GMX Question
#1

I'm just wondering, is OnPlayerDisconnect used or called whenever SendRconCommand("gmx"); is sent? Because whenever I use my "/gmx" command, it would restart the server although it doesn't save the players' stats and when they spawn - they just die and have the CJ skin as default.

Here's my code:
pawn Код:
command(gmx, playerid, params[])
{
    if(IsConnected(playerid))
    {
        if(Player[playerid][pAdmin] >= 5)
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    SavePlayer(i);
                    TogglePlayerSpectating(i, true);
                    DisablePlayerCheckpoint(i);
                    SetPlayerInterior(i, 0);
                    SetPlayerVirtualWorld(i, 0);
                    SetPlayerCameraPos(i, 1460.0, -1324.0, 287.2);
                    SetPlayerCameraLookAt(i, 1374.5, -1291.1, 239.0);
                }
            }
            GameTextForAll("~w~Server Restarting...", 10000, 5);
            SetTimer("ServerRestart", 5000, 0);
        }
    }
    return 1;
}

public ServerRestart()
{
    SendRconCommand("gmx");
    return 1;
}
Reply
#2

http://forum.sa-mp.com/showpost.php?...99&postcount=6
Reply
#3

can u show me SavePlayer(i);
Reply
#4

pawn Код:
public SavePlayer(playerid)
{
    new query[256], level, skin, cash, Float:lastpos[4], interior, world, Float:hp, Float:ap;
    level = GetPlayerScore(playerid);
    skin = GetPlayerSkin(playerid);
    cash = GetPlayerMoney(playerid);
    GetPlayerPos(playerid, lastpos[0], lastpos[1], lastpos[2]);
    GetPlayerFacingAngle(playerid, lastpos[3]);
    interior = GetPlayerInterior(playerid);
    world = GetPlayerVirtualWorld(playerid);
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, ap);
   
    format(query, sizeof(query), "UPDATE accounts SET username='%s', level='%d', adminlevel='%d', skin='%d', cash='%d', posx='%f', posy='%f', posz='%f', posr='%f' WHERE username='%s'",
        Player[playerid][pName], level, Player[playerid][pAdmin], skin, cash, lastpos[0], lastpos[1], lastpos[2], lastpos[3], GetName(playerid));
    mysql_query(query);
   
    format(query, sizeof(query), "UPDATE accounts SET gender='%d', origin='%s', health='%f', armor='%f', firstspawn='%d', interior='%d', world='%d' WHERE username='%s'",
        Player[playerid][pGender], Player[playerid][pOrigin], hp, ap, Player[playerid][pFirstSpawn], interior, world, GetName(playerid));
    mysql_query(query);
    return 1;
}
By the way, I'm using SavePlayer in OnPlayerDisconnect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)