Server Crash: NPC Delayed Timers -
DJ_Shocker - 27.06.2014
CODE:
pawn Код:
SafeConnectNPC("[Bot]Robert","npcidle");
SafeConnectNPC("[Bot]Peter","npcidle");
SafeConnectNPC("[Bot]Harry","npcidle");
SafeConnectNPC("[Bot]Kayla","npcidle");
SafeConnectNPC("[Bot]Aaron","npcidle");
SafeConnectNPC("[Bot]Joshua","npcidle");
SafeConnectNPC("[Bot]Trevor","train_lv");
SafeConnectNPC("[Bot]Gary","train_ls");
SafeConnectNPC("[Bot]Paul","train_sf");
SafeConnectNPC("[Bot]Qantas","at400_lv");
SafeConnectNPC("[Bot]JetStar","at400_sf");
SafeConnectNPC("[Bot]Virgin","at400_ls");
SafeConnectNPC("[Bot]TramDriver","tram");
SafeConnectNPC("[Bot]Rick","npcidle");//SF
SafeConnectNPC("[Bot]Charlie","npcidle");//LV
SafeConnectNPC("[Bot]Tom","npcidle");//LS
SafeConnectNPC("[Bot]Buddy","npcidle");
return 1;
}
stock SafeConnectNPC(npcname[], npcfile[])
{
new therand = random(1000-300)+300;
SetTimerEx("SafeConnectNPC2", therand, 0, "ss", npcname, npcfile);
}
forward SafeConnectNPC2(npcname[], npcfile[]);
public SafeConnectNPC2(npcname[], npcfile[])
{
ConnectNPC(npcname, npcfile); //Line 9805
}
Upon booting up the server, it crashes immediately. with this:
Код:
[18:20:44] Number of vehicle models: 125
[18:20:46] [debug] Server crashed while executing cnr.amx
[18:20:46] [debug] AMX backtrace:
[18:20:46] [debug] #0 native ConnectNPC () [00476170] from samp-server.exe
[18:20:46] [debug] #1 0005e810 in public SafeConnectNPC2 (npcname[]=@0x00a11af0 "[Bot]Buddy", npcfile[]=@0x00a11ad0 "dpcidle") at cnr.pwn:9805
[18:20:46] [debug] Native backtrace:
[18:20:46] [debug] #0 00476230 in ?? () from samp-server.exe
[18:20:46] [debug] #1 004010b6 in ?? () from samp-server.exe
[18:20:46] [debug] #2 726660ba in ?? () from crashdetect.DLL
[18:20:46] [debug] #3 72667fee in ?? () from crashdetect.DLL
[18:20:46] [debug] #4 72660091 in ?? () from crashdetect.DLL
[18:20:46] [debug] #5 7266610a in ?? () from crashdetect.DLL
[18:20:46] [debug] #6 0047f188 in ?? () from samp-server.exe
[18:20:46] [debug] #7 0048b70a in ?? () from samp-server.exe
Re: Server Crash: NPC Delayed Timers -
xo - 27.06.2014
Did you check the random value?
Re: Server Crash: NPC Delayed Timers -
DJ_Shocker - 27.06.2014
Where do you see something wrong with the random value?
Re: Server Crash: NPC Delayed Timers - Emmet_ - 27.06.2014
Strings don't work with "SetTimerEx", you'll have to manually store them.
Re: Server Crash: NPC Delayed Timers -
DJ_Shocker - 28.06.2014
Thanks Emmet_ I never knew that.
So brainstorming, and after ranting at Skyrise in Skype about how hackers and trolls with no lives like to ruin fun for others, I figured out a solution.
FIRST: Thanks Skyrise for letting me rant!
I'm going to share it here for everyone in the future who is smart enough to use the Search Function.
pawn Код:
forward ConnectBots(ID);
public ConnectBots (ID)
{
switch(ID)
{
case 1 : ConnectNPC("[Bot]Robert","npcidle");
case 2 : ConnectNPC("[Bot]Peter","npcidle1");
case 3 : ConnectNPC("[Bot]Harry","npcidle2");
case 4 : ConnectNPC("[Bot]Kayla","npcidle3");
case 5 : ConnectNPC("[Bot]Aaron","npcidle4");
case 6 : ConnectNPC("[Bot]Joshua","npcidle5");
case 7 : ConnectNPC("[Bot]Trevor","train_lv");
case 8 : ConnectNPC("[Bot]Gary","train_ls");
case 9 : ConnectNPC("[Bot]Paul","train_sf");
case 10 : ConnectNPC("[Bot]JetStar","at400_sf");
case 11 : ConnectNPC("[Bot]Virgin","at400_ls");
case 12 : ConnectNPC("[Bot]TramDriver","tram");
case 13 : ConnectNPC("[Bot]Rick","npcidle6");//SF
case 14 : ConnectNPC("[Bot]Charlie","npcidle7");//LV
case 15 : ConnectNPC("[Bot]Tom","npcidle8");//LS
case 16 : ConnectNPC("[Bot]Buddy","npcidle9");
case 17 : return 1 ;
}
SetTimerEx("ConnectBots", 5000, 0, "i", ID+1);
return 1;
}
and in your OnPlayerConnect, you're going to want to put: ConnectBots(1);
It will start with 1, and when it reaches 17, it will stop.