Raised This Month: $ Target: $400
 0% 

How can I get the command access flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 11-07-2007 , 21:51   How can I get the command access flag
Reply With Quote #1

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?
__________________
=====================================
- My Plugins -
=====================================

Last edited by Vet; 11-07-2007 at 21:53.
Vet is offline
Send a message via MSN to Vet
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 11-07-2007 , 22:13   Re: How can I get the command access flag
Reply With Quote #2

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.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 11-07-2007 , 23:50   Re: How can I get the command access flag
Reply With Quote #3

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.
__________________
=====================================
- My Plugins -
=====================================

Last edited by Vet; 11-08-2007 at 00:00.
Vet is offline
Send a message via MSN to Vet
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-08-2007 , 08:29   Re: How can I get the command access flag
Reply With Quote #4

Type 'amxx cmds' in server console ?
ConnorMcLeod is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 11-08-2007 , 09:27   Re: How can I get the command access flag
Reply With Quote #5

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.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 11-08-2007 , 13:12   Re: How can I get the command access flag
Reply With Quote #6

Ah, thanks Wilson. I missed the !(NOT) in the if(!registered).

Thanks Chronic.
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
Reply



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

Forum Jump


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


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