SA-MP Forums Archive
MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap (/showthread.php?tid=468873)



MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - flrp - 10.10.2013

Hello, i have been experiencing probably the worst nightmare bug i could ever had...
Basically i can start my server, i can connect, but when the second player connects my server crashed. When this happened i deleted some commented lines (wich makes no sense) and i rebuilt it, and then my server worked again but on the third player i crashed. then i made a few random changes and then it was again on the second player, then sometimes it was on the forth player connection that would make the server crash... I dont get any errors on compiling my gamemode is 85k lines long. I used crashdetect and this is the error that came up to my attention , i get a spam of this:

Код:
repetitivespam.....
[02:34:36] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:36] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:36] [debug] Run time error 4: "Array index out of bounds"
[02:34:36] [debug]  Accessing element at index 5 past array upper bound 4
[02:34:36] [debug] AMX backtrace:
[02:34:36] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:36] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:38] [debug] Run time error 4: "Array index out of bounds"
[02:34:38] [debug]  Accessing element at index 5 past array upper bound 4
[02:34:38] [debug] AMX backtrace:
[02:34:38] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:38] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:39] [debug] Run time error 4: "Array index out of bounds"
[02:34:39] [debug]  Accessing element at index 5 past array upper bound 4
[02:34:39] [debug] AMX backtrace:
[02:34:39] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:39] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:40] [debug] Run time error 4: "Array index out of bounds"
[02:34:40] [debug]  Accessing element at index 5 past array upper bound 4
[02:34:40] [debug] AMX backtrace:
[02:34:40] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:40] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:41] [debug] Run time error 4: "Array index out of bounds"
[02:34:41] [debug]  Accessing element at index 5 past array upper bound 4
[02:34:41] [debug] AMX backtrace:
[02:34:41] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:41] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:42] [debug] Run time error 4: "Array index out of bounds"
[02:34:42] [debug]  Accessing element at index 5 past array upper bound 4
[02:34:42] [debug] AMX backtrace:
[02:34:42] [debug] #0 0001985c in ?? () from HaxifyDMRPG.amx
[02:34:42] [debug] #1 000c5670 in public OtherTimer2 () from HaxifyDMRPG.amx
[02:34:42] Incoming connection: 188.83.155.43:57429
[02:34:43] [join] testingaaax has joined the server (3:188.83.155.43)
[02:35:12] Kicking 188.83.155.43 because they didn't logon to the game.
(in this case it was on the third player connected that the server crashed, it was right when he connected. )

Here is the OtherTimer2:

