AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_concmd problem (https://forums.alliedmods.net/showthread.php?t=86068)

Salin 02-20-2009 09:36

get_concmd problem
 
Hi, I`m having a little problem with get_concmd.


I registered (let`s say) 11 commands. At my 11th command I made the amx_help for those commands.

PHP Code:

register_concmd("amx_1""func_1"ADMIN_LEVEL_C"Some info")
register_concmd("amx_0""func_0"ADMIN_LEVEL_C"Some info")
register_concmd("amx_3""func_3"ADMIN_LEVEL_C"Some info")
register_concmd("amx_2""func_2"ADMIN_LEVEL_C"Some info")
register_concmd("amx_4""func_4"ADMIN_LEVEL_C"Some info")
register_concmd("amx_5""func_5"ADMIN_LEVEL_C"Some info")
register_concmd("amx_6""func_6"ADMIN_LEVEL_C"Some info")
register_concmd("amx_7""func_7"ADMIN_LEVEL_C"Some info")
register_concmd("amx_8""func_8"ADMIN_LEVEL_C"Some info")
register_concmd("amx_9""func_9"ADMIN_LEVEL_C"Some info")
register_concmd("amx_example""func_help"ADMIN_LEVEL_C"Some info"

The func_help function is like this:

PHP Code:

public func_help(idlevelcid)
{
    new 
p_Flag get_user_flags(id0)
    
    new 
cmd[32], eflagsinfo[128]
    
    new 
start 0
    
    
new nrofcmds get_concmdsnum(p_Flagid)
    
    for(new 
i=starti<nrofcmdsi++)
    {
        
get_concmd(icmd31eflagsinfo127p_Flagid)
        
client_print(idprint_chat"Command: %s"cmd)
    }
    
    return 
PLUGIN_HANDLED


So basically what the function does is showing all the commands, sorted alphabetically, asc. The only problem is, it is now showing the amx_1 command in the output.

The output is something like this:

Code:

Command: amx_0
Command: amx_2
Command: amx_3
Command: amx_4
Command: amx_5
Command: amx_6
Command: amx_7
Command: amx_8
Command: amx_9
Command: amx_example

I`ve noticed that if I put instead of:

PHP Code:

    for(new i=starti<nrofcmdsi++)
    {
        
get_concmd(icmd31eflagsinfo127p_Flagid)
        
client_print(idprint_chat"Command: %s"cmd)
    } 

this one

PHP Code:

         get_concmd(-5cmd31eflagsinfo127p_Flagid)
         
client_print(idprint_chat"Command: %s"cmd

I can see the amx_1 command.

What should I do to fix this?

Spunky 02-20-2009 11:40

Re: get_concmd problem
 
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Command Example", "1.0", "Spunky")     register_concmd("amx_1", "func_1", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_0", "func_0", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_3", "func_3", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_2", "func_2", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_4", "func_4", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_5", "func_5", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_6", "func_6", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_7", "func_7", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_8", "func_8", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_9", "func_9", ADMIN_LEVEL_C, "Some info")     register_concmd("amx_example", "func_help", ADMIN_LEVEL_C, "Some info") } public func_0(id, level, cid)     return PLUGIN_HANDLED public func_1(id, level, cid)     return PLUGIN_HANDLED public func_2(id, level, cid)     return PLUGIN_HANDLED public func_3(id, level, cid)     return PLUGIN_HANDLED public func_4(id, level, cid)     return PLUGIN_HANDLED public func_5(id, level, cid)     return PLUGIN_HANDLED public func_6(id, level, cid)     return PLUGIN_HANDLED public func_7(id, level, cid)     return PLUGIN_HANDLED public func_8(id, level, cid)     return PLUGIN_HANDLED public func_9(id, level, cid)     return PLUGIN_HANDLED public func_help(id, level, cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED     new szCmd[32], iFlags, szInfo[128], iIndex = 0     while (get_concmd(iIndex++, szCmd, 31, iFlags, szInfo, 127, -1, -1))         console_print(id, "Command: %s", szCmd)     return PLUGIN_HANDLED }

Untested, but try it.

Salin 02-23-2009 03:25

Re: get_concmd problem
 
This still skips that registered command and now i see different:

Code:

Command: amx_0
Command: amx_0
Command: amx_2
Command: amx_2
Command: amx_3
Command: amx_3
Command: amx_4
Command: amx_4
Command: amx_5
Command: amx_5
Command: amx_6
Command: amx_6
Command: amx_7
Command: amx_7
Command: amx_8
Command: amx_8
Command: amx_9
Command: amx_9
Command: amx_example

So, any other commands, i see them doubled, but the help command i see it just once.

On your example i can see all the commands even those i don`t have access to. Looks ok but i still have 2 commands that aren`t mine (amx_addadmin and amx_reloadadmins).

Spunky 02-23-2009 18:50

Re: get_concmd problem
 
Code:
while (get_concmd(iIndex++, szCmd, 31, iFlags, szInfo, 127, -1, -1) && iIndex < 11)

I really have no idea why amx_1 won't display...


All times are GMT -4. The time now is 17:02.

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