GMX Bug?
#1

I've been through this over and over again, can't seem to make it work. I have a command for admins to restart the server while in-game and it executes the RCON command "gmx" - it restarts fine, but when the player spawns it goes to the 0.0 position with skin ID 0 and continuously dies but all of the other stats were loaded. I'm not sure if it's a bug for 0.3x or if there's another way of doing it since it worked the last time I coded the same thing.

I hope someone could resolve or help me with this. Below is what I have coded. Thanks!

GMX command:
pawn Код:
command(gmrestart, playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(Player[playerid][pAdmin] >= 5)
        {
            OnGMX();
        }
    }
    return 1;
}
OnGMX():
pawn Код:
public OnGMX()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            OnPlayerSave(i);
            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...", 20000, 5);
    SetTimer("OnServerRestart", 10000, 0);
    return 1;
}
OnServerRestart():
pawn Код:
public OnServerRestart()
{
    SendRconCommand("gmx");
    return 1;
}
Reply
#2

remove the timer and put the gmx instead and see if it will work....
Reply
#3

I made a timer to have some time to save, but I'll give it a shot. Thanks!

Edit: Tried it, still doesn't work. Any other way?
Reply
#4

replace OnGMX(); with SetTimer("OnGMX", 1000, false); && ensure ur admin lvl iz 5

edit: or u can try below and call it like this OnGMX();
pawn Код:
stock OnGMX()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            OnPlayerSave(i);
            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...", 20000, 5);
    SetTimer("OnServerRestart", 10000, 0);
    return 1;
}
Reply
#5

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
replace OnGMX(); with SetTimer("OnGMX", 1000, false); && ensure ur admin lvl iz 5

edit: or u can try below and call it like this OnGMX();
pawn Код:
stock OnGMX()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            OnPlayerSave(i);
            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...", 20000, 5);
    SetTimer("OnServerRestart", 10000, 0);
    return 1;
}
As stock doesn't get called when using timer... only public are called if you want to use a timer

try this one

pawn Код:
CMD:gmrestart(playerid, params[])
{
    if(Player[playerid][pAdmin] <  5) return SendClientMessage(playerid, -1,"You're not authorized to use this command");
    GameTextForAll("~w~Server Restarting...", 20000, 5);
    SetTimer("OnServerRestart", 10000, 0);
    return 1;
}

public OnServerRestart()
{
    SendRconCommand("gmx");
    return 1;
}
Reply
#6

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
replace OnGMX(); with SetTimer("OnGMX", 1000, false); && ensure ur admin lvl iz 5
I don't get you. Could you type in the code? From my understanding, that doesn't make any sense at all.

Quote:
Originally Posted by pds2012
Посмотреть сообщение
As stock doesn't get called when using timer... only public are called if you want to use a timer

try this one

pawn Код:
CMD:gmrestart(playerid, params[])
{
    if(Player[playerid][pAdmin] <  5) return SendClientMessage(playerid, -1,"You're not authorized to use this command");
    GameTextForAll("~w~Server Restarting...", 20000, 5);
    SetTimer("OnServerRestart", 10000, 0);
    return 1;
}

public OnServerRestart()
{
    SendRconCommand("gmx");
    return 1;
}
That's what I already have, it only saves player data just before doing the RCON gmx command.
Reply
#7

i never said to call a stock under a timer....... lolz i said u OnGMX(); cant u read....... can u show me OnPlayerSave(playerid) plz..... i think i can solve the skin problem.....
pawn Код:
command(gmrestart, playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(Player[playerid][pAdmin] >= 5)
        {
            SetTimer("OnGMX", 1000,false);
        }
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
i never said to call a stock under a timer....... lolz i said u OnGMX(); cant u read....... can u show me OnPlayerSave(playerid) plz..... i think i can solve the skin problem.....
pawn Код:
command(gmrestart, playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(Player[playerid][pAdmin] >= 5)
        {
            SetTimer("OnGMX", 1000,false);
        }
    }
    return 1;
}
You actually posted "stock OnGMX()" on your reply and the code above would just delay calling OnGMX by a second, so I'm pretty sure that wouldn't solve the problem.

