AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spectator Block (https://forums.alliedmods.net/showthread.php?t=2726)

rootdown 06-14-2004 21:40

Spectator Block
 
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.

FlyingMongoose 06-14-2004 22:23

you should use this code that I found in olo's old autoteam select plugin and that I use in my autoassign plugin

Code:
register_event("ShowMenu","admin_check","b","4&Team_Select") register_event("VGUIMenu","admin_check","b","1=2","1=26","1=27")

to detect the team select menu


All times are GMT -4. The time now is 14:46.

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