AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   concmd info (https://forums.alliedmods.net/showthread.php?t=141445)

-B1ng0- 10-24-2010 06:40

concmd info
 
Hey guys,

How i can get info of concmd.

Exemple:
i have:
register_concmd("amx_help", "cmdHelp", 0, "<page> [nr of cmds (only for server)] - displays this help")

and i want to get info to this command: <page> [nr of cmds (only for server)] - displays this help

i try with get_concmd but no results....


Ty.

Arkshine 10-24-2010 07:20

Re: concmd info
 
get_concmd() should work, how you use it ?

-B1ng0- 10-24-2010 07:25

Re: concmd info
 
i have this:
Quote:

for (i = 0; i < g_Count; i++)
{
if (equali (arg, g_CmdsList[0][i], strlen (g_CmdsList[0][i])))
{
replace (arg, charsmax (arg), g_Slash, "");
formatex (command, charsmax (command),"amx_%s", arg);
client_cmd(id, command);

break;
}
}
and i whant when i type on of this commands: g_CmdsList[0][i] to get info of this, or show me how to get info only for one command like amx_help

fysiks 10-24-2010 17:21

Re: concmd info
 
Looks like you would need to loop through all commands with get_concmd() and get_concmdsnum() to retreive the correct a single command info.

I would probably cache the command names and their associated indices in a Trie so that when I look for the one command it is quick and simple to get the index. Then with that index you would use get_concmd() to retrieve the information that you want.

Shouldn't be too hard to write one up.

Exolent[jNr] 10-24-2010 17:59

Re: concmd info
 
You can use this:
Code:
stock find_concmd_byname(const cmd[], &flags, info[], infolen, id = -1) {     new iIndex = -1, szCommand[ 32 ];         while( get_concmd( ++iIndex, szCommand, charsmax( szCommand ), flags, info, infolen, id ) )     {         if( equali( cmd, szCommand ) )         {             return iIndex;         }     }         flags = 0;     info[ 0 ] = 0;         return -1; }

fysiks 10-24-2010 19:20

Re: concmd info
 
Much more compact than my method. Don't suppose that efficiency between yours and mine would be significant (ignoring plugin_cfg code to populate the trie)?

Exolent[jNr] 10-24-2010 19:28

Re: concmd info
 
Quote:

Originally Posted by fysiks (Post 1333399)
Much more compact than my method. Don't suppose that efficiency between yours and mine would be significant (ignoring plugin_cfg code to populate the trie)?

Really just depends on how much it is used.
I actually wouldn't use my function unless I'm using it for one command.
It would be better to imitate my function and filter the commands you want into the trie.

-B1ng0- 10-25-2010 07:37

Re: concmd info
 
exolent can you show me an exemple with your stock metod!?

fysiks 10-25-2010 10:56

Re: concmd info
 
PHP Code:

new iFlagsszInfo[40]
if( 
find_concmd_byname("amx_hello"iFlagsszInfocharsmax(szInfo)) > -)
{
    
// command exists, info is in iFlags and szInfo


Just put the variables in there.


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

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