What is wrong with OnPlayerDisconnect?
#1

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?
Reply
#2

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

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.
Reply
#4

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

Show line 80
Reply
#6

^Above. If I use that it wont compiled again
Reply
#7

your brackets are messed up
Reply
#8

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");
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)