SA-MP Forums Archive
Changing NPC skin - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Changing NPC skin (/showthread.php?tid=178493)



Changing NPC skin - jurtes - 22.09.2010

Is there any way I can change the skin of my npc's, some how if I ingame /setskin on myself and than record I end up getting the same skin on each character, is there anyway I can set there skin from pawno. I already tried SetPlayerSkin but it doesn't work because the player id's of the bots are random.


Re: Changing NPC skin - Rachael - 22.09.2010

pawn Код:
public OnPlayerSpawn(playerid)
{
     if(IsPlayerNPC(playerid))
     {
          new npc_name[24];
          GetPlayerName(playerid,npc_name,sizeof(npc_name));
          if(!strcmp(npc_name,"Name_Of_Your_NPC",false))
          {
               SetPlayerSkin(playerid, 264); // your skin choice for NPC
          }
          return 1;
     }
//rest of callback here



Re: Changing NPC skin - jurtes - 22.09.2010

pawn Код:
public OnPlayerSpawn(playerid)
 {
        if(IsPlayerNPC(playerid))
        {
            new npc_name[24];
            GetPlayerName(playerid,npc_name,sizeof(npc_name));
            if(!strcmp(npc_name,"Cocaine1",false))
            {
            SetPlayerSkin(playerid, 144); // your skin choice for NPC
            }
            return 1;
        }



        if(IsPlayerNPC(playerid))
        {
            new npc_name[24];
            GetPlayerName(playerid,npc_name,sizeof(npc_name));
            if(!strcmp(npc_name,"Cocaine2",false))
            {
            SetPlayerSkin(playerid, 144); // your skin choice for NPC
            }
            return 1;
        }
       
        if(IsPlayerNPC(playerid))
        {
            new npc_name[24];
            GetPlayerName(playerid,npc_name,sizeof(npc_name));
            if(!strcmp(npc_name,"Cocaine3",false))
            {
            SetPlayerSkin(playerid, 144); // your skin choice for NPC
            }
            return 1;
        }

    return 1;
}
This is what I got now, but only the first one ''Cocaine1'' Changed skin the others didn't.


Re: Changing NPC skin - Rachael - 22.09.2010

look at your script, it will return 1; for any npc, and only change the name of the first one.
Put all of the if statements under the same "if(IsPlayerNPC(playerid))"


Re: Changing NPC skin - jurtes - 22.09.2010

I'm sorry I don't know very much about scripting but I'm doing this for a roleplay project on a server, could you maybe give a excample code with 2 npc skin changes. Would be awesome mate


Re: Changing NPC skin - Mauzen - 22.09.2010

pawn Код:
public OnPlayerSpawn(playerid)
{
        if(IsPlayerNPC(playerid))
        {
            new npc_name[24];
            GetPlayerName(playerid,npc_name,sizeof(npc_name));
            if(!strcmp(npc_name,"Cocaine1",false))
            {
                SetPlayerSkin(playerid, 144); // your skin choice for NPC
            }
            if(!strcmp(npc_name,"Cocaine2",false))
            {
                SetPlayerSkin(playerid, 144); // your skin choice for NPC
            }
            if(!strcmp(npc_name,"Cocaine3",false))
            {
                SetPlayerSkin(playerid, 144); // your skin choice for NPC
            }
        }
    return 1;
}
Just remove all the return 1, except the very last one.
And for the performance and a clean style dont do the
IsPlayerNPC, GetPlayerName stuff again and again. Checking it one time is enough, if you got the name, just check them one directly after the other.