Код:
new roundtime,bool:infection
new cv_rtime
new ScoreInfo,TeamInfo,ScreenFade
// Me Guesta
new const g_weapon_ents[][] = {
"weapon_357",
"weapon_9mmAR",
"weapon_9mmhandgun",
"weapon_crossbow",
"weapon_egon",
"weapon_gauss",
"weapon_glock",
"weapon_handgrenade",
"weapon_hornetgun",
"weapon_mp5",
"weapon_python",
"weapon_rpg",
"weapon_satchel",
"weapon_shotgun",
"weapon_snark",
"weapon_tripmine",
"item_longjump",
"item_suit",
"item_battery",
"item_healthkit",
"weaponbox"
}
// Item entities
new const g_item_ents[][] = {
"ammo_357",
//"ammo_556",
"ammo_9mmAR",
"ammo_9mmbox",
"ammo_9mmclip",
"ammo_ARgrenades",
"ammo_buckshot",
"ammo_crossbow",
"ammo_egonclip",
"ammo_gaussclip",
"ammo_glockclip",
"ammo_mp5clip",
"ammo_mp5grenades",
"ammo_rpgclip",
"item_longjump",
"item_suit",
"item_battery",
"item_healthkit",
"weaponbox"
}
// "Func" entities
new const g_func_ents[][] = {
"func_recharge",
"func_healthcharger",
"func_tank",
"func_tankcontrols",
"func_tanklaser",
"func_tankmortar",
"func_tankrocket",
"monster_barney",
"monster_scientist"
}
#define m_iDeaths 377
#define m_szTeamName 383
#define hud_offset 296
#define XTRA_OFS_PLAYER 5
stock static teams[10][16]
new bool:g_infected[33],cuplayers,g_zombies,g_humans
public plugin_init(){
register_plugin(PLUGIN, VERSION, AUTHOR)
cv_rtime = register_cvar("bh_rtime","2")
ScoreInfo = get_user_msgid("ScoreInfo")
TeamInfo = get_user_msgid("TeamInfo")
ScreenFade = get_user_msgid("ScreenFade")
// Thank to Anggara_nothing and his Zombie Mod plugin
for(new i=0;i<sizeof(g_func_ents);i++)
RegisterHam(Ham_Use, g_func_ents[i], "fw_UseStaticonary")
for(new i=0;i<sizeof(g_item_ents);i++)
RegisterHam(Ham_Touch,g_item_ents[i],"fw_WpTouch")
for(new i=0;i<sizeof(g_weapon_ents);i++)
RegisterHam(Ham_Item_AddToPlayer,g_weapon_ents[i],"fw_WpTouch")
RegisterHam(Ham_Killed,"player","fw_PlayerKilled")
RegisterHam(Ham_TraceAttack,"player","fw_TraceAttack")
set_task(10.0,"round_start")
}
public client_putinserver()
cuplayers++
public client_disconnect()
cuplayers--
// Round System ------------------------------------------------------------------------------------
public round_start(){
if(cuplayers<3){
set_hudmessage(0, 255, 0, -1.0, 0.30, 0, 6.0, 12.0)
show_hudmessage(0, "NOPE!!!")
set_task(5.0,"round_start")
return PLUGIN_CONTINUE
}
roundtime = get_pcvar_num(cv_rtime)*60
for(new i=1;i<=get_playersnum();++i){
g_infected[i]=false
set_user_team(i,"hgrunt",false,false)
hl_user_spawn(i)
g_humans++
}
set_task(5.0,"random_infection")
round_think()
return PLUGIN_CONTINUE
}
public round_think(){
static mins; mins = roundtime/60
static secs; secs = roundtime-mins*60
set_hudmessage(0, 255, 0, -1.0, 0.30, 0, 6.0, 12.0)
show_hudmessage(0, "%d:%.2d",mins,secs) // help me pls
roundtime--
if(!g_zombies&&infection){
round_end(2)
return PLUGIN_CONTINUE
}else if(!g_humans){
round_end(1)
return PLUGIN_CONTINUE
}
if(roundtime)
set_task(1.0,"round_think")
else
round_end(0)
return PLUGIN_CONTINUE
}
public round_end(wins){
g_zombies = 0
g_humans = 0
infection = false
set_hudmessage(255, 255, 212, -1.0, 0.30, 0, 6.0, 12.0)
switch(wins){
case 0: show_hudmessage(0,"Round Draw :P")
case 1: show_hudmessage(0,"Zombies wins! :U")
case 2: show_hudmessage(0,"Humans wins! Fuck Yeah")
}
set_task(5.0,"round_start")
}
//--------------------------------------------------------------------------------------------------
// Infection :D ------------------------------------------------------------------------------------
public random_infection(){
new infected = random_num(1,cuplayers)
set_hudmessage(255, 255, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "%d is infected!!! XD",infected)
infection=true
infect_user(infected)
}
public infect_user(id){
if(!is_user_alive(id))
return
set_user_team(id,"zombie",false,false)
g_infected[id]=true
hl_strip_user_weapons(id)
give_item(id,"weapon_crowbar")
message_begin(MSG_ONE,ScreenFade, _,id)
write_short(1<<10)
write_short(1<<10)
write_short(0)
write_byte(255)
write_byte(100)
write_byte(100)
write_byte(250)
message_end()
set_pev(id,pev_health,1337.0) // The Leet Zombie
g_zombies++
g_humans--
}
//--------------------------------------------------------------------------------------------------
// Disallow zombies pickup weapons and use guns ----------------------------------------------------
public fw_WpTouch(ent, id){
if(!is_user_connected(id))
return HAM_IGNORED
if(g_infected[id])
return HAM_SUPERCEDE
return HAM_IGNORED
}
public fw_UseStaticonary(entity, caller, activator, use_type){
if(is_user_connected(caller)&&g_infected[caller])
return HAM_SUPERCEDE
return HAM_IGNORED
}
//--------------------------------------------------------------------------------------------------
public fw_PlayerKilled(this, idattacker, shouldgib){
if(is_user_connected(this)&&g_infected[this]){
hl_set_user_spectator(this,true)
g_zombies--
}else if(!g_infected[this]){
hl_set_user_spectator(this,true)
g_humans--
}
}
public fw_TraceAttack(victim, inflictor, Float:damage, Float:direction[3], traceresult, damagebits){
if(damagebits == DMG_CLUB && g_infected[inflictor]&&!g_infected[victim]){
infect_user(victim)
}
return HAM_IGNORED
}
//--------------------------------------------------------------------------------------------------
// User Team -_- -----------------------------------------------------------------------------------
set_user_team(const iPlayer, const szTeamName[], const bool: bKill, const bool: bGib){
if(pev_valid(iPlayer)!=2)
return
if(bKill){
// kill the player, remove a death, and let them start on the new team
set_pdata_int(iPlayer, m_iDeaths, get_pdata_int(iPlayer, m_iDeaths, XTRA_OFS_PLAYER) - 1, XTRA_OFS_PLAYER)
ExecuteHam(Ham_TakeDamage, iPlayer, 0, 0, 99999.9, DMG_GENERIC | _:bGib ? DMG_ALWAYSGIB : DMG_NEVERGIB);
}
set_pdata_string(iPlayer, m_szTeamName * 4, szTeamName, -1, XTRA_OFS_PLAYER * 4)
// notify everyone's HUD of the team change
message_begin(MSG_ALL, TeamInfo)
write_byte(iPlayer)
write_string(szTeamName)
message_end()
message_begin(MSG_ALL, ScoreInfo)
write_byte(iPlayer)
write_short(pev(iPlayer, pev_frags))
write_short(get_pdata_int(iPlayer, m_iDeaths, XTRA_OFS_PLAYER))
write_short(0)
write_short(__get_team_index(szTeamName))
message_end()
set_user_info(iPlayer, "model",szTeamName)
hl_set_user_spectator(iPlayer,false)
}
stock __get_team_index(const team[])
{
static teamid; teamid = 0
static valid; valid = 0
static i; i = 0
__count_teams()
for(i = 0 ; i < sizeof teams; i++)
{
teamid++
if(equali(teams[i][0], team))
{
valid = 1
break
}
}
if(valid)
return teamid
return 0
}
stock __count_teams()
{
if(!teams[0][0])
{
new teamlist[50]
get_pcvar_string(get_cvar_pointer("mp_teamlist"), teamlist, charsmax(teamlist)); trim(teamlist)
__explode_teamlist(teams, charsmax(teams[]), teamlist, ';')
}
static teamcount
if(!teamcount)
{
for(new i = 0; i < sizeof teams; i++)
{
if(teams[i][0])
teamcount++
}
}
return teamcount
}
stock __explode_teamlist(output[][], size, input[], delimiter)
{
new nIdx = 0, l = strlen(input)
new nLen = (1 + copyc(output[nIdx], size, input, delimiter ))
while( (nLen < l) && (++nIdx < 10) )
nLen += (1 + copyc(output[nIdx], size, input[nLen], delimiter ))
}
stock hl_get_user_team(client, team[] = "", len = 0)
{
if(hl_get_user_spectator(client))
return 0
static Float: tdm; global_get(glb_teamplay, tdm)
if(tdm < 1.0) return 0
if(!len) len = 16
get_user_info(client, "model", team, len)
return __get_team_index(team)
}
stock bool:hl_get_user_spectator(client)
{
if(pev(client, pev_iuser1) || pev(client, pev_iuser2))
return true
return false
}
stock hl_set_user_spectator(client, bool:spectator = true)
{
if(hl_get_user_spectator(client) == spectator)
return
if(spectator)
{
static AllowSpectatorsCvar
if(AllowSpectatorsCvar || (AllowSpectatorsCvar = get_cvar_pointer("allow_spectators")))
{
if(!get_pcvar_num(AllowSpectatorsCvar))
set_pcvar_num(AllowSpectatorsCvar, 1)
engclient_cmd(client, "spectate")
}
}
else
{
hl_user_spawn(client)
set_pev(client, pev_iuser1, 0)
set_pev(client, pev_iuser2, 0)
set_pdata_int(client,hud_offset, 0)
static szTeam[16]
hl_get_user_team(client, szTeam, charsmax(szTeam))
message_begin(MSG_ALL, TeamInfo)
write_byte(client)
write_string(szTeam)
message_end()
}
}
stock hl_user_spawn(client)
{
if(!hl_strip_user_weapons(client))
return
set_pev(client, pev_deadflag, DEAD_RESPAWNABLE)
}
stock hl_strip_user_weapons(client)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
if(!pev_valid(ent))
return 0
dllfunc(DLLFunc_Spawn, ent);
dllfunc(DLLFunc_Use, ent, client)
engfunc(EngFunc_RemoveEntity, ent)
return 1
}
//--------------------------------------------------------------------------------------------------