20.01.2019, 11:05
Hello, i am facing problem in my script when player disconnect (/q or from menu)
Error
OnPlayerDisconnect
Error
PHP Code:
[12:37:32] [debug] Run time error 4: "Array index out of bounds"
[12:37:32] [debug] Attempted to read/write array element at negative index -1
[12:37:32] [debug] AMX backtrace:
[12:37:32] [debug] #0 000137a0 in public CB_OnPlayerDisconnect (0, 1) from yo.amx
[12:37:32] [debug] #1 00007df0 in public SSCANF_OnPlayerDisconnect (0, 1) from yo.amx
[12:37:32] [debug] #2 00000d70 in public OnPlayerDisconnect (0, 1) from yo.amx
PHP Code:
public OnPlayerDisconnect(playerid, reason)
{
PlayerWait[playerid]=0;
new m[512], Float:tx,Float:ty,Float:tz;
if(PlayerInfo[playerid][pInjured]==1){
PlayerInfo[playerid][pInjured]=2;
SavePlayer(playerid);
}
switch(reason)
{
case 0: format(m, sizeof(m), "* %s left the server. (Timeout/Crashed)", PlayerICName(playerid));
case 1: format(m, sizeof(m), "* %s left the server. (Leaving)", PlayerICName(playerid));
case 2: format(m, sizeof(m), "* %s left the server. (Kicked/Banned)", PlayerICName(playerid));
}
for(new i=0; i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i)){
if(IsPlayerInRangeOfPoint(i, 30, tx,ty,tz)){
SendClientMessage(i, COLOR_GEAR_LIGHTYELLOW, m);
}
}
}
PlayerInfo[playerid][pCash]=0;
CellPhone[playerid][InCall] = -1;
CellPhone[CellPhone[playerid][CalledBy]][InCall]= -1;
SendClientMessage(CellPhone[playerid][CalledBy], COLOR_GREY, "Line went dead...");
CellPhone[CellPhone[playerid][CalledBy]][CalledBy] = -1;
CellPhone[playerid][PhoneRinging] = -1;
CellPhone[playerid][CalledTo] = -1;
CellPhone[playerid][CalledBy] = -1;
PlayerInfo[playerid][pCheckpoint] = 0;
GotPackages[playerid] = 0;
PlayerInfo[playerid][pInjured]=0;
phoneoff[playerid] = 0;
reporttimer[playerid] = 0;
reporttimer2[playerid] = 0;
// Variables reset are necessary(don't touch pls).
SavePlayer(playerid);
KillTimer(SavingTimer);
return 1;
}