17.05.2016, 14:11
Its your recurrsive function that is causing the problem.
Each time a function is called, some information is pushed onto the stack. Your function calls itself so many times that your stack size increases to such an extent that it collides with the heap. The heap and stack share the same memory in your RAM and they run in opposite directions.
The problem is that your SpectateNext is an infinite loop.
The issue is here
and
You set it to -1, you wont find anybody to spectate next. Your code (given below)
calls SpectateNext again.... you set it to -1 and then call SpectateNext again, this calls SpectateNext again, this again calls SpectateNext again.... this is an infinite loop.
Each time a function is called, some information is pushed onto the stack. Your function calls itself so many times that your stack size increases to such an extent that it collides with the heap. The heap and stack share the same memory in your RAM and they run in opposite directions.
The problem is that your SpectateNext is an infinite loop.
Код:
function SpectateNext(playerid) { new bool:fl; foreach(new i:Player) if(PInfo[i][pInDerby] && i > PInfo[playerid][pSpectateID]) { new tdstring[85]; fl = true; PInfo[playerid][pSpectateID] = i; format(tdstring, sizeof(tdstring), "~<~ ~g~~h~Spectate: ~w~%s ~>~", GetName(PInfo[playerid][pSpectateID])); PlayerTextDrawSetString(playerid, PInfo[playerid][pSpectateTD], tdstring); PlayerSpectateVehicle(playerid, GetPlayerVehicleID(i)); break; } if(!fl) { PInfo[playerid][pSpectateID] = -1; SpectateNext(playerid); } return 1; }
Код:
i > PInfo[playerid][pSpectateID]
Код:
PInfo[playerid][pSpectateID] = -1;
Код:
if(!fl) { PInfo[playerid][pSpectateID] = -1; SpectateNext(playerid); }