Raised This Month: $51 Target: $400
 12% 

Solved register_clcmd only for admins..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xExperienced
Member
Join Date: Jun 2017
Location: USA
Old 08-15-2017 , 07:02   register_clcmd only for admins..
Reply With Quote #1

I want a specific command to be executed by admin only who has immunity.

I did :
Code:
register_clcmd ("mycommand" "cmdfunction" "ADMIN_IMMUNITY" , "adminonlycommand")
but it is throwing error.
Code:
error 035:
 argument type mismatch (argument 3)
so I tried to define :
Code:
#define IMMUNITY_ACCESS_LEVEL ADMIN_IMMUNITY

but still is throwing same error..
need help in making this active for only admins.

Last edited by xExperienced; 08-15-2017 at 09:16.
xExperienced is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-15-2017 , 07:05   Re: register_clcmd only for admins..
Reply With Quote #2

You are missing some commas there between function arguments. Also, there should be no quotation marks around ADMIN_IMMUNITY.
Why didn't you just take a look at another plugin? There are many plugins registering commands, even in the default AMXX package.

Last edited by klippy; 08-15-2017 at 07:06.
klippy is offline
Ayman Khaled
Senior Member
Join Date: Mar 2017
Location: Palestine
Old 08-15-2017 , 07:05   Re: register_clcmd only for admins..
Reply With Quote #3

PHP Code:
#include <amxmisc> 
PHP Code:
register_clcmd ("mycommand" "cmdfunction" "ADMIN_IMMUNITY" "adminonlycommand"


PHP Code:
register_clcmd ("mycommand""cmdfunction"ADMIN_IMMUNITY
PHP Code:
public cmdfunction(iPlayeriLeveliCid)
{
    if(!
cmd_access(iPlayeriLeveliCid0))
        return 
PLUGIN_HANDLED

__________________

Last edited by Ayman Khaled; 08-15-2017 at 07:07.
Ayman Khaled is offline
Old 08-15-2017, 07:09
Natsheh
This message has been deleted by Natsheh.
xExperienced
Member
Join Date: Jun 2017
Location: USA
Old 08-15-2017 , 08:42   Re: register_clcmd only for admins..
Reply With Quote #4

Thansk Klippy & Ayman Khaled for your valuable reply.


but what will happen if I just register command properly for ADMIN_IMMUNITY and dont put this :

Code:
public cmdfunction(iPlayer, iLevel, iCid)
{
    if(!cmd_access(iPlayer, iLevel, iCid, 0))
        return PLUGIN_HANDLED
}

Last edited by xExperienced; 08-15-2017 at 08:44.
xExperienced is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-15-2017 , 08:59   Re: register_clcmd only for admins..
Reply With Quote #5

If you read the code of cmd_access() you'll see that it check whether the user has a required flag(s), has passed in the right amount of arguments. Also displays the help message in case they didn't execute the command properly or didn't have access.

What the access flag you put into register_clcmd() does is it opts the command into the flag manager (file addons/amxmodx/configs/cmdaccess.ini) and sets that as a default access flag.
klippy is offline
xExperienced
Member
Join Date: Jun 2017
Location: USA
Old 08-15-2017 , 09:15   Re: register_clcmd only for admins..
Reply With Quote #6

Quote:
Originally Posted by KliPPy View Post
If you read the code of cmd_access() you'll see that it check whether the user has a required flag(s), has passed in the right amount of arguments. Also displays the help message in case they didn't execute the command properly or didn't have access.

What the access flag you put into register_clcmd() does is it opts the command into the flag manager (file addons/amxmodx/configs/cmdaccess.ini) and sets that as a default access flag.
oh.. Thanks..
xExperienced is offline
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 05:33.


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