#include <amxmodx>
#include <reapi>
native zp_infect_user(id, infector = 0, silent = 0, rewards = 0);
native zp_override_user_model(id, const newmodel[], modelindex = 0);
/* Game modes for zp_round_started() */
enum
{
MODE_INFECTION = 1,
MODE_NEMESIS,
MODE_ASSASSIN,
MODE_SURVIVOR,
MODE_SNIPER,
MODE_SWARM,
MODE_MULTI,
MODE_PLAGUE,
MODE_ARMAGEDDON,
MODE_APOCALYPSE,
MODE_NIGHTMARE
}
new const g_szTag[] = "WebAilesi";
new const g_szDeathSoundFile[] = "xxx.wav"; /* Olunce calar sound/xxx.wav */
new const g_szJumpSoundFile[] = "xxx.wav"; /* Yetenek atinca calar sound/xxx.wav */
new const g_szInfectedSoundFile[] = "xxx.wav"; /* Secilince calar sound/xxx.wav */
new const g_szNewPlayerModel[] = "ModelIsmi"; /* models/player/ModelIsmi/ModelIsmi.mdl */
new const g_szKnifeModel[] = "models/v_bicak.mdl"; /* Zombinin elindeki bicak */
new bool:g_iPicked[33], bool:g_iCoolDown[33];
public plugin_init()
{
register_plugin("Random Zombie", "0.1", "LyNcH");
register_event("CurWeapon", "CurWeapon", "be");
RegisterHookChain(RG_CBasePlayer_PreThink, "PreThink", .post = true);
RegisterHookChain(RG_CBasePlayer_Killed, "PlayerKilled", .post = true);
RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "DefaultDeploy", .post = false);
}
public plugin_precache()
{
precache_sound(g_szDeathSoundFile);
precache_sound(g_szJumpSoundFile);
precache_sound(g_szInfectedSoundFile);
precache_model(fmt("models/player/%s/%s.mdl", g_szNewPlayerModel, g_szNewPlayerModel));
precache_model(g_szKnifeModel);
}
public client_putinserver(id)
{
g_iPicked[id] = false;
g_iCoolDown[id] = false;
}
public client_disconnected(id)
{
g_iPicked[id] = false;
g_iCoolDown[id] = false;
}
public zp_round_started(gamemode, id)
{
if(gamemode == MODE_NEMESIS || gamemode == MODE_ASSASSIN || gamemode == MODE_SNIPER) return; /* En ust kisimdan bakarak calismasini istemediginiz modlari yazabilirsiniz */
new Players[32], iNum, iRandomPlayer;
get_players(Players, iNum, "ah");
if(iNum < 1) return;
iRandomPlayer = Players[random_num(0, iNum-1)];
zp_infect_user(iRandomPlayer, 0, 1, 0);
zp_override_user_model(iRandomPlayer, g_szNewPlayerModel);
g_iPicked[iRandomPlayer] = true;
g_iCoolDown[iRandomPlayer] = false;
emit_sound(iRandomPlayer, CHAN_AUTO, g_szInfectedSoundFile, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
client_print_color(0,0, "^1[^3%s^1] ^4%n adli oyuncu zombi oldu.", g_szTag, iRandomPlayer);
client_print_color(iRandomPlayer,iRandomPlayer, "^1[^3%s^1] ^4CTRL + E basarak uzun atlama yetenegini kullanabilirsin.", g_szTag);
}
public PlayerKilled(iVictim, iAttacker)
{
if(!is_user_connected(iVictim) || !g_iPicked[iVictim]) return;
g_iPicked[iVictim] = false;
client_print_color(0,0, "^1[^3%s^1] ^4%n adli oyuncu zombi olduruldu.", g_szTag, iVictim);
emit_sound(iVictim, CHAN_AUTO, g_szDeathSoundFile, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
public DefaultDeploy(const ent, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal)
{
new id = get_member(ent, m_pPlayer);
if(get_member(ent, m_iId) != WEAPON_KNIFE)
{
return;
}
if(!is_user_alive(id) || !g_iPicked[id])
{
return;
}
SetHookChainArg(2, ATYPE_STRING, g_szKnifeModel);
}
public CurWeapon(const id)
{
if(g_iPicked[id])
{
set_entvar(id, var_maxspeed, 500.0);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public PreThink(const id)
{
if(!g_iPicked[id]) return;
if(!is_user_alive(id)) return; /* Sadece tek bir oyuncuyu sorguladigi icin is_user_alive kullandim yoksa degiskene atanir */
static iButton; iButton = get_entvar(id, var_button);
static iOldButton; iOldButton = get_entvar(id, var_oldbuttons);
if((iButton & IN_USE) && (iButton & IN_DUCK) && !(iOldButton & IN_USE) && !g_iCoolDown[id])
{
static Float:fVelocity[3];
velocity_by_aim(id, 700, fVelocity);
set_entvar(id, var_velocity, fVelocity);
emit_sound(id, CHAN_AUTO, g_szJumpSoundFile, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
g_iCoolDown[id] = true;
set_task(5.0, "ResetCooldown", id);
}
}
public ResetCooldown(id)
{
if(is_user_connected(id))
{
g_iCoolDown[id] = false;
client_print_color(id,id, "^1[^3%s^1] ^4Yetenek bekleme suresi bitti.", g_szTag);
client_print_color(id,id, "^1[^3%s^1] ^4CTRL + E basarak uzun atlama yetenegini kullanabilirsin.", g_szTag);
}
}