AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   dmb lil question (https://forums.alliedmods.net/showthread.php?t=13441)

n0obie4life 05-16-2005 10:53

dmb lil question
 
may i know whats the difference if i don't put the ",level,cid" in this following script?
Code:
public train(id,level,cid)

i declared that you need at least ADMIN_LEVEL_A to do that, but if i don't put that, will it do any harm?

yep, i know stupid question :)

xeroblood 05-16-2005 11:30

If you don't put it, then the function will not be able to compare access levels to the calling user, meaning anyone can call the command from console in-game..

Bad idea, unless it is a public command..

To compare access levels, we usually use 'cmd_access()' from amxmisc.inc:

Code:
public MyFunction( id, level, cid ) {     if( !cmd_access( id, level, cid, 0 ) ) // <--  0 = # of Command-Line Arguments..         return PLUGIN_HANDLED }

twistedeuphoria 05-16-2005 12:23

The last parameter should be number of command line arguments + 1 :wink:
Quote:

Originally Posted by funcwiki
The last parameter (num) is the number of arguments.
Note that the first parameter is the command name so if you expect one param set it to 2.


n0obie4life 05-17-2005 05:51

oh crap. no wonder my plugin wasn't "approved"

Code:
 if (!(get_user_flags(id)&ADMIN_LEVEL_A)){         client_print(id,print_console,"[AMX] You have no access to that command")         return PLUGIN_HANDLED  }

what abotu if i use this?


All times are GMT -4. The time now is 16:39.

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