[09:56:11] [debug] Run time error 4: "Array index out of bounds" [09:56:11] [debug] Accessing element at index 999 past array upper bound 500 [09:56:11] [debug] Backtrace (most recent call first): [09:56:11] [debug] #0 000702d4 in OnPlayerStateChange () from ggrpboombox.amx
public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate != 2) NOPTrigger[playerid] = 0; if(IsPlayerNPC(playerid)) { if(newstate == PLAYER_STATE_SPECTATING) { TogglePlayerSpectating(playerid, false); } return 1; } if(GettingSpectated[playerid] != 999) { new spectator = GettingSpectated[playerid]; if(!IsPlayerConnected(spectator)) { GettingSpectated[playerid] = 999; Spectate[spectator] = 999; } if(newstate == PLAYER_STATE_DRIVER && PlayerInfo[spectator][pAdmin] >= 2 || newstate == PLAYER_STATE_PASSENGER && PlayerInfo[spectator][pAdmin] >= 2) { TogglePlayerSpectating(spectator, true); new carid = GetPlayerVehicleID( playerid ); PlayerSpectateVehicle( spectator, carid ); SetPVarInt(spectator, "SpecState", newstate); } else if(newstate == PLAYER_STATE_ONFOOT && PlayerInfo[spectator][pAdmin] >= 2) { TogglePlayerSpectating(spectator, true); PlayerSpectatePlayer( spectator, playerid ); SetPlayerInterior( spectator, GetPlayerInterior( playerid ) ); SetPVarInt(spectator, "SpecState", newstate); } } if(newstate == PLAYER_STATE_ONFOOT) { if(Audio_IsClientConnected(playerid)) { Audio_Stop(playerid, stationidp[playerid]); stationidp[playerid] = 0; } new spectator = GettingSpectated[playerid]; if(PlayerInfo[spectator][pAdmin] >= 2) { // Preventing possible buffer overflows with the arrays TogglePlayerSpectating(spectator, true); PlayerSpectatePlayer( spectator, playerid ); SetPlayerInterior( spectator, GetPlayerInterior( playerid ) ); SetPVarInt(spectator, "SpecState", newstate); SetPlayerInterior( spectator, GetPlayerInterior( playerid ) ); SetPlayerVirtualWorld( spectator, GetPlayerVirtualWorld( playerid ) ); } if(oldstate == PLAYER_STATE_DRIVER) { SetPlayerWeaponsEx(playerid); } else if(oldstate == PLAYER_STATE_PASSENGER) SetPlayerWeaponsEx(playerid); if(ConnectedToPC[playerid] == 1337)//mdc { SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Anda keluar dari MDC."); ConnectedToPC[playerid] = 0; } if(TransportDuty[playerid] > 0) { if(TransportDuty[playerid] == 1) { TaxiDrivers -= 1; } else if(TransportDuty[playerid] == 2) { BusDrivers -= 1; } TransportDuty[playerid] = 0; new string[42]; format(string, sizeof(string), "* Anda sekarang berhenti bertugas dan mendapatkan $%d.", TransportMoney[playerid]); SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string); GivePlayerCash(playerid, TransportMoney[playerid]); ConsumingMoney[playerid] = 1; TransportValue[playerid] = 0; TransportMoney[playerid] = 0; SetPlayerColor(playerid, TEAM_HIT_COLOR); TransportTime[playerid] = 0; TransportCost[playerid] = 0; } if(TransportDriver[playerid] < 999) { new string[128]; TransportMoney[TransportDriver[playerid]] += TransportCost[playerid]; format(string, sizeof(string), "~w~Total Argo~n~~r~$%d",TransportCost[playerid]); GameTextForPlayer(playerid, string, 5000, 3); format(string, sizeof(string), "~w~penumpang keluar dari taxi.~n~~g~Mendapatkan $%d",TransportCost[playerid]); GameTextForPlayer(TransportDriver[playerid], string, 5000, 3); GivePlayerCash(playerid, -TransportCost[playerid]); new ip[32], ipex[32]; GetPlayerIp(playerid, ip, sizeof(ip)); GetPlayerIp(TransportDriver[playerid], ipex, sizeof(ipex)); TaxiWarn[playerid][TransportDriver[playerid]] += TransportCost[playerid]; if(TaxiWarn[playerid][TransportDriver[playerid]] >= 10000) { format(string, sizeof(string), "%s (IP:%s) has taxied %s (IP:%s) $%d in this session.", GetPlayerNameEx(playerid), ip, GetPlayerNameEx(TransportDriver[playerid]), ipex, TaxiWarn[playerid][TransportDriver[playerid]]); Log("logs/pay.log", string); ABroadCast(COLOR_YELLOW, string, 2); } TransportTime[TransportDriver[playerid]] = 0; TransportCost[TransportDriver[playerid]] = 0; TransportCost[playerid] = 0; TransportTime[playerid] = 0; TransportDriver[playerid] = 999; } TelePos[playerid][0] = 0.0; TelePos[playerid][1] = 0.0; }
Accessing element at index 999 past array upper bound 500 |
if(GettingSpectated[playerid] != 999)
new spectator = GettingSpectated[playerid];
if(PlayerInfo[spectator][pAdmin] >= 2) {
//This line
if(PlayerInfo[spectator][pAdmin] >= 2) {
//Changes into
if(spectator != 999 && PlayerInfo[spectator][pAdmin] >= 2) {