OnPlayerDisconect help.
#1

I need help with OnPlayerDisconect. Look what i have:

Quote:

public OnPlayerDisconnect(playerid, reason)
{
new playername[MAX_PLAYER_NAME];

GetPlayerName(playerid, playername, sizeof(playername));
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);

//Save temp info for timeouts/crashes
GetPlayerName(playerid, playername, sizeof(playername));
format(savedNames[savePos], MAX_PLAYER_NAME, "%s",playername);

savedInfo[savePos][0] = bounty[playerid];
savedInfo[savePos][1] = 0;


for(new i = 0; i < MAX_WEAPONS; i++)
savedWeapons[savePos][i]=playerWeapons[playerid][i];
//
savePos++;
if(savePos >= MAX_SAVE)
savePos = 0;
bounty[playerid] = 0;
MiniAntiSpamCount[playerid] = 0;

for(new i = 0; i < MAX_WEAPONS;i++) {
playerWeapons[playerid][i]=0;
}

SetPlayerColor( playerid, COLOR_INACTIVE );
}
}

I need to put this one in it:

Quote:

new string[85],pname[24];
switch (reason)
{
case 0:
{
GetPlayerName(playerid,pname,24);
format(string,sizeof(string), "* %s left the server. (Timeout) (ID:%d).",pname,playerid);
SendClientMessageToAll(COLOR_DIS_RED,string);
}
case 1:
{
GetPlayerName(playerid,pname,24);
format(string,sizeof(string), "* %s left the server. (Leaving) (ID:%d).",pname,playerid);
SendClientMessageToAll(COLOR_DIS_RED,string);
}
case 2:
{
GetPlayerName(playerid,pname,24);
format(string,sizeof(string), "* %s left the server. (Kicked) (ID:%d).",pname,playerid);
SendClientMessageToAll(COLOR_DIS_RED,string);
}
}
return 1;
}

But! when i put this i have several errors, please type how to put it corectly...

Thanks.
Reply
#2

C'MON! please i need help!
Reply
#3

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  new playername[MAX_PLAYER_NAME];

  GetPlayerName(playerid, playername, sizeof(playername));
  SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);

    //Save temp info for timeouts/crashes
    GetPlayerName(playerid, playername, sizeof(playername));
    format(savedNames[savePos], MAX_PLAYER_NAME, "%s",playername);

    savedInfo[savePos][0] = bounty[playerid];
    savedInfo[savePos][1] = 0;


    for(new i = 0; i < MAX_WEAPONS; i++)
        savedWeapons[savePos][i]=playerWeapons[playerid][i];
    //
    savePos++;
    if(savePos >= MAX_SAVE)
    savePos = 0;
    bounty[playerid] = 0;
    MiniAntiSpamCount[playerid] = 0;

    for(new i = 0; i < MAX_WEAPONS;i++) {
        playerWeapons[playerid][i]=0;
    }

    SetPlayerColor( playerid, COLOR_INACTIVE );
    new string[85],pname[24];
    switch (reason)
    {
        case 0:
        {
                GetPlayerName(playerid,pname,24);
                format(string,sizeof(string), "* %s left the server. (Timeout) (ID:%d).",pname,playerid);
                SendClientMessageToAll(COLOR_DIS_RED,string);
        }
        case 1:
  {
    GetPlayerName(playerid,pname,24);
    format(string,sizeof(string), "* %s left the server. (Leaving) (ID:%d).",pname,playerid);
    SendClientMessageToAll(COLOR_DIS_RED,string);
  }
  case 2:
  {
    GetPlayerName(playerid,pname,24);
    format(string,sizeof(string), "* %s left the server. (Kicked) (ID:%d).",pname,playerid);
    SendClientMessageToAll(COLOR_DIS_RED,string);
  }
}
Reply
#4

Hamptonin,

I demand you, pawno you utilise encoding. ( [pawn] [/ pawn] )
Reply
#5

