SA-MP Forums Archive
Can somebody make me a gmx command - 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: Can somebody make me a gmx command (/showthread.php?tid=356701)



Can somebody make me a gmx command - Starky Yakavetta - 04.07.2012

Can somebody make me a gmx command mine isnt working i dont know why ... :S


Re: Can somebody make me a gmx command - DBan - 04.07.2012

pawn Код:
// ZCMD
CMD:restart(playerid, params[])
{
    SendRconCommand("gmx");
    return 1;
}



Respuesta: Can somebody make me a gmx command - admantis - 04.07.2012

I think if you send the RCON command directly OnGameModeExit won't call properly, It happened to me where not all player data would save properly, if that's the case, use a more safe version:
pawn Код:
// ZCMD
CMD:restart(playerid, params[])
{
    OnGameModeExit();
    return 1;
}



Re: Can somebody make me a gmx command - Starky Yakavetta - 04.07.2012

tnx a lot


Re: Respuesta: Can somebody make me a gmx command - Tee - 04.07.2012

Quote:
Originally Posted by admantis
Посмотреть сообщение
I think if you send the RCON command directly OnGameModeExit won't call properly, It happened to me where not all player data would save properly, if that's the case, use a more safe version:
pawn Код:
// ZCMD
CMD:restart(playerid, params[])
{
    OnGameModeExit();
    return 1;
}
pawn Код:
CMD:restart(playerid, params[])
{
    foreach(Player,i)
    {
        SavePlayer(i);
    }
    SendRconCommand("gmx");
    return 1;
}
In that case you could save the players before restarting. But I've never done it the way you do, I'll try it.
The 'SavePlayer()' function is just for this example.


Re: Can somebody make me a gmx command - Dubya - 04.07.2012

@Tee, Yes but, you should make it more secure as in:
pawn Код:
CMD:restart(playerid, params[])
{
    foreach(Player,i)
    {
        if(IsPlayerConnected(i))
        {
            SavePlayer(i);
        }
    }
    SendRconCommand("gmx");
    return 1;
}
Therefore making it more secure, to the on-line players.


Re: Can somebody make me a gmx command - Tee - 04.07.2012

People forget to do that, so foreach does it for them, therefore no need to create a check for connected players.


Re: Can somebody make me a gmx command - Revo - 04.07.2012

pawn Код:
CMD:restart(playerid, params[])
{
    if(IsPlayerAdmin(playerid) {
        foreach(Player,i)
        {
            SavePlayer(i);
        }
        SendRconCommand("gmx");
    }
    return 1;
}
Talking about adding a little security..


Re: Can somebody make me a gmx command - Tee - 04.07.2012

It would've been nice if you guys kept this The 'SavePlayer()' function is just for this example. in the quotes to prevent people viewing it to have problems.