02.06.2020, 08:51
Hello! I found this recently:
This happens if a player disconnects in the middle of a duel. Line:
OnPlayerDisconnect:
The message is sent correctly to the other player and runs well the code but i founded this in the log
PHP Code:
[18:09:34] [debug] Run time error 4: "Array index out of bounds"
[18:09:34] [debug] Attempted to read/write array element at negative index -1
[18:09:34] [debug] AMX backtrace:
[18:09:34] [debug] #0 00042230 in public Iter_OnPlayerDisconnect (playerid=1, reason=0) at C:\Users\ert\OneDrive\Desktop\game\gamemodes\game.pwn:890
[18:09:34] [debug] #1 native CallLocalFunction () in server
[18:09:34] [debug] #2 00038a38 in public SSCANF_OnPlayerDisconnect (playerid=1, reason=0) at C:\Users\ert\OneDrive\Desktop\game\pawno\include\foreach.inc:833
[18:09:34] [debug] #3 00031860 in public WC_OnPlayerDisconnect (playerid=1, reason=0) at C:\Users\ert\OneDrive\Desktop\game\pawno\include\sscanf2.inc:266
[18:09:34] [debug] #4 00014b98 in public FIXES_OnPlayerDisconnect (1, 0) at C:\Users\ert\OneDrive\Desktop\game\pawno\include\weapon-config.inc:2243
[18:09:34] [debug] #5 00004960 in public OnPlayerDisconnect (playerid=1, reason=0) at C:\Users\ert\OneDrive\Desktop\game\pawno\include\fixes.inc:6522
PHP Code:
format(str, sizeof(str), "%s abandoned the server in the mid of a duel vs %s. %s is the winner. [%.0f health and %.0f armour]", GetName(playerid), GetName(id), GetName(id), health, armour);
PHP Code:
public OnPlayerDisconnect(playerid, reason)
{
//another checks...
if(PlayerInfo[playerid][inDuel] == 1)
{
new id = PlayerInfo[playerid][Duelingto], Float:health, Float:armour, str[124];
GetPlayerHealth(id, health);
GetPlayerArmour(id, armour);
ResetPlayerWeapons(id);
SetPlayerVirtualWorld(id, 0);
SetPlayerInterior(id, 0);
SetPlayerHealth(id, 100);
SpawnPlayer(id);
format(str, sizeof(str), "%s abandoned the server in the mid of a duel vs %s. %s is the winner. [%.0f health and %.0f armour]", GetName(playerid), GetName(id), GetName(id), health, armour);
SendClientMessageToAll(CDUEL, str);
PlayerInfo[id][Duelingto] = -1;
PlayerInfo[id][Maker] = -1;
PlayerInfo[id][Opponent] = -1;
PlayerInfo[playerid][LoseDuels] ++;
PlayerInfo[id][WinDuels] ++;
}
// another checks etc
return 1;
}