AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Register Commands with Space (https://forums.alliedmods.net/showthread.php?t=162356)

deadman909 07-18-2011 02:31

Register Commands with Space
 
Okay so just a simple question but how do you register commands with a space in them.

Example:
// This Command Works
register_clcmd( "say /ServerRules", "Rules" );


// But this command doesn't because there is a space between Server and Rules.
register_clcmd( "say /Server Rules", "Rules" );

// What I want to know is how to make it so this above command also works as well.

fysiks 07-18-2011 03:55

Re: Register Commands with Space
 
You might have to register just "say" then check there (however, this is less efficient but don't know how much).

deadman909 07-18-2011 04:21

Re: Register Commands with Space
 
You mean just put it like this

register_clcmd( "say", "Rules" );

//and than under put?
register_clcmd( "say /Server Rules", "Rules" );

Aykay 07-18-2011 04:57

Re: Register Commands with Space
 
Quote:

Originally Posted by deadman909 (Post 1512885)
You mean just put it like this

register_clcmd( "say", "Rules" );

//and than under put?
register_clcmd( "say /Server Rules", "Rules" );

I think he means within the function called by 'say', check if "Server Rules" was the input and then call the "Rules" function.

deadman909 07-18-2011 05:06

Re: Register Commands with Space
 
Quote:

Originally Posted by Aykay (Post 1512895)
I think he means within the function called by 'say', check if "Server Rules" was the input and then call the "Rules" function.

Thank you for your reply but can you give an example to what your trying to tell me?

fysiks 07-18-2011 05:29

Re: Register Commands with Space
 
register "say", get arg string, check it is equal to "/Server Rules" else return PLUGIN_CONTINUE.

abdul-rehman 07-18-2011 06:13

Re: Register Commands with Space
 
Wont this work ?
Code:
register_clcmd( "say ^"/Server Rules^"", "Rules" );

deadman909 07-18-2011 06:37

Re: Register Commands with Space
 
Quote:

Originally Posted by abdul-rehman (Post 1512931)
Wont this work ?
Code:
register_clcmd( "say ^"/Server Rules^"", "Rules" );

It compiled but when I type the command still nothing happens.

liinuus 07-18-2011 07:44

Re: Register Commands with Space
 
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say", "HandleSay") }  public HandleSay(id)  {         static said[192], cow;     read_args(said,191);     remove_quotes(said);     //remove the / if it is there     if( equali(said,"/",1 ) ) cow = 1;     else cow = 0;         new first_message[21], dummy[2]     strbreak(said[cow], first_message, 20, dummy, 1)         if(equali(first_message, "Server")) {         new Left[151], Right[151]         strbreak(said[cow], Left, 150, Right, 150)         strbreak(Right, Left, 150, Right, 150)         if( equali(Left, "rules") || equali(Left, "Rules") )         {                         //ur code here         }     } }

Exolent[jNr] 07-18-2011 09:04

Re: Register Commands with Space
 
Quote:

Originally Posted by liinuus (Post 1512970)
Code:
        if( equali(Left, "rules") || equali(Left, "Rules") )

equali() is case-insensitive, so those 2 checks are the exact same.


All times are GMT -4. The time now is 01:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.