Hi, this code is supposed to prevent other than admins to join spectatormode... but it isnt working as it should, care to help me out?
Code:
#include <amxmodx>
public admin_check(id, level, cid) {
if (!(get_user_flags(id)&ADMIN_RESERVATION) && (get_cvar_num("amx_spectator") == 1)){
client_print(id,print_chat,"* You can not become spectator!")
new sTeam[10]
get_user_info(id,"team",sTeam,9)
if (equal(sTeam,"")) client_cmd(id,"chooseteam")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("Spectator Block", "1.1", "[AsC]Phil")
register_clcmd("jointeam 6", "admin_check")
register_cvar("amx_spectator","1")
if (get_cvar_num("allow_spectators") == 0) set_cvar_num("allow_spectators",1)
return PLUGIN_CONTINUE
}
when using the above code a non-admin player can still join spectatormode through menus ("m" then "6"). But if the player uses command "jointeam 6" through console he gets the message "* You can not become spectator!"
Code:
#include <amxmodx>
public admin_check(id, level, cid) {
if (!(get_user_flags(id)&ADMIN_RESERVATION) && (get_cvar_num("amx_spectator") == 1)){
client_print(id,print_chat,"* You can not become spectator!")
new sTeam[10]
get_user_info(id,"team",sTeam,9)
if (equal(sTeam,"")) client_cmd(id,"chooseteam")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("Spectator Block", "1.1", "[AsC]Phil")
register_clcmd("jointeam 6", "admin_check")
register_clcmd("menuselect 6", "admin_check")
register_cvar("amx_spectator","1")
if (get_cvar_num("allow_spectators") == 0) set_cvar_num("allow_spectators",1)
return PLUGIN_CONTINUE
}
when using this code (just added
register_clcmd("menuselect 6", "admin_check") ) you cannot as a player join spectatormode through menus or through "jointeam 6" in console, which is good.... But as you see the problem is when you use menuselect 6 in a other situation (for example buying AWM through menus) and not being able to perform the command.
You can still buy awm's through buyscripts, but as you can guess it wont be so funny to get "* You can not become spectator!" in every situation you use menuselect 6, and not getting the command executed.
__________________