public OnFilterScriptInit()
{
RNPC_SetUpdateRate(80);
MapAndreas_Init(MAP_ANDREAS_MODE_NOBUFFER);
new count = 0;
for(new npcid = 0; npcid < MAX_ZOMBIES; npcid++)
{
new name[24];
format(name, sizeof(name), ZOMBIE_NAME, npcid + 1);
SetTimerEx("SpawnZombie", 1000, false, "s", name);
count++;
}
printf("Number of zombies created: %i", count);
SetTimer("OnZombieAttack", 1000, true);
SetTimer("OnZombieRoam", 10000, true);
return 1;
}
forward SpawnZombie(name[]);
public SpawnZombie(name[])
{
ConnectRNPC(name);
return 1;
}
[01:12:19] [01:12:19] Filterscripts [01:12:19] --------------- [01:12:19] Loading filterscript 'zombietest.amx'... [01:12:20] [debug] Server crashed while executing zombietest.amx [01:12:20] [debug] AMX backtrace: [01:12:20] [debug] #0 native SetTimerEx () from samp-server.exe [01:12:20] [debug] #1 00003224 in public OnFilterScriptInit () from zombietest.amx [01:12:20] [debug] Native backtrace: [01:12:20] [debug] #0 0048288c in ?? () from samp-server.exe [01:12:20] [debug] #1 00473919 in ?? () from samp-server.exe [01:12:20] [debug] #2 004010b6 in ?? () from samp-server.exe [01:12:20] [debug] #3 6cb5d60a in ?? () from plugins\crashdetect.DLL [01:12:20] [debug] #4 6cb64078 in ?? () from plugins\crashdetect.DLL [01:12:20] [debug] #5 6cb5a767 in ?? () from plugins\crashdetect.DLL [01:12:20] [debug] #6 6cb5d65a in ?? () from plugins\crashdetect.DLL [01:12:20] [debug] #7 6cae4629 in ?? () from plugins\streamer.DLL [01:12:20] [debug] #8 0046a958 in ?? () from samp-server.exe
|
Hey dude, why do you use a timer to create NPC (why wait 1s?), also show me hownyou defined ZOMBIE_NAME
|
SetTimerEx("SpawnZombie", 1000, false, "i", npcid);
forward SpawnZombie(npc_id);
public SpawnZombie(npc_id)
{
new name[24];
format(name, sizeof(name), ZOMBIE_NAME, npc_id + 1);
ConnectRNPC(name);
return 1;
}
|
Because i need some more and if they connect all together server blocks them.
|
|
I don't think you realize that you current code does exactly the same thing. It just waits 1 second and then it connects them all simultaneously anyway. If you need a 1 second interval then you can multiply "npcid" with 1000. There is another solution that only uses one timer but it is more complex and since this thing only gets executed once it doesn't really matter.
|
forward ZombieTimer();
public ZombieTimer()
{
RNPC_SetUpdateRate(80);
MapAndreas_Init(MAP_ANDREAS_MODE_NOBUFFER);
new zombie_count = 0;
new name[24];
format(name, sizeof(name), "Zombie_%i", zombie_count + 1);
ConnectRNPC(name);
zombie_count++;
if(zombie_count == MAX_ZOMBIES)
{
KillTimer(ZombieTimer);
}
return 1;
}