And here's the OnPlayerSave callback although I know that I got it all covered:
pawn Код:
public OnPlayerSave(playerid)
{
    new query[264], level, skin, interior, world, cash, Float:lastpos[4], Float:hp, Float:ap;
    level = GetPlayerScore(playerid);
    skin = GetPlayerSkin(playerid);
    interior = GetPlayerInterior(playerid);
    world = GetPlayerVirtualWorld(playerid);
    cash = GetPlayerMoney(playerid);
    GetPlayerPos(playerid, lastpos[0], lastpos[1], lastpos[2]);
    GetPlayerFacingAngle(playerid, lastpos[3]);
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, ap);
   
    format(query, sizeof(query), "UPDATE accounts SET username='%s', gender='%d', origin='%s', level='%d', adminlevel='%d', skin='%d', interior='%d', world='%d' WHERE username='%s'",
        Player[playerid][pName], Player[playerid][pGender], Player[playerid][pOrigin], level, Player[playerid][pAdmin], skin, interior, world, Player[playerid][pName]);
    mysql_query(query);
   
    format(query, sizeof(query), "UPDATE accounts SET cash='%d', posx='%f', posy='%f', posz='%f', posr='%f', respect='%d', needrespect='%d', playinghours='%d' WHERE username='%s'",
        cash, lastpos[0], lastpos[1], lastpos[2], lastpos[3], Player[playerid][pRespect], Player[playerid][pNeedRespect], Player[playerid][pHours], Player[playerid][pName]);
    mysql_query(query);
   
    format(query, sizeof(query), "UPDATE accounts SET nextlevel='%d', firstspawn='%d', health='%f', armor='%f' WHERE username='%s'",
        Player[playerid][pNextLevel], Player[playerid][pFirstSpawn], hp, ap, Player[playerid][pName]);
    mysql_query(query);
   
    return 1;
}
Reply
#9

pawn Код:
//@ the top
LoggedIn[MAX_PLAYERS];
//under onplayer connect
LoggedIn[playerid] = 0;
//under on player spawn
LoggedIn[playerid] = 1;


public OnPlayerSave(playerid)
{
  if(LoggedIn[playerid] == 1)
  {
    new query[264], level, skin, interior, world, cash, Float:lastpos[4], Float:hp, Float:ap;
    level = GetPlayerScore(playerid);
    skin = GetPlayerSkin(playerid);
    interior = GetPlayerInterior(playerid);
    world = GetPlayerVirtualWorld(playerid);
    cash = GetPlayerMoney(playerid);
    GetPlayerPos(playerid, lastpos[0], lastpos[1], lastpos[2]);
    GetPlayerFacingAngle(playerid, lastpos[3]);
    GetPlayerHealth(playerid, hp);
    GetPlayerArmour(playerid, ap);
   
    format(query, sizeof(query), "UPDATE accounts SET username='%s', gender='%d', origin='%s', level='%d', adminlevel='%d', skin='%d', interior='%d', world='%d' WHERE username='%s'",
        Player[playerid][pName], Player[playerid][pGender], Player[playerid][pOrigin], level, Player[playerid][pAdmin], skin, interior, world, Player[playerid][pName]);
    mysql_query(query);
   
    format(query, sizeof(query), "UPDATE accounts SET cash='%d', posx='%f', posy='%f', posz='%f', posr='%f', respect='%d', needrespect='%d', playinghours='%d' WHERE username='%s'",
        cash, lastpos[0], lastpos[1], lastpos[2], lastpos[3], Player[playerid][pRespect], Player[playerid][pNeedRespect], Player[playerid][pHours], Player[playerid][pName]);
    mysql_query(query);
   
    format(query, sizeof(query), "UPDATE accounts SET nextlevel='%d', firstspawn='%d', health='%f', armor='%f' WHERE username='%s'",
        Player[playerid][pNextLevel], Player[playerid][pFirstSpawn], hp, ap, Player[playerid][pName]);
    mysql_query(query);
   }  
   return 1;
}

public OnGMX()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            OnPlayerSave(i);
            DisablePlayerCheckpoint(i);
            SetPlayerInterior(i, 0);
            SetPlayerVirtualWorld(i, 0);
            SetPlayerCameraPos(i, 1460.0, -1324.0, 287.2);
            SetPlayerCameraLookAt(i, 1374.5, -1291.1, 239.0);
            LoggedIn[i] = 0;
        }
    }
   
    GameTextForAll("~w~Server Restarting...", 20000, 5);
    SetTimer("OnServerRestart", 10000, 0);
    return 1;
}
The Player Values are restarted upon disconnect so i made a variable to save the data only if the spawn has spawn ...... if u have the saving data anywhere else then i suggest u add the variable just like in the command..... NB: like if u under onplayerdisconnect i know players have saving data under that callback..
Reply
#10

That's what I've coded on my previous script and I didn't use it on purpose knowing that it doesn't matter. Weird, I used the same exact variable. But anyway, I'll try it out. Thanks again.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)