03.06.2020, 07:31
Quote:
Are you resetting the PlayerInfo array when the player disconnects? If so, make sure to do the duel check before you reset it, otherwise I assume you set the value to -1 before you actually do your check, so "id" will always be -1 which isn't a valid player ID.
You also have a typo in your parameters, while it's unrelated to your problem, you gotta figure it out. |
Quote:
Since arrays start from 0, -1 looks like an arbitrary value you give to it.
Post OnPlayerDisconnect entirely, maybe we can help. |
Quote:
PHP Code:
PHP Code:
|
PHP Code:
public OnPlayerDisconnect(playerid, reason)
{
if(gTeam[playerid][TEAMATT] == 1)
{
CountAtt --;
}
if(gTeam[playerid][TEAMDEF] == 1)
{
CountDef --;
}
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] ++;
}
if(PlayerInfo[playerid][Inviter] == 1)
{
new id = PlayerInfo[playerid][Inviter], str[124];
PlayerInfo[id][Invited] = 0;
KillTimer(InviteTimer[id]);
format(str, sizeof(str), "%s disconnected in the mid of the invite. The invite is cancelled.", GetName(playerid));
SendClientMessage(id, CDUEL, str);
}
if(PlayerInfo[playerid][Invited] == 1)
{
new id = PlayerInfo[playerid][Invited], str[124];
PlayerInfo[id][Inviter] = 0;
KillTimer(InviteTimer[id]);
format(str, sizeof(str), "%s disconnected in the mid of the invite. The invite is cancelled.", GetName(playerid));
SendClientMessage(id, CDUEL, str);
}
if(SniperGame[playerid] == 1)
{
new str[124];
countsniper --;
format(str, sizeof(str), "%s disconnected in the mid of sniper game. (%d players).", GetName(playerid), countsniper);
SendClientMessageToAll(-1, str);
}
Saving(playerid);
PlayerInfo[playerid][Logged] = 0;
PlayerInfo[playerid][pDeaths] = 0;
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][Invisible] = 0;
PlayerInfo[playerid][God] = 0;
PlayerInfo[playerid][PMs] = 0;
PlayerInfo[playerid][Muted] = 0;
PlayerInfo[playerid][Admin] = 0;
PlayerInfo[playerid][Skin] = 0;
PlayerInfo[playerid][ATT] = 0;
PlayerInfo[playerid][DEF] = 0;
PlayerInfo[playerid][DMG] = 0;
PlayerInfo[playerid][TotalDMG] = 0;
PlayerInfo[playerid][FPSCheck] = 0;
PlayerInfo[playerid][FPSKick] = 0;
PlayerInfo[playerid][MsKick] = 0;
PlayerInfo[playerid][MsCheck] = 0;
PlayerInfo[playerid][NetCheck] = 0;
PlayerInfo[playerid][RestartSpawn] = 0;
PlayerInfo[playerid][WinRounds] = 0;
PlayerInfo[playerid][LoseRounds] = 0;
PlayerInfo[playerid][Hora] = 0;
PlayerInfo[playerid][Clima] = 0;
PlayerInfo[playerid][Warns] = 0;
PlayerInfo[playerid][Kicks] = 0;
PlayerInfo[playerid][Maker] = -1;
PlayerInfo[playerid][Opponent] = -1;
PlayerInfo[playerid][inDuel] = 0;
PlayerInfo[playerid][DuelMap] = 0;
PlayerInfo[playerid][DuelPack] = 0;
PlayerInfo[playerid][DuelArmour] = 0;
PlayerInfo[playerid][WeapDuel] = 0;
PlayerInfo[playerid][OnWeap] = 0;
PlayerInfo[playerid][Inviter] = 0;
PlayerInfo[playerid][Invited] = 0;
PlayerInfo[playerid][Duelingto] = -1;
PlayerInfo[playerid][WinDuels] = 0;
PlayerInfo[playerid][LoseDuels] = 0;
PlayerInfo[playerid][Duelos] = 1;
PlayerInfo[playerid][Duty] = 1;
gTeam[playerid][TEAMATT] = 0;
gTeam[playerid][TEAMDEF] = 0;
Streaks[playerid] = 0;
Voted[playerid] = 0;
LastPm[playerid] = -1;
onspec[playerid] = -1;
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
TextDrawHideForPlayer(playerid, TextdrawLogo1);
TextDrawHideForPlayer(playerid, Textdraw2);
TextDrawHideForPlayer(playerid, TextdrawDMG[playerid]);
return 1;
}