(ignore the commented lines)
Код:
public OtherTimer2(playerid)
{
    if(IsPlayerConnected(playerid))
    {
    	    new Float:maxspeed = 275.0;
    		new plname[MAX_PLAYER_NAME];
			new string[128];
			new Float:oldposx, Float:oldposy, Float:oldposz;
			new zone[MAX_ZONE_NAME];
			new d,m,y,h,mi,s;
			getdate(y,m,d);
			gettime(h,mi,s);
	        if(PlayerInfo[playerid][pInteriorNr] == 0)
			{
		        GetPlayer2DRadarZone(playerid, zone, MAX_ZONE_NAME);
		        format(string,sizeof(string),"%s",zone);
		        TextDrawSetString(Textdraw49[playerid], string);
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 1)
			{
		        TextDrawSetString(Textdraw49[playerid], "LSPD");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 2)
			{
		        TextDrawSetString(Textdraw49[playerid], "City Hall");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 3)
			{
		        TextDrawSetString(Textdraw49[playerid], "Bank");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 4)
			{
		        TextDrawSetString(Textdraw49[playerid], "FBI HQ");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 10)
			{
		        TextDrawSetString(Textdraw49[playerid], "Regulars Lounge");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 11)
			{
		        TextDrawSetString(Textdraw49[playerid], "DMW");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 12)
			{
		        TextDrawSetString(Textdraw49[playerid], "24/7");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 13)
			{
		        TextDrawSetString(Textdraw49[playerid], "Ammunation");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 14)
			{
		        TextDrawSetString(Textdraw49[playerid], "Weapon Store");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 15)
			{
		        TextDrawSetString(Textdraw49[playerid], "Gym");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 16)
			{
		        TextDrawSetString(Textdraw49[playerid], "Binco");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 17)
			{
		        TextDrawSetString(Textdraw49[playerid], "Pig Pen");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 18)
			{
		        TextDrawSetString(Textdraw49[playerid], "Alhambra");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 20)
			{
		        TextDrawSetString(Textdraw49[playerid], "Cluckin' Bell");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 21)
			{
		        TextDrawSetString(Textdraw49[playerid], "Burger Shoot");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 22)
			{
		        TextDrawSetString(Textdraw49[playerid], "Pizza Hut");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 23)
			{
		        TextDrawSetString(Textdraw49[playerid], "Firemen HQ");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 24)
			{
		        TextDrawSetString(Textdraw49[playerid], "Hitmen HQ");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 25)
			{
		        TextDrawSetString(Textdraw49[playerid], "DD Stadium");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 26)
			{
		        TextDrawSetString(Textdraw49[playerid], "Ten Green");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 28)
			{
		        TextDrawSetString(Textdraw49[playerid], "Airlines");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 29)
			{
		        TextDrawSetString(Textdraw49[playerid], "Hospital");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 30)
			{
		        TextDrawSetString(Textdraw49[playerid], "Donut Store");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 32)
			{
		        TextDrawSetString(Textdraw49[playerid], "ABC Studio");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 33)
			{
		        TextDrawSetString(Textdraw49[playerid], "Yellow Cab HQ");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 34)
			{
		        TextDrawSetString(Textdraw49[playerid], "Sex Shop");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 35)
			{
		        TextDrawSetString(Textdraw49[playerid], "Sub Urban");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 36)
			{
		        TextDrawSetString(Textdraw49[playerid], "ZIP");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 37)
			{
		        TextDrawSetString(Textdraw49[playerid], "Victim");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 38)
			{
		        TextDrawSetString(Textdraw49[playerid], "Restaurant");
			}
   			else if(PlayerInfo[playerid][pInteriorNr] == 39)
			{
		        TextDrawSetString(Textdraw49[playerid], "House");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 41)
			{
		        TextDrawSetString(Textdraw49[playerid], "Ministery of ~n~Defense HQ");
			}
			else if(PlayerInfo[playerid][pInteriorNr] == 60)
			{
		        TextDrawSetString(Textdraw49[playerid], "Driving School");
			}
			else
			{
			    TextDrawSetString(Textdraw49[playerid], "Unknown~n~~r~Contact a Manager+.");
			}
	        //new vehicleid = GetPlayerVehicleID(playerid);
            if(SafeTime[playerid] > 0)
			{
				//SafeTime[playerid]--;
			}
			if(SafeTime[playerid] == 1)
			{
				if(gPlayerAccount[playerid] == 1 && gPlayerLogged[playerid] == 0)
				{
					SendClientMessage(playerid, COLOR_WHITE, "HINT: You took too long to login.");
					SetTimer("tooktoolong", 100, false); //took too long kick failed login
				}
			}
		    if(GetPlayerState(playerid) == 2)
		    {
     			new kmh = GetPlayerSpeed(playerid, true);
				//if ((BusrouteEast[playerid][0] >= 0 && BusrouteWest[playerid][0] >= 0))
				//{
				if(PlayerInfo[playerid][pSpeedo] == 2)
				{
						format(string, 64, "~g~~h~KM/H     ~r~~h~%d", kmh);
						TextDrawSetString(Textdraw39[playerid], string);
				}
				if(kmh > maxspeed && PlayerInfo[playerid][pAdmin] < 6)
				{
				        new tmpcar = GetPlayerVehicleID(playerid);
						if(!IsAPlane(tmpcar) || tmpcar < 1698)
						{
							if(!IsPlayerNPC(playerid))
							{
							    if(PlayerGotSpottedRecently[playerid] == 0)
							    {
									GetPlayerName(playerid, plname, sizeof(plname));
									format(string, 128, "[AC]: %s (%d) is going at %d km/h; Check him immediately!!",plname,playerid,kmh);
									SendAdminMessage(COLOR_YELLOW,string);
									PlayerSuspicious[playerid] = 1;
									PlayerSpeedHacking[playerid] = 1;
									PlayerSuspiciousSpeed[playerid] = kmh;
									PlayerGotSpottedRecently[playerid] = 1;
	                                SetTimerEx("ResetAcWarn", 60000, 0, "i", playerid);
								}
							}
						}
				}
				//}
				if(gGas[playerid] == 1)
		   		{
		   		    /*new vehicle = GetPlayerVehicleID(playerid);
            		if(IsModelAPlane(vehicle) || IsModelABoat(vehicle) || IsModelABycicle(vehicle) || IsModelAHeli(vehicle))
  		   			{
          				//format(string, sizeof(string), "~g~~h~Fuel    ~g~~h~N/A");
					}
					else if(vehicle >= 1698)
					{
     					//format(string, sizeof(string), "~g~~h~Fuel    ~g~~h~Unknown");
					}
					else
					{
					    if(Gas[vehicle] > 10)
					    {
	                       	//format(string, sizeof(string), "~g~~h~Fuel    ~g~~h~%d%.",Gas[vehicle]);
						}
						else
						{
						    //format(string, sizeof(string), "~g~~h~Fuel    ~r~~h~%d%.",Gas[vehicle]);
						}
					}
					TextDrawSetString(Textdraw40[playerid], string);*/
   		 		}
			}
		    if(PlayerInfo[playerid][pLocal] != 255 && PlayerInfo[playerid][pInt] != 0)
			{
				new house = PlayerInfo[playerid][pLocal];
				GetPlayerPos(playerid, oldposx, oldposy, oldposz);
				if(oldposz != 0.0)
				{
					if(oldposz < 600.0)
					{
						if(house == 242)
						{
						    SafeSetPlayerInterior(playerid,0);
							SafeSetPlayerPos(playerid,-2518.5967,-623.2701,132.7679);
							PlayerInfo[playerid][pLocal] = 255;
						}
						else if(house < 99 && house != 10000)
						{
							SafeSetPlayerPos(playerid, HouseInfo[house][hEntrancex], HouseInfo[house][hEntrancey],HouseInfo[house][hEntrancez]); // Warp the player
							PlayerInfo[playerid][pLocal] = 255;
							SafeSetPlayerInterior(playerid,0);
						}
					}
				}
			}
		    if(CellTime[playerid] > 0)
			{
				if (CellTime[playerid] == cchargetime)
				{
					CellTime[playerid] = 1;
					if(Mobile[Mobile[playerid]] == playerid)
					{
						CallCost[playerid] = CallCost[playerid]+callcost;
					}
				}
				CellTime[playerid] = CellTime[playerid] +1;
				if (Mobile[Mobile[playerid]] == 255 && CellTime[playerid] == 5)
				{
				    if(IsPlayerConnected(Mobile[playerid]))
				    {
						new called[MAX_PLAYER_NAME];
						GetPlayerName(Mobile[playerid], called, sizeof(called));
						format(string, sizeof(string), "%s's phone rings.", called);
						RingTone[Mobile[playerid]] = 10;
						ProxDetector(30.0, Mobile[playerid], string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					}
				}
			}
			if(CellTime[playerid] == 0 && CallCost[playerid] > 0)
			{
				format(string, sizeof(string), "~w~The call cost~n~~r~$%d",CallCost[playerid]);
				SafeGivePlayerMoney(playerid, -CallCost[playerid]);
				SBizzInfo[2][sbTill] += CallCost[playerid];
				ExtortionSBiz(2, CallCost[playerid]);
				GameTextForPlayer(playerid, string, 5000, 1);
				CallCost[playerid] = 0;
			}
			if(TransportTime[playerid] > 0)
			{//Taxi driver and passenger only
			    if(TransportTime[playerid] >= 16)
				{
					TransportTime[playerid] = 1;
					if(TransportDriver[playerid] < 999)
					{
						if(IsPlayerConnected(TransportDriver[playerid]))
						{
	      					TransportCost[playerid] += TransportValue[TransportDriver[playerid]];
						    TransportCost[TransportDriver[playerid]] = TransportCost[playerid];
						}
					}
				}
			    TransportTime[playerid] += 1;
			    format(string, sizeof(string), "~r~%d ~w~: ~g~$%d",TransportTime[playerid],TransportCost[playerid]);
			    GameTextForPlayer(playerid, string, 15000, 6);
			}
			/*if (BusrouteEast[playerid][0] != 0 || BusrouteWest[playerid][0] != 0)
			{
				if (!IsPlayerInAnyVehicle(playerid) || !IsABus(GetPlayerVehicleID(playerid)))
				if (vehicleid != 0)
				{
					if (!IsABus(vehicleid))
					{
						if (BusrouteEast[playerid][0] != 0) BusrouteEnd(playerid, BusrouteEast[playerid][1]);
						else if (BusrouteWest[playerid][0] != 0) BusrouteEnd(playerid, BusrouteWest[playerid][1]);
					}
				}
				else
				{
					if (BusrouteEast[playerid][0] != 0) BusrouteEnd(playerid, BusrouteEast[playerid][1]);
					else if (BusrouteWest[playerid][0] != 0) BusrouteEnd(playerid, BusrouteWest[playerid][1]);
				}
			}*/
			//if (IsABus(vehicleid) && GetPlayerState(playerid) == 2 && PlayerInfo[playerid][pJob] != 14)
			//{
			//	RemovePlayerFromVehicle(playerid);
			//}
	}
	return 1;
}
Please help me this is urgent. Leave me a skype contact if possible. Thanks.


Re: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - JamesH - 11.10.2013

I dont think thats what causing the crash though.

Show us the log.txt please.


Re: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - Konstantinos - 11.10.2013

There are few suspicious parts but I'm not sure which one caused it.
pawn Код:
new house = PlayerInfo[playerid][pLocal];
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
if(oldposz != 0.0)
{
    if(oldposz < 600.0)
    {
        if(house == 242)
        {
            SafeSetPlayerInterior(playerid,0);
            SafeSetPlayerPos(playerid,-2518.5967,-623.2701,132.7679);
            PlayerInfo[playerid][pLocal] = 255;
        }
        else if(house < 99 && house != 10000)
        {
            SafeSetPlayerPos(playerid, HouseInfo[house][hEntrancex], HouseInfo[house][hEntrancey],HouseInfo[house][hEntrancez]); // Warp the player
            PlayerInfo[playerid][pLocal] = 255;
            SafeSetPlayerInterior(playerid,0);
        }
    }
}
pawn Код:
// I doubt about it, it should be with a size of MAX_PLAYERS
if(CellTime[playerid] > 0)
{
    if (CellTime[playerid] == cchargetime)
    {
        CellTime[playerid] = 1;
        if(Mobile[Mobile[playerid]] == playerid)
        {
            CallCost[playerid] = CallCost[playerid]+callcost;
        }
    }
    CellTime[playerid] = CellTime[playerid] +1;
    if (Mobile[Mobile[playerid]] == 255 && CellTime[playerid] == 5)
    {
        if(IsPlayerConnected(Mobile[playerid]))
        {
            new called[MAX_PLAYER_NAME];
            GetPlayerName(Mobile[playerid], called, sizeof(called));
            format(string, sizeof(string), "%s's phone rings.", called);
            RingTone[Mobile[playerid]] = 10;
            ProxDetector(30.0, Mobile[playerid], string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
}
pawn Код:
if(TransportTime[playerid] > 0)
{//Taxi driver and passenger only
    if(TransportTime[playerid] >= 16)
    {
        TransportTime[playerid] = 1;
        if(TransportDriver[playerid] < 999)
        {
            if(IsPlayerConnected(TransportDriver[playerid]))
            {
                TransportCost[playerid] += TransportValue[TransportDriver[playerid]];
                TransportCost[TransportDriver[playerid]] = TransportCost[playerid];
            }
        }
    }
You need to do 2 things:

• Get the latest version of crashdetect (if you don't have it) which is 4.12 (it can be found: https://github.com/Zeex/samp-plugin-...ases/tag/v4.12). Goto pawno directory and create a file pawn.cfg
Open it and write in it:
pawn Код:
-d3
Save it and re-compile HaxifyDMRPG.pwn file. Alright, it is now compiled with the debug mode.

If the server gets crashed, then there's a chance to give the line caused the crash!

• Please show us how did you declare the following: HouseInfo, TransportValue, TransportCost.


Re: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - BlueBaron - 11.10.2013

This may also happen if you didn't setup the required folders in "scriptfiles". For instance, if you got the PWN/AMX from the forum, without getting the whole server files. But yet again, its 1 in a 1000. It isn't common, but its just a wild guess.

I got a GM from the forums, just the source. Compiled it, then started the server. 2-3friends connected, but after that the server crashed. Took me some time to realize it, that I had to create 3folders in "scriptfiles". But its one in a thousand.


Re: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - Konstantinos - 11.10.2013

Quote:
Originally Posted by bluebaron
Посмотреть сообщение
This may also happen if you didn't setup the required folders in "scriptfiles". For instance, if you got the PWN/AMX from the forum, without getting the whole server files. But yet again, its 1 in a 1000. It isn't common, but its just a wild guess.

I got a GM from the forums, just the source. Compiled it, then started the server. 2-3friends connected, but after that the server crashed. Took me some time to realize it, that I had to create 3folders in "scriptfiles". But its one in a thousand.
The reason a server crashed is not always the same. In his case, he knows the reason: Run time error 4: "Array index out of bounds".

pawn Код:
new
    sth[ 5 ]
;
// Array size of 5 can get values 0-4.

sth[ 0 ] = 0; // correct
sth[ 1 ] = 1; // correct
sth[ 2 ] = 2; // correct
sth[ 3 ] = 3; // correct
sth[ 4 ] = 4; // correct
sth[ 5 ] = 5; // Run time error 4: "Array index out of bounds"



Re: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - flrp - 13.10.2013

i managed to fix that othertimer2 and all the bugs detected by crashdetect, however the problem remains.. I have created a folder called SBizzes wich was missing, i will check if it is related to that and ill post results.


Re: MAJOR BUG - Server crashes when the 2nd or 3rd or 4th player connects - help asap - flrp - 13.10.2013

It is still crashing, the server doesn't totally closes, it just freezes, nobody can connect and who'ever was connected before cant do anything but also doesnt get disconnected, and even if they /q they still appear on the player list as online and no errors appear from crashdetect logs... If anyone could give me a contact i'd be thankfull.