Quote:
Originally Posted by Hamptonin
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  new playername[MAX_PLAYER_NAME];

  GetPlayerName(playerid, playername, sizeof(playername));
  SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);

    //Save temp info for timeouts/crashes
    GetPlayerName(playerid, playername, sizeof(playername));
    format(savedNames[savePos], MAX_PLAYER_NAME, "%s",playername);

    savedInfo[savePos][0] = bounty[playerid];
    savedInfo[savePos][1] = 0;


    for(new i = 0; i < MAX_WEAPONS; i++)
        savedWeapons[savePos][i]=playerWeapons[playerid][i];
    //
    savePos++;
    if(savePos >= MAX_SAVE)
    savePos = 0;
    bounty[playerid] = 0;
    MiniAntiSpamCount[playerid] = 0;

    for(new i = 0; i < MAX_WEAPONS;i++) {
        playerWeapons[playerid][i]=0;
    }

    SetPlayerColor( playerid, COLOR_INACTIVE );
    new string[85],pname[24];
    switch (reason)
    {
        case 0:
        {
                GetPlayerName(playerid,pname,24);
                format(string,sizeof(string), "* %s left the server. (Timeout) (ID:%d).",pname,playerid);
                SendClientMessageToAll(COLOR_DIS_RED,string);
        }
        case 1:
  {
    GetPlayerName(playerid,pname,24);
    format(string,sizeof(string), "* %s left the server. (Leaving) (ID:%d).",pname,playerid);
    SendClientMessageToAll(COLOR_DIS_RED,string);
  }
  case 2:
  {
    GetPlayerName(playerid,pname,24);
    format(string,sizeof(string), "* %s left the server. (Kicked) (ID:%d).",pname,playerid);
    SendClientMessageToAll(COLOR_DIS_RED,string);
  }
}
1. It won't work, gives me alot of errors.
2. In standart script when player left the server it shows in deathchat , not in mainchat, i need to destroy deathchat and to put mainchat disconect messages.
Reply
#6

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerName(playerid, savedNames[savePos], MAX_PLAYER_NAME);

    savedInfo[savePos][0] = bounty[playerid];
    savedInfo[savePos][1] = 0;

    for(new i; i < MAX_WEAPONS; i++)
        playerWeapons[playerid][i] = 0,
        savedWeapons[savePos][i] = playerWeapons[playerid][i];

    new Reasons[][] = { "Timeout", "Leaving", "Kicked" };
    format(string,sizeof(string), "* %s left the server. (%s) (ID:%d).", savedNames[savePos], Reasons[reason], playerid);
    SendClientMessageToAll(COLOR_DIS_RED, string);

    if(++savePos >= MAX_SAVE) savePos = 0;
    MiniAntiSpamCount[playerid] = 0;
    bounty[playerid] = 0;
    return true;
}
Reply
#7

Quote:
Originally Posted by ♣ ⓐⓢⓢ
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerName(playerid, savedNames[savePos], MAX_PLAYER_NAME);

    savedInfo[savePos][0] = bounty[playerid];
    savedInfo[savePos][1] = 0;

    for(new i; i < MAX_WEAPONS; i++)
        playerWeapons[playerid][i] = 0,
        savedWeapons[savePos][i] = playerWeapons[playerid][i];

    new Reasons[][] = { "Timeout", "Leaving", "Kicked" };
    format(string,sizeof(string), "* %s left the server. (%s) (ID:%d).", savedNames[savePos], Reasons[reason], playerid);
    SendClientMessageToAll(COLOR_DIS_RED, string);

    if(++savePos >= MAX_SAVE) savePos = 0;
    MiniAntiSpamCount[playerid] = 0;
    bounty[playerid] = 0;
    return true;
}
E:\Games\GTA San Andreas\Mods, Cheats ,Dedicated servers\SA-MP Server\gamemodes\lsu.pwn(128 : error 017: undefined symbol "string"
E:\Games\GTA San Andreas\Mods, Cheats ,Dedicated servers\SA-MP Server\gamemodes\lsu.pwn(128 : error 017: undefined symbol "string"
E:\Games\GTA San Andreas\Mods, Cheats ,Dedicated servers\SA-MP Server\gamemodes\lsu.pwn(128 : error 029: invalid expression, assumed zero
E:\Games\GTA San Andreas\Mods, Cheats ,Dedicated servers\SA-MP Server\gamemodes\lsu.pwn(128 : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

is it rly so hard to add new string[64];

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerName(playerid, savedNames[savePos], MAX_PLAYER_NAME);

    savedInfo[savePos][0] = bounty[playerid];
    savedInfo[savePos][1] = 0;

    for(new i; i < MAX_WEAPONS; i++)
        playerWeapons[playerid][i] = 0,
        savedWeapons[savePos][i] = playerWeapons[playerid][i];

    new Reasons[][] = { "Timeout", "Leaving", "Kicked" }, string[64];
    format(string,sizeof(string), "* %s left the server. (%s) (ID:%d).", savedNames[savePos], Reasons[reason], playerid);
    SendClientMessageToAll(COLOR_DIS_RED, string);

    if(++savePos >= MAX_SAVE) savePos = 0;
    MiniAntiSpamCount[playerid] = 0;
    bounty[playerid] = 0;
    return true;
}
Reply
#9

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)