SA-MP Forums Archive
is there a way to make your own RCON commands? - 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: is there a way to make your own RCON commands? (/showthread.php?tid=338602)



is there a way to make your own RCON commands? - niels44 - 30.04.2012

hey guys,

is it possible to make your own rcon commands? so you make a command like, setname and then you can type it in console like setname [playerid] [newname] ?

just a question

greets niels


Re: is there a way to make your own RCON commands? - Youwannaplayarough?OKAY! - 30.04.2012

Quote:
Originally Posted by niels44
Посмотреть сообщение
hey guys,

is it possible to make your own rcon commands? so you make a command like, setname and then you can type it in console like setname [playerid] [newname] ?

just a question

greets niels
I think there is...


Re: is there a way to make your own RCON commands? - Mean - 30.04.2012

You can use IsPlayerAdmin.

pawn Код:
//Example
CMD:loltest(playerid, params[]) {
    if(!IsPlayerAdmin(playerid)) return 0; // If the player isn't logged into RCON, it will return "Unknown Command" and stop the code from executing. If the player is logged into RCON, the code after this line will get executed. That's what this line does.
    SendClientMessage(playerid, -1, "Lol you're an admin");
    return 1;
}



Re: is there a way to make your own RCON commands? - Niko_boy - 30.04.2012

OnRCONCommand recieved there something like that
i guess that can work
https://sampwiki.blast.hk/wiki/OnRconCommand


Re: is there a way to make your own RCON commands? - Mauzen - 30.04.2012

Yes, OnRCONCommand is made exactly for this.


Re: is there a way to make your own RCON commands? - Niko_boy - 30.04.2012

@Mauzen yeah
i didnt earlier knewing it i was trying to use it for checking if old command is used :P but that was no working :=\ the check *


Re: is there a way to make your own RCON commands? - Hiddos - 30.04.2012

You could use IsPlayerAdmin, but that can only be used for in-game admins. From the console you can use OnRconCommand, but you need at least one filterscript running (else OnRconCommand doesn't get called :S)


AW: is there a way to make your own RCON commands? - BigETI - 30.04.2012

OnRconCommand won't get called if you try to write commands over the cmd window.


Re: is there a way to make your own RCON commands? - Mean - 30.04.2012

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
but you need at least one filterscript running (else OnRconCommand doesn't get called :S)
Quote:
Originally Posted by SA-MP wiki
Important Note: You will need to include this callback in a loaded filterscript for it to work in the gamemode!
Yup.


There's no big difference in using IsPlayerAdmin and OnRconCommand except you need /rcon [command] with OnRconCommand, while with IsPlayerAdmin you'd do /command.

I prefer IsPlayerAdmin, don't know about you guys.


Re: is there a way to make your own RCON commands? - MP2 - 30.04.2012

If you want to make console commands you need to use OnRconCommand and sscanf and strcmp.

pawn Код:
public OnRconCommand(cmd[])
{
    new cmdtext[16], params[128];
    sscanf(cmd, "s[16]S( )[128]", cmdtext, params);

    if(!strcmp(cmdtext, "setname", true))
    {
        new id, newname[MAX_PLAYER_NAME];
        if(sscanf(params, "us[24]", id, newname))
        {
            print("USAGE: setname <id/name> <newname>");
        }
        else
        {
            if(id == INVALID_PLAYER_ID) print("ERROR: Player not connected.");
            else SetPlayerName(id, newname);
        }
        return 1;
    }
    return 0;
}
You'll need sscanf.

Also IMPORTANT:
pawn Код:
// Put this in a filterscript. OnRconCommand won't be called in your GM unless it is used in a FS

public OnRconCommand(cmd[]) return 1;
Just tested it and it works great.