SA-MP Forums Archive
What is wrong with OnPlayerDisconnect? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What is wrong with OnPlayerDisconnect? (/showthread.php?tid=372369)



What is wrong with OnPlayerDisconnect? - Connection - 26.08.2012

Heey guys,

I have a little question. Did anyone know what is wrong with this?:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pName[90],string[256];
    GetPlayerName(playerid,pName,sizeof(pName));
    switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Crashed)", pName);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pName);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pName);
        }
        SendClientMessageToAll(COLOR_GREY,string);
    }
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"AdminLvl",PlayerInfo[playerid][pAdminLvl]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}
When I didnt make the had left the server function. My pawn will it compiled. But when I add it it wont be compiled..

Can anyone help me?


Re: What is wrong with OnPlayerDisconnect? - JaKe Elite - 26.08.2012

pawn Код:
switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Crashed)", pName);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pName);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pName);
        SendClientMessageToAll(COLOR_GREY,string);
    }



Re: What is wrong with OnPlayerDisconnect? - Universal - 26.08.2012

The above example is wrong.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pName[MAX_PLAYER_NAME], string[32 + MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));

    switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Crashed)", pName);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pName);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pName);
    }

    SendClientMessageToAll(COLOR_GREY,string);

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"AdminLvl",PlayerInfo[playerid][pAdminLvl]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);

    return 1;
}
32 + MAX_PLAYER_NAME(24) = 56, you used 256 cells, where 56 needed. Also with the pName, use MAX_PLAYER_NAME instead of 90.


Re: What is wrong with OnPlayerDisconnect? - Connection - 26.08.2012

It works! thank you

[EDIT] I got this errors:

pawn Код:
D:\GTA San Andreas\SAMP\pawno\test.pwn(80) : error 001: expected token: "-string end-", but found "-identifier-"
D:\GTA San Andreas\SAMP\pawno\test.pwn(80) : warning 215: expression has no effect
D:\GTA San Andreas\SAMP\pawno\test.pwn(80) : error 001: expected token: ";", but found "-string-"
D:\GTA San Andreas\SAMP\pawno\test.pwn(80) : warning 215: expression has no effect
D:\GTA San Andreas\SAMP\pawno\test.pwn(80) : error 001: expected token: "-string end-", but found "-identifier-"
D:\GTA San Andreas\SAMP\pawno\test.pwn(80) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



Re: What is wrong with OnPlayerDisconnect? - [MM]RoXoR[FS] - 26.08.2012

Show line 80


Re: What is wrong with OnPlayerDisconnect? - Connection - 26.08.2012

^Above. If I use that it wont compiled again


Re: What is wrong with OnPlayerDisconnect? - cessil - 26.08.2012

your brackets are messed up


Re: What is wrong with OnPlayerDisconnect? - Connection - 26.08.2012

This is line 80:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_LIME"Welcome back to the server",""COL_WHITE"Welcome back,\n"COL_WHITE"Type your password below to login.","Login","Quit");