AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Admin only command- Gatling weapon (https://forums.alliedmods.net/showthread.php?t=270803)

Dare.Devil 08-30-2015 02:59

Admin only command- Gatling weapon
 
1 Attachment(s)
Hi all,

Attached is a weapon plugin called "Gatling".. and under the plugin init section you will find the register_clcmd line that I've edited to make it console only & for admins only..

only problems is.. everyone can still use it and NOT only admins.. can someone me help out and make the console command to buy for ADMINS ONLY?!

Code:

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
       
        register_forward(FM_CmdStart, "fw_CmdStart")
        register_forward(FM_SetModel, "fw_SetModel")
        register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
        register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")       
       
        RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack")
        RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")               
       
        RegisterHam(Ham_Item_Deploy, weapon_gatling, "fw_Item_Deploy_Post", 1)
        RegisterHam(Ham_Weapon_Reload, weapon_gatling, "fw_Weapon_Reload_Post", 1)
        RegisterHam(Ham_Item_PostFrame, weapon_gatling, "fw_Item_PostFrame")
        RegisterHam(Ham_Item_AddToPlayer, weapon_gatling, "fw_Item_AddToPlayer_Post", 1)
        RegisterHam(Ham_Weapon_PrimaryAttack, weapon_gatling, "fw_Weapon_PrimaryAttack")
        RegisterHam(Ham_Weapon_PrimaryAttack, weapon_gatling, "fw_Weapon_PrimaryAttack_Post", 1)
       
        register_clcmd("weapon_gatling", "hook_weapon")
        register_clcmd("get_gatling", "get_gatling", ADMIN_BAN)
}


Phant 08-30-2015 03:20

Re: Admin only command- Gatling weapon
 
You should check access inside declared function.
Check source code of default plugins. For example:
Quote:

register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>")

public cmdRcon(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED


new arg[128], authid[32], name[MAX_NAME_LENGTH]

read_args(arg, charsmax(arg))
get_user_authid(id, authid, charsmax(authid))
get_user_name(id, name, charsmax(name))

log_amx("Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")", name, get_user_userid(id), authid, arg)

console_print(id, "[AMXX] %L", id, "COM_SENT_SERVER", arg)
server_cmd("%s", arg)

return PLUGIN_HANDLED
}

Dare.Devil 08-30-2015 14:39

Re: Admin only command- Gatling weapon
 
Quote:

Originally Posted by Phant (Post 2338210)
You should check access inside declared function.
Check source code of default plugins. For example:

there are no other default plugins..only the includes.. also do u mean that I copy the code script u provide and replace "id" with admin level values??

so do u mean it's a whole new section to add?


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

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