10.03.2012, 16:00
My spectate functions are causing troubles for me, i really dont know why so i ask here.
Here is the affected functions:
OnPlayerKeyStateChange:
At first i wanted to make theese functions with y_iterate, but lack of time made me take theese from luxadmin.
After 1 day or more of uptime, crashdetect plugin goes crazy and gives me this:
This causes big problem to the server since the crashdetect file grows insanely HUGE. Every single error is with theese functions and they are written 100's of times to crashdetect log every second this problem occur.
Is there anything to do besides completely disable this?
Thanks in advance to those who are able to help me find a solution to this.
Here is the affected functions:
pawn Код:
stock StartSpectate(playerid, specid)
{
foreach(Player, x)
{
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] == playerid) AdvanceSpectate(x);
}
SetPlayerInterior(playerid,GetPlayerInterior(specid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(specid));
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(specid))
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(specid));
gSpectateID[playerid] = specid;
gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
}
else
{
PlayerSpectatePlayer(playerid, specid);
gSpectateID[playerid] = specid;
gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
}
new string[40];
if(PVar[playerid][pLevel] >0)
{
format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~w~%s - ID:%d~n~< Sprint - Jump >", pName(specid), specid);
GameTextForPlayer(playerid,string,9999999,3);
}
return 1;
}
pawn Код:
stock AdvanceSpectate(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING && gSpectateID[playerid] != INVALID_PLAYER_ID)
{
for(new x=gSpectateID[playerid]+1; x<=MAX_PLAYERS; x++)
{
if(x == MAX_PLAYERS) x = 0;
if(IsPlayerConnected(x) && x != playerid)
{
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] != INVALID_PLAYER_ID || (GetPlayerState(x) != 1 && GetPlayerState(x) != 2 && GetPlayerState(x) != 3))
{
continue;
}
else
{
StartSpectate(playerid, x); // Line 15736
break;
}
}
}
}
return 1;
}
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING && gSpectateID[playerid] != INVALID_PLAYER_ID)
{
if(newkeys == KEY_JUMP)
AdvanceSpectate(playerid); // Line 13919
else if(newkeys == KEY_SPRINT)
ReverseSpectate(playerid);
}
After 1 day or more of uptime, crashdetect plugin goes crazy and gives me this:
pawn Код:
[14:58:01]: File 'D:\Documents and Settings\***/Skrivebord\Dev\gamemodes\MySQL_v6.0.0.1.pwn', line 13919
[14:58:01]: AdvanceSpectate(playerid=12)
[14:58:01]: File 'D:\Documents and Settings\***\Skrivebord\Dev\gamemodes\MySQL_v6.0.0.1.pwn'
[14:58:01]: public OnPlayerKeyStateChange(playerid=12, newkeys=9, oldkeys=9)
[14:58:01]: Script[gamemodes/MySQL_v6.0.0.1.amx]: In file 'D:\Documents and Settings\***\Skrivebord\Dev\gamemodes\MySQL_v6.0.0.1.pwn' at line 15628:
[14:58:01]: Script[gamemodes/MySQL_v6.0.0.1.amx]: Run time error 3: "Stack/heap collision (insufficient stack size)"
[14:58:01]: Additional information:
[14:58:01]: Stack index (STK) is 0x396784, heap index (HEA) is 0x396748
[14:58:01]: Call stack (most recent call first):
[14:58:02]: File 'D:\Documents and Settings\***\Skrivebord\Dev\gamemodes\MySQL_v6.0.0.1.pwn', line 15736
[14:58:02]: StartSpectate(playerid=12, specid=9)
Is there anything to do besides completely disable this?
Thanks in advance to those who are able to help me find a solution to this.