CONNECT NPC HELP! - 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: CONNECT NPC HELP! (
/showthread.php?tid=555895)
CONNECT NPC HELP! -
JawsPlus - 09.01.2015
Connect random NPC is possible ??
Код:
new RandomNPC = random(2);
if(RandomNPC == 1)
{
ConnectNPC("TrustyGuard","npc");
return 1;
}
if(RandomNPC == 2)
{
ConnectNPC("TrustyGuard","npc2");
return 1;
}
I do this but NPC not connect.
How to fix it
Re: CONNECT NPC HELP! -
KayJ - 09.01.2015
https://sampforum.blast.hk/showthread.php?tid=555762
Re: CONNECT NPC HELP! -
JawsPlus - 09.01.2015
NO i mean i want to connect npc randomly like
Example :
if i want to connect a npc with the same name but difference npcmodes
Код:
ConnectNPC("1","1");
or
ConnectNPC("1","2");
Re: CONNECT NPC HELP! -
Threshold - 09.01.2015
Yes. All you need to do is change the number of NPCs that you want to select from. Example, if you have 10 different NPCs, you would use 'random(10)', if you had 6 NPCs, you would use 'random(6)' etc.
pawn Код:
switch(random(5))
{
case 0: ConnectNPC("NPC1", "File1");
case 1: ConnectNPC("NPC2", "File2");
case 2: ConnectNPC("NPC3", "File3");
case 3: ConnectNPC("NPC4", "File4");
case 4: ConnectNPC("NPC5", "File5");
}
Remember that 'random' returns a number between 0 and the number given take 1. 'random(10)' gives a number between 0 and 9. 'random(5)' gives a number between 0 and 4, etc.
References:
https://sampwiki.blast.hk/wiki/Keywords:Statements#switch
https://sampwiki.blast.hk/wiki/Random
https://sampwiki.blast.hk/wiki/ConnectNPC