Server Crash on NPC Connect Timer
#1

I'm trying to connect some Bots to the Server with a Timer but it keeps crashing.

Can someone help me with that?

OnFilterScriptInit:

Код:
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 & Public:

Код:
forward SpawnZombie(name[]);

public SpawnZombie(name[])
{
    ConnectRNPC(name);
    return 1;
}
Serverlog:

Код:
[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
Reply
#2

show full your server_logs, i think update you crashdetect plugins and recompile again
Reply
#3

Hey dude, why do you use a timer to create NPC (why wait 1s?), also show me hownyou defined ZOMBIE_NAME
Reply
#4

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Hey dude, why do you use a timer to create NPC (why wait 1s?), also show me hownyou defined ZOMBIE_NAME
Because i need some more and if they connect all together server blocks them.


#define ZOMBIE_NAME "Zombie[%i]"
Reply
#5

Wiki states "s" is unusable even though it does work. You can try pass the npcid and retrieve name in the timer's callback:
pawn Код:
SetTimerEx("SpawnZombie", 1000, false, "i", npcid);
pawn Код:
forward SpawnZombie(npc_id);
public SpawnZombie(npc_id)
{
    new name[24];
    format(name, sizeof(name), ZOMBIE_NAME, npc_id + 1);
    ConnectRNPC(name);
    return 1;
}
Reply
#6

Quote:
Originally Posted by LongGong
Посмотреть сообщение
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.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
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.
Yes, saw it now..

i tried it with:

Код:
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;
}
But now i get error 076: syntax error in the expression, or invalid function call
at KillTimer(ZombieTimer);

Edit:
Timer: SetTimer("ZombieTimer", 500, true);
Reply
#8

No one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)