is there a way to make your own RCON commands?
#1

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
Reply
#2

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...
Reply
#3

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;
}
Reply
#4

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

Yes, OnRCONCommand is made exactly for this.
Reply
#6

@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 *
Reply
#7

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)
Reply
#8

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

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)