07/01/2022, 04:35 PM
para los servidores knife con respawn (35hp, 1hp)
Código PHP:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <engine>
new on_protect[33]
new cvar_mode
new hp1 = false
new hp35 = false
public plugin_init()
{
register_plugin("Knife spawn protect", "1.0", "Nelo")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
cvar_mode = register_cvar("knife_mode", "0")
new mapname[64]
get_mapname(mapname,charsmax(mapname))
if(contain(mapname,"35hp") != -1)
{
hp35 = true
hp1 = false
}
else if(contain(mapname,"1hp") != -1)
{
hp1 = true
hp35 = false
}
new entname[64]
new entcount = entity_count()
for (new id = 33; id < entcount; id++)
{
if(!is_valid_ent(id))
continue;
entity_get_string(id, EV_SZ_classname, entname, 64)
if (equali(entname, "game_player_hurt"))
remove_entity(id)
}
}
public plugin_cfg()
set_pcvar_num(cvar_mode, 0)
public fw_PlayerSpawn_Post(id)
{
if(!is_user_alive(id))
return
on_protect[id] = 1
set_user_rendering(id,kRenderFxGlowShell,0,255,0,kRenderNormal,25)
set_user_godmode(id, 1)
}
public remove_protect(id)
{
if(!get_pcvar_num(cvar_mode))
{
if(hp35)
set_user_health(id, 35)
else if(hp1)
set_user_health(id, 1)
}
else
{
if(get_pcvar_num(cvar_mode) == 1)
set_user_health(id, 1)
else if(get_pcvar_num(cvar_mode) == 2)
set_user_health(id, 35)
else if(get_pcvar_num(cvar_mode) >= 3)
set_user_health(id, 100)
}
on_protect[id] = 0
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25)
set_user_godmode(id, 0)
screenfade(id)
}
public client_disconnect(id)
{
remove_task(id)
on_protect[id] = 0
}
public client_PreThink(id)
{
if(is_user_alive(id) && on_protect[id])
{
new flags = entity_get_int(id, EV_INT_flags)
new onground = flags & FL_ONGROUND
if(onground && !task_exists(id))
set_task(0.5, "remove_protect", id)
}
}
screenfade(id)
{
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(0)
write_byte(200)
write_byte(0)
write_byte(75)
message_end()
}
Aportes: