OnPlayerDisconnect [REP++++++++]
#1

Please this is very improtant for me.....
First here is the codes that under onplayerdisconnect
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME], PlayerIP[16];
    
GetPlayerName(playeridnamesizeof(name));
    
GetPlayerIp(playeridPlayerIPsizeof(PlayerIP));
    if(
reason == 0)
     {
        
format(stringsizeof(string), "%s left the server (Timeout)"name);
        
SendToPlayers(COLOR_GRAYstring);
        
format(stringsizeof(string), "%s left the server (Timeout) (%s)"namePlayerIP);
        
SendToAdmins(COLOR_GRAYstring);
    }
    else if(
reason == 1)
     {
        
format(stringsizeof(string), "%s left the server"name);
        
SendToPlayers(COLOR_GRAYstring);
         
format(stringsizeof(string), "%s left the server (%s)"name,PlayerIP);
        
SendToAdmins(COLOR_GRAYstring);
    }
    else
     {
        
format(stringsizeof(string), "%s left the server (Kicked)"name);
        
SendToPlayers(COLOR_GRAYstring);
         
format(stringsizeof(string), "%s left the server (Kicked) (%s)"namePlayerIP);
        
SendToAdmins(COLOR_GRAYstring);
    }
    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] [debugRun 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] [debugAMX 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] [partNezoo has left the server (0:1
This prevent me from saving any player data
Please Help
REP+++++
Reply
#2

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;
}
Reply
#3

Nooooooooothing Pleaaase !!
Reply
#4

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 )
Reply
#5

The problem was on the health one because i didn't make a float with the health Thank You All
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)