SA-MP Forums Archive
[Help] Setting Bot Skins - 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)
+--- Thread: [Help] Setting Bot Skins (/showthread.php?tid=561056)



[Help] Setting Bot Skins - DukeVega - 31.01.2015

Hello again,

I am just learning how to make simple Bot's, so far I have them spawning in game and working.
My problem right now is that the Bots are all using the same skins.


I am sure it is because i havnt split up the script properly, as seen below.
im sure its obvious to anyone who knows what they are doing, but for me sorry its not so easy.

Please let me know whats wrong with this script,

Much love


Duke <3



Код:
public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("    Fallout RP New Vegas BOTS        ");
	print("--------------------------------------\n");
	return 1;
}

#endif

public OnPlayerSpawn(playerid)
{
  print("BOTS");
  ConnectNPC("Civilian1","nvciv1");
  SetPlayerSkin(playerid, 1);
  
  ConnectNPC("Civilian2","nvciv2diner");
  SetPlayerSkin(playerid, 11);
  
  ConnectNPC("Civilian3","nvciv3");
  SetPlayerSkin(playerid, 32);

  ConnectNPC("Civilian4","nvciv4");
  SetPlayerSkin(playerid, 93);
  
  ConnectNPC("Civilian5","nvbouncer");
  SetPlayerSkin(playerid, 30);
}



Re: [Help] Setting Bot Skins - Vince - 31.01.2015

That's not how it works at all. You connect the bots ONCE when the mode starts and you use strcmp to compare their names in OnPlayerSpawn so you can set their skin accordingly.


Re: [Help] Setting Bot Skins - CalvinC - 31.01.2015

First of all, i you should connect your NPC's under OnFilterScriptInit for it to work.

You should use Strcmp to check their name, then set the skin accordingly:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid)) // Checks if playerid is an NPC
    {
        new NpcName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, NpcName, sizeof(NpcName)); // Get's the NPC's name
        if(!strcmp(NpcName, "Civilian1", false)) SetPlayerSkin(playerid, 1); // Checks if the NPC's name is Civilian1, if so, it sets the skin to 1.
                // Then you can do the same as the above line with the rest of your NPC's.
    }
    return 1;
}
Your script will just setplayerskin 1, then it will set skin to 11, set skin to 32, then 93, then 30. So they would all have skin ID 30.


Re: [Help] Setting Bot Skins - DukeVega - 31.01.2015

it wont let me Rep you anymore Calvin lol... thanks matey ill try this now


Re: [Help] Setting Bot Skins - GenzT - 01.02.2015

Try this..

Код:
public OnFilterScriptInit()
{
	print("BOTS");
	ConnectNPC("Civilian1","nvciv1");
	ConnectNPC("Civilian2","nvciv2diner");
	ConnectNPC("Civilian3","nvciv3");
	ConnectNPC("Civilian4","nvciv4");
	ConnectNPC("Civilian5","nvbouncer");
	return 1;
}
public OnPlayerSpawn(playerid)
{
	if(IsPlayerNPC(playerid))
	{
		new npcname[MAX_PLAYER_NAME];
		GetPlayerName(playerid, npcname, sizeof(npcname));
		if(!strcmp(npcname, "Civilian1", false)) SetPlayerSkin(playerid, 1);
		if(!strcmp(npcname, "Civilian2", false)) SetPlayerSkin(playerid, 11);
		if(!strcmp(npcname, "Civilian3", false)) SetPlayerSkin(playerid, 32);
		if(!strcmp(npcname, "Civilian4", false)) SetPlayerSkin(playerid, 93);
		if(!strcmp(npcname, "Civilian5", false)) SetPlayerSkin(playerid, 30);
	}
	return 1;
}



Re: [Help] Setting Bot Skins - DukeVega - 01.02.2015

Thanks Guys, really appreciate it was stuggling there for a whiel and getting a bit muddled up. this works great now ,cheers .. Rep +++++