|
#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
new bool:g_canRespawn[33]
new time_s[33]
new cvar_chongsheng,cvar_killdeath,cvar_vipdeath
public plugin_init()
{
register_plugin("[重生]", "6.0", "123")
register_event("DeathMsg", "Event_DeathMsg", "a")
register_event("DeathMsg", "Death", "a")
cvar_chongsheng = register_cvar("zp_chongsheng", "15")
cvar_killdeath = register_cvar("zp_killdeath", "10")
cvar_vipdeath = register_cvar("zp_vipdeath","5")
}
public Death()
{
new victim = read_data(2)
if(!g_canRespawn[victim]) {
time_s[victim] = get_pcvar_num(cvar_chongsheng)
set_task(0.0+get_pcvar_num(cvar_chongsheng),"respawn_player",victim)
read_times(victim)
}
}
public client_connect(id)
{
g_canRespawn[id] = false
}
public client_disconnect(id)
{
g_canRespawn[id] = false
}
public check_time(id)
{
if(get_user_flags(id) & ADMIN_USER && g_canRespawn[id]) {
time_s[id] = get_pcvar_num(cvar_killdeath)
read_times(id)
}
if(get_user_flags(id) & ADMIN_MENU && g_canRespawn[id]) {
time_s[id] = get_pcvar_num(cvar_vipdeath)
read_times(id)
}
}
public read_times(id) {
if(!is_user_alive(id)) {
client_print(id, print_center,"你将在 %i 秒后复活",time_s[id])
--time_s[id]
if(time_s[id] >= 1) {
set_task(1.0,"read_times",id)
} }
}
public Event_DeathMsg()
{
new attacker = read_data(1)
new victim = read_data(2)
if(!is_user_connected(attacker) || !is_user_connected(victim)) {
return PLUGIN_CONTINUE
}
if(attacker != victim)
{
if(get_user_flags(victim) & ADMIN_USER) {
set_task(get_pcvar_num(cvar_killdeath) + 0.0,"respawn_player",victim)
g_canRespawn[victim] = true
check_time(victim)
}
if(get_user_flags(victim) & ADMIN_MENU) {
set_task(get_pcvar_num(cvar_vipdeath) + 0.0,"respawn_player",victim)
g_canRespawn[victim] = true
check_time(victim)
}
}
return PLUGIN_CONTINUE
}
public respawn_player(id)
{
if(is_user_alive(id))
return PLUGIN_CONTINUE
ExecuteHamB(Ham_CS_RoundRespawn, id)
new name[32]
get_user_name(id, name, 31)
if(!zp_is_nemesis_round() || !zp_is_plague_round()) {
server_cmd("zp_zombie %s", name)
}
g_canRespawn[id] = false
return PLUGIN_CONTINUE
}
public client_putinserver(id) {
client_print(0, print_chat, "服务器采用无限重生插件")
} |
|