CONNECT NPC HELP!
#1

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

https://sampforum.blast.hk/showthread.php?tid=555762
Reply
#3

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)