Heyall,
I've been lurking these forums for the past 3 days trying to iron out my spec kick plugin but it just doesn't work so I've decided to post the code here and see what you guys think.
I coded it for my CS 1.6 server so there are no STEAM checks or anything. It's purpose is to kick users that are in SPECTATOR mode, connected but don't have the immunity bit set at the start of a round when there are 10 or more players.
Code:
#include <amxmodx>
public Round_Time()
{
new Float:roundtime = get_cvar_float("mp_roundtime") * 60.0
new rtime = read_data(1)
if ( roundtime == rtime ) {
new playerCount = get_playersnum()
if (playerCount > 9) {
new Players[32]
new i, userid, team
get_players(Players, playerCount)
for (i=0; i<playerCount; i++) {
if (is_user_connected(i)) {
if (!(get_user_flags(i)&ADMIN_IMMUNITY)) {
team = get_user_team(i)
if (team != 0 && team != 1) {
new name[32], authid[32]
get_user_name(i, name,31)
get_user_authid(i, authid,31)
userid = get_user_userid(i)
server_cmd("kick #%d ^"Spectator^"",userid)
log_amx("Spec Kick: ^"%s<%d><%s>^" was spec kicked)", name,get_user_userid(i),authid)
}
}
}
}
}
}
return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("Spec Kick","0.1","Foo.bar")
register_event("RoundTime", "Round_Time", "bc")
return PLUGIN_CONTINUE
}
(Maybe useful) observations:
- The code is stretched out (cascading ifs) so that I could code in a simpler manner but it'll be optimized once it starts working.
- I've tried coding it with cs_user_team_get but it didn't work (right after the immunity bit check, I did have an include for cstrike)
Code:
if (cs_user_team_get(i) == 3) {
- I've tried comparing the variable "team" with 3 and it didn't work.
If you've got an idea, please help!
Edit:
- I've left out the is_player_alive() check because I don't know if spectators are considered dead or alive.
__________________