30.10.2012, 21:13
When ANY player joins the server, this appears:
This is a big part of the OnPlayerStateChange:
and hope someone helps and thanks
pawn Код:
[debug] Run time error 4: "Array index out of bounds"
[debug] Accessing element at index 999 past array upper bound 500
[debug] AMX backtrace:
[debug] #0 000661e8 in public OnPlayerStateChange () from EG-RP.amx
pawn Код:
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, "* You are now logged off the 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), "* You are now off duty and earned $%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~The ride cost~n~~r~$%d",TransportCost[playerid]);
GameTextForPlayer(playerid, string, 5000, 3);
format(string, sizeof(string), "~w~Passenger left the taxi.~n~~g~Earned $%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;
}