IP Skin selection
by Chris Ratliff · in General Discussion · 05/06/2006 (9:35 am) · 0 replies
I have been trying to develop a way of making a player with a specific ip always login with a specific skin. I have tried to do this in many different way, but I will only list 2 of them that I cannot seem to find anything wrong with. Can anyone help me out here?
First I tried this in the base game using a if/else statement during the character creation process.
//creates a player without a team
function GameConnection::createSinglePlayer(%this, %spawnPoint, %client)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
if(strStr(%client.getAddress(), "192.168.1.200") > -1 ){
%player = new Player() {
datablock = elf;
client = %this;
};
//change the client mappings to be the right thing for elf
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"elf");
}
else {
%player = new Player() {
datablock = orc;
client = %this;
};
//change the client mappings to be the right thing for orc
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"orc");
}
... the rest of this code is default for this function
When that didnt work, I tried making this a function rather than a straight if/else.
function IpSkin(%client){
%newskin = 0;
%client = ClientGroup.getObject(%cl);
%address = %client.getAddress();
if(strStr(%client.getAddress(), "192.168.1.200") > -1 ) // IP for specific
%newskin = 1;
if(%newskin == 0)
%player = new Player() {
datablock = orc;
client = %this;
};
//change the client mappings to be the right thing for elf
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
commandToClient(%this,'SetWeaponMappings',"orc");
return 0;
%player = new Player() {
datablock = elf;
client = %this;
};
//change the client mappings to be the right thing for elf
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
commandToClient(%this,'SetWeaponMappings',"elf");
return 1;
}
Could anyone help me out with this and possibly see what it is I'm doing wrong. When I try either of these: 1) the console says it fails on the get.Address command and 2) it loads a character inventory but never allows anyone to enter the game as a character datablock is never actually loaded.
When I dont get the get.Address error, the console errors on attempting to setup the character with inventory, items, ect. Any clues to solving this problem...
Edit, I have currently been trying this as well. Problem is it works only once and then not again unless the server is completely shutdown and restarted. Any suggestive help would be appreciated.
// Create the player object
%count = ClientGroup.getCount();
for(%cl = 0; %cl < %count; %cl++)
%client = ClientGroup.getObject(%cl);
%address = %client.getAddress();
if(strStr(%Address $= "192.168.1.134") == 1 ){ // IP for specific
//change the client mappings to be the right thing for elf
%player = new Player() {
datablock = elf;
client = %this;
};
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
//%player.setInventory(Poison,1);
//%player.setInventory(PoisonAmmo,20);
//%player.setInventory(firebow,1);
//%player.setInventory(fireAmmo,20);
%player.setInventory(Flamebow,1);
%player.setInventory(FlameAmmo,20);
%player.setInventory(CoCo,1);
%player.setInventory(CoCoAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"elf");
}
else{
//change the client mappings to be the right thing for orc
%player = new Player() {
datablock = orc;
client = %this;
};
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
//%player.setInventory(Poison,1);
//%player.setInventory(PoisonAmmo,20);
//%player.setInventory(firebow,1);
//%player.setInventory(fireAmmo,20);
%player.setInventory(Flamebow,1);
%player.setInventory(FlameAmmo,20);
%player.setInventory(CoCo,1);
%player.setInventory(CoCoAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"orc");
}
First I tried this in the base game using a if/else statement during the character creation process.
//creates a player without a team
function GameConnection::createSinglePlayer(%this, %spawnPoint, %client)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
if(strStr(%client.getAddress(), "192.168.1.200") > -1 ){
%player = new Player() {
datablock = elf;
client = %this;
};
//change the client mappings to be the right thing for elf
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"elf");
}
else {
%player = new Player() {
datablock = orc;
client = %this;
};
//change the client mappings to be the right thing for orc
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"orc");
}
... the rest of this code is default for this function
When that didnt work, I tried making this a function rather than a straight if/else.
function IpSkin(%client){
%newskin = 0;
%client = ClientGroup.getObject(%cl);
%address = %client.getAddress();
if(strStr(%client.getAddress(), "192.168.1.200") > -1 ) // IP for
%newskin = 1;
if(%newskin == 0)
%player = new Player() {
datablock = orc;
client = %this;
};
//change the client mappings to be the right thing for elf
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
commandToClient(%this,'SetWeaponMappings',"orc");
return 0;
%player = new Player() {
datablock = elf;
client = %this;
};
//change the client mappings to be the right thing for elf
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
commandToClient(%this,'SetWeaponMappings',"elf");
return 1;
}
Could anyone help me out with this and possibly see what it is I'm doing wrong. When I try either of these: 1) the console says it fails on the get.Address command and 2) it loads a character inventory but never allows anyone to enter the game as a character datablock is never actually loaded.
When I dont get the get.Address error, the console errors on attempting to setup the character with inventory, items, ect. Any clues to solving this problem...
Edit, I have currently been trying this as well. Problem is it works only once and then not again unless the server is completely shutdown and restarted. Any suggestive help would be appreciated.
// Create the player object
%count = ClientGroup.getCount();
for(%cl = 0; %cl < %count; %cl++)
%client = ClientGroup.getObject(%cl);
%address = %client.getAddress();
if(strStr(%Address $= "192.168.1.134") == 1 ){ // IP for
//change the client mappings to be the right thing for elf
%player = new Player() {
datablock = elf;
client = %this;
};
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
//%player.setInventory(Poison,1);
//%player.setInventory(PoisonAmmo,20);
//%player.setInventory(firebow,1);
//%player.setInventory(fireAmmo,20);
%player.setInventory(Flamebow,1);
%player.setInventory(FlameAmmo,20);
%player.setInventory(CoCo,1);
%player.setInventory(CoCoAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"elf");
}
else{
//change the client mappings to be the right thing for orc
%player = new Player() {
datablock = orc;
client = %this;
};
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,20);
//%player.setInventory(Poison,1);
//%player.setInventory(PoisonAmmo,20);
//%player.setInventory(firebow,1);
//%player.setInventory(fireAmmo,20);
%player.setInventory(Flamebow,1);
%player.setInventory(FlameAmmo,20);
%player.setInventory(CoCo,1);
%player.setInventory(CoCoAmmo,20);
%player.use(Crossbow);
commandToClient(%this,'SetWeaponMappings',"orc");
}
About the author