Game Development Community

Skins relative to player names

by Jonny · in Technical Issues · 05/31/2006 (11:38 am) · 2 replies

Hi, im just getting in to c++ and its my first experience of programming so im probably doing somtething very basically wrong here. What i want is for players of certain names to have a certain skin set to their player as they enter the server. Ive looked at lots of different resources including these ones:



Help with setSkinName

Change Items Skin

setSkinName problems

and some others which i cant find anymore but didnt help me.

and I am using the following code in my rw/server/gametypes/basegame.cs:

//creates a player without a team, always an orc!
function GameConnection::createSinglePlayer(%this, %spawnPoint)
{
   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
   %player = new Player() {
      dataBlock = orc;
      client = %this;

  [b]  if(strcmp(%client.nameBase, "Jonny" ))
                                                                   
   %skin = "red";                                        
                                                                   
   else                                                         
     %skin = "base";                               
                                                               
  %player.setSkinName(%skin);   [/b]          


   };
   // default ammo/weapon gift.
   %player.setInventory(Crossbow,1); 
   %player.setInventory(CrossbowAmmo,20);
   %player.use(Crossbow); 

   commandToClient(%this,'SetWeaponMappings',"orc");




   //spawnTestPlayers(%spawnPoint);
   
   MissionCleanup.add(%player);

   // Player setup...
   %player.setTransform(%spawnPoint);
   %player.setEnergyLevel(60);
   //%player.setShapeName(%this.name);
   //%player.setShapeTeam("none");
   

   // Update the camera to start with the player
   %this.camera.setTransform(%player.getEyeTransform());

   // Give the client control of the player
   %this.player = %player;
   %this.setControlObject(%player);
   commandToClient(%this,'SetTeam',"1");




}

Ive put the new added code in Bold so its easy to see.


I know the skin files are named correctly because theres another server that uses them fine. Sorry for so many topics being posted on this subjects but i cant find any that have worked for me and i though it would be better to bring up a new one than to raise up old ones.

Hope some one can help!


Jon

#1
06/24/2006 (9:03 am)
From what I see, the problem is that your using strcmp. I actually learned C++ while using TGE also, so heres a site that I found very useful for all the string functions.
http://www.cplusplus.com/ref/cstring/
(Theres probally better but I like the nice and simple layout :)

http://www.cplusplus.com/ref/cstring/strcmp.html In particular explains the problem, strcmp returns 0 if hte strings are the same. If (strcmp(blah,blah) == 0) is what you want to use, as 0 is when its a match.
Although you could also use if($string $= string)

Hope that helps
#2
06/28/2006 (12:13 pm)
Thanks for the link, that will be very useful! I think the problem was also to do with the version of Realm Wars I was using, I started again fresh with out the string comparison and it worked fine. With that new info you gave me Ill try it out and see if it works!

thanks again, Jon

EDIT: Thank you so much, it works perfectly now. that had me stressing for ages!