Changing NPC skin
#1

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.
Reply
#2

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
Reply
#3

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.
Reply
#4

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))"
Reply
#5

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
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)