#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <cs_maxspeed_api>
#include <zp50_class_zombie>
#include <zp50_core>
// Configs
const Float:fastrun_time = 10.0
const Float:fastrun_speed = 400.0
const Float:slowrun_time = 5.0
const Float:slowrun_speed = 140.0
new g_had_sprint[33], g_can_use_sprint[33], g_using_sprint[33], g_sprint_status[33]
new g_Msg_ScreenFade
new const sound_fastrun_start[] = "Zombie_Thehero/speedup.wav"
new const sound_fastrun_heartbeat[] = "Zombie_Thehero/speedup_heartbeat.wav"
new const sound_breath_male[] = "Zombie_Thehero/human_breath_male.wav"
new const sound_breath_female[] = "Zombie_Thehero/human_breath_female.wav"
#define TASK_REMOVE_FASTRUN 59384543
#define TASK_REMOVE_SLOWRUN 5893485
#define TASK_HUMAN_SOUND 53450834
new g_MsgSetFOV
public plugin_init()
{
//register_clcmd("run", "run")
register_clcmd("wohenni", "do_fastrun")
//RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
g_Msg_ScreenFade = get_user_msgid("ScreenFade")
g_MsgSetFOV = get_user_msgid("SetFOV")
}
public plugin_precache()
{
precache_sound(sound_fastrun_start)
precache_sound(sound_fastrun_heartbeat)
precache_sound(sound_breath_male)
precache_sound(sound_breath_female)
}
public client_PostThink(id)
{
if(!is_user_alive(id))return
if(g_had_sprint[id] && g_using_sprint[id])
{
if(g_sprint_status[id] == 1)
{
if(pev(id, pev_maxspeed) != fastrun_speed) cs_set_player_maxspeed_auto(id, fastrun_speed)
} else if(g_sprint_status[id] == 2) {
if(pev(id, pev_maxspeed) != slowrun_speed) cs_set_player_maxspeed_auto(id, slowrun_speed)
}
}
}
public client_connect(id)
{
g_had_sprint[id] = 1
g_can_use_sprint[id] = 0
g_using_sprint[id] = 0
g_sprint_status[id] = 0
}
public zp_fw_core_infect_post(id)
{
reset_all_item(id)
}
//public fw_PlayerSpawn_Post(id)
public zp_fw_gamemodes_start()
{
for(new id = 1; id <= get_maxplayers(); id++)
{
//HAM_IGNORED
if(!is_user_connected(id))
continue;
if(is_user_bot(id))
continue;
if (zp_core_is_zombie(id))
continue;
g_had_sprint[id] = 1
set_user_item_sprint(id)
}
}
public reset_all_item(id)
{
g_can_use_sprint[id] = 0
g_using_sprint[id] = 0
g_sprint_status[id] = 0
}
public set_user_item_sprint(id)
{
if(!is_user_alive(id))return
if(!g_had_sprint[id])return
g_can_use_sprint[id] = 1
g_using_sprint[id] = 0
g_sprint_status[id] = 0
//client_cmd(id, "bind F1 fastrun")
}
public do_fastrun(id)
{
if(!is_user_alive(id))return
if(g_can_use_sprint[id] && !g_using_sprint[id])
{
g_can_use_sprint[id] = 0
g_using_sprint[id] = 1
g_sprint_status[id] = 1
//message_begin(MSG_ONE_UNRELIABLE, g_Msg_ScreenFade, _, id)
//write_short(0) // duration
//write_short(0) // hold time
//write_short(0x0004) // fade type
//write_byte(255) // r
//write_byte(255) // g
//write_byte(255) // b
//write_byte(100) // alpha
//message_end()
fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 0)
message_begin(MSG_ONE_UNRELIABLE, g_MsgSetFOV, _, id)
write_byte(105)
message_end()
remove_task(id+TASK_REMOVE_FASTRUN)
set_task(fastrun_time, "task_remove_fastrun", id+TASK_REMOVE_FASTRUN)
cs_set_player_maxspeed_auto(id, fastrun_speed)
emit_sound(id, CHAN_AUTO, sound_fastrun_start, 1.0, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_AUTO, sound_fastrun_heartbeat, 1.0, ATTN_NORM, 0, PITCH_NORM)
set_task(1.0, "task_human_sound", id+TASK_HUMAN_SOUND, _, _, "b")
}
}
public fm_reset_user_speed(id)
{
if(!is_user_alive(id))return
new Float:MaxSpeed
switch(get_user_weapon(id))
{
case CSW_SG550, CSW_AWP, CSW_G3SG1: MaxSpeed = 210.0
case CSW_M249: MaxSpeed = 220.0
case CSW_AK47: MaxSpeed = 221.0
case CSW_M3, CSW_M4A1: MaxSpeed = 230.0
case CSW_SG552: MaxSpeed = 235.0
case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS: MaxSpeed = 240.0
case CSW_P90: MaxSpeed = 245.0
case CSW_SCOUT: MaxSpeed = 260.0
default: MaxSpeed = 250.0
}
cs_set_player_maxspeed_auto(id, MaxSpeed)
}
public task_human_sound(id)
{
id -= TASK_HUMAN_SOUND
if(!is_user_alive(id))return
if(!g_had_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if(!g_using_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if (g_sprint_status[id] == 1)
{
emit_sound(id, CHAN_VOICE, sound_fastrun_heartbeat, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
else if (g_sprint_status[id] == 2)
{
new sex, num = random_num(1, 100)
if (num & 1) sex = 2
else sex = 1
emit_sound(id, CHAN_VOICE, sex == 1 ? sound_breath_male : sound_breath_female, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
}
public task_remove_fastrun(id)
{
id -= TASK_REMOVE_FASTRUN
if(!is_user_alive(id))return
if(!g_had_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if(!g_using_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
//message_begin(MSG_ONE_UNRELIABLE, g_Msg_ScreenFade, _, id)
//write_short(0) // duration
//write_short(0) // hold time
//write_short(0x0004) // fade type
//write_byte(255) // r
//write_byte(255) // g
//write_byte(255) // b
//write_byte(0) // alpha
//message_end()
fm_set_rendering(id)
message_begin(MSG_ONE_UNRELIABLE, g_MsgSetFOV, _, id)
write_byte(90)
message_end()
g_sprint_status[id] = 2
remove_task(id+TASK_REMOVE_SLOWRUN)
set_task(slowrun_time, "task_remove_slowrun", id+TASK_REMOVE_SLOWRUN)
fm_reset_user_speed(id)
cs_set_player_maxspeed_auto(id, slowrun_speed)
}
public task_remove_slowrun(id)
{
id -= TASK_REMOVE_SLOWRUN
if(!is_user_alive(id))return
if(!g_had_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if(!g_using_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
g_sprint_status[id] = 0
g_using_sprint[id] = 0
fm_reset_user_speed(id)
}
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <cs_maxspeed_api>
#include <zp50_class_zombie>
#include <zp50_core>
// Configs
const Float:fastrun_time = 10.0
const Float:fastrun_speed = 400.0
const Float:slowrun_time = 5.0
const Float:slowrun_speed = 140.0
new g_had_sprint[33], g_can_use_sprint[33], g_using_sprint[33], g_sprint_status[33]
new g_Msg_ScreenFade
new const sound_fastrun_start[] = "Zombie_Thehero/speedup.wav"
new const sound_fastrun_heartbeat[] = "Zombie_Thehero/speedup_heartbeat.wav"
new const sound_breath_male[] = "Zombie_Thehero/human_breath_male.wav"
new const sound_breath_female[] = "Zombie_Thehero/human_breath_female.wav"
#define TASK_REMOVE_FASTRUN 59384543
#define TASK_REMOVE_SLOWRUN 5893485
#define TASK_HUMAN_SOUND 53450834
new g_MsgSetFOV
public plugin_init()
{
//register_clcmd("run", "run")
register_clcmd("wohenni", "do_fastrun")
//RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
g_Msg_ScreenFade = get_user_msgid("ScreenFade")
g_MsgSetFOV = get_user_msgid("SetFOV")
}
public plugin_precache()
{
precache_sound(sound_fastrun_start)
precache_sound(sound_fastrun_heartbeat)
precache_sound(sound_breath_male)
precache_sound(sound_breath_female)
}
public client_PostThink(id)
{
if(!is_user_alive(id))return
if(g_had_sprint[id] && g_using_sprint[id])
{
if(g_sprint_status[id] == 1)
{
if(pev(id, pev_maxspeed) != fastrun_speed) cs_set_player_maxspeed_auto(id, fastrun_speed)
} else if(g_sprint_status[id] == 2) {
if(pev(id, pev_maxspeed) != slowrun_speed) cs_set_player_maxspeed_auto(id, slowrun_speed)
}
}
}
public client_connect(id)
{
g_had_sprint[id] = 1
g_can_use_sprint[id] = 0
g_using_sprint[id] = 0
g_sprint_status[id] = 0
}
public zp_fw_core_infect_post(id)
{
reset_all_item(id)
}
//public fw_PlayerSpawn_Post(id)
public zp_fw_gamemodes_start()
{
for(new id = 1; id <= get_maxplayers(); id++)
{
//HAM_IGNORED
if(!is_user_connected(id))
continue;
if(is_user_bot(id))
continue;
if (zp_core_is_zombie(id))
continue;
g_had_sprint[id] = 1
set_user_item_sprint(id)
}
}
public reset_all_item(id)
{
g_can_use_sprint[id] = 0
g_using_sprint[id] = 0
g_sprint_status[id] = 0
}
public set_user_item_sprint(id)
{
if(!is_user_alive(id))return
if(!g_had_sprint[id])return
g_can_use_sprint[id] = 1
g_using_sprint[id] = 0
g_sprint_status[id] = 0
//client_cmd(id, "bind F1 fastrun")
}
public do_fastrun(id)
{
if(!is_user_alive(id))return
if(g_can_use_sprint[id] && !g_using_sprint[id])
{
g_can_use_sprint[id] = 0
g_using_sprint[id] = 1
g_sprint_status[id] = 1
//message_begin(MSG_ONE_UNRELIABLE, g_Msg_ScreenFade, _, id)
//write_short(0) // duration
//write_short(0) // hold time
//write_short(0x0004) // fade type
//write_byte(255) // r
//write_byte(255) // g
//write_byte(255) // b
//write_byte(100) // alpha
//message_end()
fm_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 0)
message_begin(MSG_ONE_UNRELIABLE, g_MsgSetFOV, _, id)
write_byte(105)
message_end()
remove_task(id+TASK_REMOVE_FASTRUN)
set_task(fastrun_time, "task_remove_fastrun", id+TASK_REMOVE_FASTRUN)
cs_set_player_maxspeed_auto(id, fastrun_speed)
emit_sound(id, CHAN_AUTO, sound_fastrun_start, 1.0, ATTN_NORM, 0, PITCH_NORM)
emit_sound(id, CHAN_AUTO, sound_fastrun_heartbeat, 1.0, ATTN_NORM, 0, PITCH_NORM)
set_task(1.0, "task_human_sound", id+TASK_HUMAN_SOUND, _, _, "b")
}
}
public fm_reset_user_speed(id)
{
if(!is_user_alive(id))return
new Float:MaxSpeed
switch(get_user_weapon(id))
{
case CSW_SG550, CSW_AWP, CSW_G3SG1: MaxSpeed = 210.0
case CSW_M249: MaxSpeed = 220.0
case CSW_AK47: MaxSpeed = 221.0
case CSW_M3, CSW_M4A1: MaxSpeed = 230.0
case CSW_SG552: MaxSpeed = 235.0
case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS: MaxSpeed = 240.0
case CSW_P90: MaxSpeed = 245.0
case CSW_SCOUT: MaxSpeed = 260.0
default: MaxSpeed = 250.0
}
cs_set_player_maxspeed_auto(id, MaxSpeed)
}
public task_human_sound(id)
{
id -= TASK_HUMAN_SOUND
if(!is_user_alive(id))return
if(!g_had_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if(!g_using_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if (g_sprint_status[id] == 1)
{
emit_sound(id, CHAN_VOICE, sound_fastrun_heartbeat, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
else if (g_sprint_status[id] == 2)
{
new sex, num = random_num(1, 100)
if (num & 1) sex = 2
else sex = 1
emit_sound(id, CHAN_VOICE, sex == 1 ? sound_breath_male : sound_breath_female, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
}
public task_remove_fastrun(id)
{
id -= TASK_REMOVE_FASTRUN
if(!is_user_alive(id))return
if(!g_had_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if(!g_using_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
//message_begin(MSG_ONE_UNRELIABLE, g_Msg_ScreenFade, _, id)
//write_short(0) // duration
//write_short(0) // hold time
//write_short(0x0004) // fade type
//write_byte(255) // r
//write_byte(255) // g
//write_byte(255) // b
//write_byte(0) // alpha
//message_end()
fm_set_rendering(id)
message_begin(MSG_ONE_UNRELIABLE, g_MsgSetFOV, _, id)
write_byte(90)
message_end()
g_sprint_status[id] = 2
remove_task(id+TASK_REMOVE_SLOWRUN)
set_task(slowrun_time, "task_remove_slowrun", id+TASK_REMOVE_SLOWRUN)
fm_reset_user_speed(id)
cs_set_player_maxspeed_auto(id, slowrun_speed)
}
public task_remove_slowrun(id)
{
id -= TASK_REMOVE_SLOWRUN
if(!is_user_alive(id))return
if(!g_had_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
if(!g_using_sprint[id])
{
remove_task(id+TASK_HUMAN_SOUND)
return
}
g_sprint_status[id] = 0
g_using_sprint[id] = 0
fm_reset_user_speed(id)
}