AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I get the command access flag (https://forums.alliedmods.net/showthread.php?t=62941)

Vet 11-07-2007 21:51

How can I get the command access flag
 
How can I retrieve the access level flag from a registered console command?

Example:
In the amxcmd.amxx plugin, it registers the slay command as such...
Code:


register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>")

So if I wanted to set my custom command to the same access level as the 'amx_slay' command (assuming I didn't know what it was), how would I go about it?

Clear as mud eh?

GHW_Chronic 11-07-2007 22:13

Re: How can I get the command access flag
 
Code:
    new cmd[32]     new cmdinfo[8]     new flag     new num = get_concmdsnum()     new bool:registered     for(new i=0;i<num;i++)     {         get_concmd(i,cmd,31,flag,cmdinfo,7,52428799,-1)         if(equal(cmd,"amx_slay"))         {             registered=true             break;         }     }     if(!registered)     {         flag = ADMIN_SLAY     }     register_concmd("amx_custom_command","function",flag," - Does Stuff <Blah>")
should work if I am successfully recalling how get_concmd works.

Vet 11-07-2007 23:50

Re: How can I get the command access flag
 
You're on the right track, but that's not quite what I'm looking for. The line: flag = ADMIN_SLAY says that I KNOW what the command's access flag is. I need to know how to get the access flag of a command if I DON'T know what it is.

Why? With the release of 1.8.0, the access flag can be changed in the cmdaccess.ini file. And I want my new command have the same access level at run time. I suppose I can get it by reading through and finding the command in the cmdaccess.ini file. But I figured there must be an easier way.

ConnorMcLeod 11-08-2007 08:29

Re: How can I get the command access flag
 
Type 'amxx cmds' in server console ?

Wilson [29th ID] 11-08-2007 09:27

Re: How can I get the command access flag
 
Vet, look closer at Chronic's code. The reason he set flag = ADMIN_SLAY is because by default, it is set to admin_slay.

But above that, it where the real work gets done.
get_concmd(i,cmd,31,flag,cmdinfo,7,52428799,-1)
That line sets the flag variable. Then it checks if it just set the slay command's info. If so, breaks the loop and leaves you with that flag. If not, keeps going. After it's done looping through all the registered commands, it checks to see if it found the slay command. If not, it sets the flag to admin_slay.

Vet 11-08-2007 13:12

Re: How can I get the command access flag
 
Ah, thanks Wilson. I missed the !(NOT) in the if(!registered).

Thanks Chronic.


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

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