problem with halting the plugin
my plugin is slightly large, show I will only show the bits that are relevant:
Code:
|
Yeah.
Code:
So, the function cmd_noaccess return PLUGIN_HANDLED. But, you don't do anything with the return value. If you do something like this: Code:
Change your code to this: Code:
|
thanks for your reply :) although i still dont understand this return PLUGIN_HANDLED - does the command just stop all execution of code, within that function? what would happen if i didnt return anything, i read in the amxmodx docs that it would display "unknown command" in the client console
|
erm...pm...correct me if im wrong but...um
Code:
if (!cmd_access(id, level, cid, 0)) {Code:
if (!cmd_access(id, level, cid, 1)) { |
Quote:
|
What PM was saying is that in cmd_live you call cmd_noaccess. Inside of cmd_noaccess you return PLUGIN_HANDLED, and this stops cmd_noaccess, it does NOT stop cmd_live, since you never put a return statement inside of cmd_live itself. Additionally, the cmd_access function will print "You have no access to this command" by itself, so your entire cmd_noaccess function is useless, and it will be printed twice to the client.
When you call cmd_access, the last parameter is how many parameters the comand has, including the command itself. So if you have a command "amx_command <player> <0|1>" you would have a 3 for the last parameter in cmd_access. 1 is amx_comand, 2 is <player>, and 3 is <0|1>. When you do that, if a player only puts in "amx_command <player>", cmd_access will return an error and show the proper usage. This is also another reason why not to print "You do not have access to this command" yourself, as cmd_access may be false for different reasons. So, technically the last parameter in your case should be 1, although it does work with 0. |
Try the plugin like this.
Code:
|
| All times are GMT -4. The time now is 19:22. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.