OnPlayerDisconnect [REP++++++++] -
nezo2001 - 21.01.2015
Please this is very improtant for me.....
First here is the codes that under onplayerdisconnect
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME], PlayerIP[16];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
if(reason == 0)
{
format(string, sizeof(string), "%s left the server (Timeout)", name);
SendToPlayers(COLOR_GRAY, string);
format(string, sizeof(string), "%s left the server (Timeout) (%s)", name, PlayerIP);
SendToAdmins(COLOR_GRAY, string);
}
else if(reason == 1)
{
format(string, sizeof(string), "%s left the server", name);
SendToPlayers(COLOR_GRAY, string);
format(string, sizeof(string), "%s left the server (%s)", name,PlayerIP);
SendToAdmins(COLOR_GRAY, string);
}
else
{
format(string, sizeof(string), "%s left the server (Kicked)", name);
SendToPlayers(COLOR_GRAY, string);
format(string, sizeof(string), "%s left the server (Kicked) (%s)", name, PlayerIP);
SendToAdmins(COLOR_GRAY, string);
}
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_WriteInt(File,"Ban",PlayerInfo[playerid][pBan]);
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Police",PlayerInfo[playerid][pPolice]);
INI_WriteInt(File,"Freeze",PlayerInfo[playerid][pFreeze]);
INI_WriteInt(File,"Gang",PlayerInfo[playerid][pGang]);
INI_WriteInt(File,"Color", GetPlayerColor(playerid));
INI_WriteInt(File,"Armour", GetPlayerArmour(playerid));
INI_WriteInt(File,"Health", GetPlayerHealth(playerid));
INI_WriteInt(File, "Horseshoes", PlayerInfo[playerid][pHorseshoes]);
INI_WriteInt(File,"Ammo", GetPlayerAmmo(playerid));
INI_Close(File);
LoggedIn[playerid] = false;
return 1;
}
btw SendToAdmin is a stock made by us
And when the player disconnect from the server it apear at the console
PHP код:
[14:19:28] [debug] Run time error 4: "Array index out of bounds"
[14:19:28] [debug] Accessing element at index 1286240 past array upper bound 1
[14:19:28] [debug] AMX backtrace:
[14:19:28] [debug] #0 0001a38c in ?? (1286240) from FM.amx
[14:19:28] [debug] #1 0002230c in public Itter_OnPlayerDisconnect (0, 1) from FM.amx
[14:19:28] [debug] #2 native CallLocalFunction () from samp-server.exe
[14:19:28] [debug] #3 0001d990 in public S@@_OnPlayerDisconnect (0, 1, 33554432) from FM.amx
[14:19:28] [debug] #4 native CallLocalFunction () from samp-server.exe
[14:19:28] [debug] #5 0000d520 in ?? (0, 1) from FM.amx
[14:19:28] [debug] #6 000003d8 in public OnPlayerDisconnect (0, 1) from FM.amx
[14:19:28] [part] Nezoo has left the server (0:1)
This prevent me from saving any player data
![Sad](images/smilies/sad.gif)
Please Help
REP+++++
Respuesta: OnPlayerDisconnect [REP++++++++] -
JuanStone - 21.01.2015
Did not find any error, but try as well, eh fact your code from 0 and it seems that it should operate.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new name[24], ip[16], g_string[70];
GetPlayerIp(playerid, ip, 16);
GetPlayerName(playerid, name, 24);
switch(reason)
{
case 0:
{
format(g_string, sizeof(g_string), "%s left the server (Timeout)", name);
SendToPlayers(COLOR_GRAY, g_string);
format(g_string, sizeof(g_string), "%s left the server (Timeout) (%s)", name, ip);
SendToAdmins(COLOR_GRAY, g_string);
}
case 1:
{
format(g_string, sizeof(g_string), "%s left the server", name);
SendToPlayers(COLOR_GRAY, g_string);
format(g_string, sizeof(g_string), "%s left the server (%s)", name, ip);
SendToAdmins(COLOR_GRAY, g_string);
}
case 2:
{
format(string, sizeof(g_string), "%s left the server (Kicked)", name);
SendToPlayers(COLOR_GRAY, g_string);
format(string, sizeof(g_string), "%s left the server (Kicked) (%s)", name, ip);
SendToAdmins(COLOR_GRAY, g_string);
}
}
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File, "Cash", GetPlayerMoney(playerid));
INI_WriteInt(File, "Admin", PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File, "Kills", PlayerInfo[playerid][pKills]);
INI_WriteInt(File, "Deaths", PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File, "Skin", GetPlayerSkin(playerid));
INI_WriteInt(File, "Ban", PlayerInfo[playerid][pBan]);
INI_WriteInt(File, "Score", GetPlayerScore(playerid));
INI_WriteInt(File, "Police", PlayerInfo[playerid][pPolice]);
INI_WriteInt(File, "Freeze", PlayerInfo[playerid][pFreeze]);
INI_WriteInt(File, "Gang", PlayerInfo[playerid][pGang]);
INI_WriteInt(File, "Color", GetPlayerColor(playerid));
INI_WriteInt(File, "Armour", GetPlayerArmour(playerid));
INI_WriteInt(File, "Health", GetPlayerHealth(playerid));
INI_WriteInt(File, "Horseshoes", PlayerInfo[playerid][pHorseshoes]);
INI_WriteInt(File, "Ammo", GetPlayerAmmo(playerid));
INI_Close(File);
LoggedIn[playerid] = false;
return true;
}
Re: OnPlayerDisconnect [REP++++++++] -
nezo2001 - 21.01.2015
Nooooooooothing Pleaaase !!
Re: OnPlayerDisconnect [REP++++++++] -
PT - 21.01.2015
here: string[24+MAX_PLAYER_NAME]
change for string[30+MAX_PLAYER_NAME]
This "%s left the server (Timeout) (%s)" have more than just 24 ( maybe is this the problem )
Re: OnPlayerDisconnect [REP++++++++] -
nezo2001 - 21.01.2015
The problem was on the health one because i didn't make a float with the health Thank You All