SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 28/07/2009, 05:54 PM   #1
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Fast rcon command processor: RCMD (modified DCMD)

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

Last edited by Correlli; 14/09/2012 at 10:18 PM.
Correlli is offline   Reply With Quote
Old 28/07/2009, 06:58 PM   #2
aspire5630
Huge Clucker
 
Join Date: Jul 2008
Posts: 286
Reputation: 0
Default Re: Fast rcon command processor: RCMD (modified DCMD)

Don't you need permsion if its a edit?
and i don't really understand
aspire5630 is offline   Reply With Quote
Old 01/08/2009, 11:25 AM   #3
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Re: Fast rcon command processor: RCMD (modified DCMD)

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.
Correlli is offline   Reply With Quote
Old 01/08/2009, 11:27 AM   #4
Burridge
High-roller
 
Burridge's Avatar
 
Join Date: Nov 2008
Location: England
Posts: 2,086
Reputation: 26
Default Re: Fast rcon command processor: RCMD (modified DCMD)

Cool. Nice work Don Correlli.
__________________
Burridge is offline   Reply With Quote
Old 01/08/2009, 11:39 AM   #5
Goldkiller
Big Clucker
 
Goldkiller's Avatar
 
Join Date: Aug 2006
Location: Germany
Posts: 157
Reputation: 14
Default Re: Fast rcon command processor: RCMD (modified DCMD)

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 '/'.
__________________
Goldkiller is offline   Reply With Quote
Old 01/08/2009, 11:47 AM   #6
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Re: Fast rcon command processor: RCMD (modified DCMD)

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.
Correlli is offline   Reply With Quote
Old 01/08/2009, 11:57 AM   #7
Goldkiller
Big Clucker
 
Goldkiller's Avatar
 
Join Date: Aug 2006
Location: Germany
Posts: 157
Reputation: 14
Default Re: Fast rcon command processor: RCMD (modified DCMD)

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
__________________
Goldkiller is offline   Reply With Quote
Old 01/08/2009, 12:02 PM   #8
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Re: Fast rcon command processor: RCMD (modified DCMD)

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.
Correlli is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] [INC] zcmd 0.3.1 | Fast & Simple Command Processor (updated 30/10/2009) Zeex Includes 535 03/08/2014 07:12 PM
[HowTo] Fast command processor: DCMD (0.3 Ready) DracoBlue Help Archive 9 28/11/2010 12:13 PM
[HR/SR:FS] Fast rcon command processor: RCMD (modified DCMD) Correlli Archive 0 16/11/2009 10:20 PM
fast command processor [mad]MLK Help Archive 1 22/08/2009 01:32 AM
rcmd, like dcmd but for rcon commands! Daren_Jacobson Help Archive 4 02/03/2009 10:02 PM


All times are GMT. The time now is 01:53 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.