Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "set spectate"
#define VERSION "1.0"
#define AUTHOR "naven & alliedmodders"
new oldSpecTeam[33];
// get/set mapzone bits
#define CS_GET_USER_MAPZONES(%1) get_pdata_int(%1, OFFSET, OFFSET_LINUX_DIFF)
#define CS_SET_USER_MAPZONES(%1,%2) set_pdata_int(%1, OFFSET, %2, OFFSET_LINUX_DIFF)
#define DELAY 0.3
#define TOTAL 0
#define DROPED 1
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /spec", "setSpectate");
}
public setSpectate(id)
{
new team;
team = get_pdata_int(id, 114, 5);
switch(team)
{
case 1:
{
oldSpecTeam[id] = 1;
cs_set_user_team(id, CS_TEAM_SPECTATOR, CS_DONTCHANGE);
if(is_user_alive(id))
user_kill(id);
}
case 2:
{
oldSpecTeam[id] = 2;
cs_set_user_team(id, CS_TEAM_SPECTATOR, CS_DONTCHANGE);
if(is_user_alive(id))
user_kill(id);
}
case 3:
{
switch(oldSpecTeam[id])
{
case 1:
{
cs_set_user_team(id, CS_TEAM_T, CS_T_TERROR);
set_task(0.5, "task_afterSpecChange", id);
}
default:
{
cs_set_user_team(id, CS_TEAM_CT, CS_CT_GIGN);
set_task(0.5, "task_afterSpecChange", id);
}
}
}
default: return FMRES_IGNORED;
}
return PLUGIN_CONTINUE;
}
public task_afterSpecChange(id)
{
//log_amx("AT: task_afterSpecChange");
dllfunc(DLLFunc_Spawn, id);
}
Sometimes after type /spec and go back with /spec i not see the HUD - "health, armor, crosshire, ammo", maybe this is bug.
Please, fix it.