SA-MP Forums Archive
Fast rcon command processor: RCMD (modified DCMD) - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: Fast rcon command processor: RCMD (modified DCMD) (/showthread.php?tid=88771)



Fast rcon command processor: RCMD (modified DCMD) - Correlli - 28.07.2009

This works on same way as DCMD but only difference is that this function is for RCON commands.

Function:
pawn Code:
#if !defined RCMD_PREFIX
    #define RCMD_PREFIX "/"
#endif
pawn Code:
#if !defined rcmd
    #define rcmd(%1,%2,%3) if((strcmp((%3), RCMD_PREFIX #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (rcmd_%1(""))) || (((%3)[(%2) + 1] == 32) && (rcmd_%1((%3)[(%2) + 2]))))) return 1
#endif
Example:
pawn Code:
public OnRconCommand(cmd[])
{
    rcmd(amsg, 4, cmd); // Because amsg has 4 characters.
    return false;
}

// Example RCON-console command:
rcmd_amsg(command[])
{
    if(!strlen(command))
    {
        printf("Correct usage: \"%samsg [text]\"", RCMD_PREFIX);
        return true;
    }
    SendClientMessageToAll(0xFF0000AA, command);
    printf("Admin: %s", command);
    return true;
}
Credits:
DracoBlue - [HowTo] Fast command processor: DCMD


Re: Fast rcon command processor: RCMD (modified DCMD) - aspire5630 - 28.07.2009

Don't you need permsion if its a edit?
and i don't really understand


Re: Fast rcon command processor: RCMD (modified DCMD) - Correlli - 01.08.2009

Quote:
Originally Posted by aspire5630
Don't you need permsion if its a edit?
and i don't really understand
Read again if you don't understand.


Re: Fast rcon command processor: RCMD (modified DCMD) - Burridge - 01.08.2009

Cool. Nice work Don Correlli.


Re: Fast rcon command processor: RCMD (modified DCMD) - Goldkiller - 01.08.2009

Quote:

Known bugs:
Somehow you can use rcmd commands if you use /, !, ? or any other character in front of the command.

That's not a bug.I guess the only thing you have changed is "dcmd" to "rcmd" in the definition.

Quote:

#define rcmd(%1,%2,%3) if((strcmp((%3)[1], #%1, true, (%2)) == 0)

You should change it to
Quote:

#define rcmd(%1,%2,%3) if((strcmp((%3)[0], #%1, true, (%2)) == 0)

or
Quote:

#define rcmd(%1,%2,%3) if((strcmp((%3), #%1, true, (%2)) == 0)

to make it work without any character before the command name.DCMD ignores the first character as in OnPlayerCommandText() it is always '/'.


Re: Fast rcon command processor: RCMD (modified DCMD) - Correlli - 01.08.2009

I mean, it's meant to work with '/' in front of it, OnPlayerCommandText always looks for '/' character in front of the command
while OnRconCommand doesn't.


Re: Fast rcon command processor: RCMD (modified DCMD) - Goldkiller - 01.08.2009

Uhm,I guess I understood you now.You want the Rcon cmds to start with '/'.
Code:
#define rcmd(%1,%2,%3) if((strcmp((%3),"/" #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (rcmd_%1(""))) || (((%3)[(%2) + 1] == 32) && (rcmd_%1((%3)[(%2) + 2]))))) return 1



Re: Fast rcon command processor: RCMD (modified DCMD) - Correlli - 01.08.2009

Quote:
Originally Posted by Goldkiller
Uhm,I guess I understood you now.You want the Rcon cmds to start with '/'.
Code:
#define rcmd(%1,%2,%3) if((strcmp((%3),"/" #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (rcmd_%1(""))) || (((%3)[(%2) + 1] == 32) && (rcmd_%1((%3)[(%2) + 2]))))) return 1
Yes. I figured that out, but thanks for support.