level 13
/*
* 自动重生插件V0.3
* (使用fakemeta模块)
* 在Amxx.cfg中输入
* lein_respawn 1 插件开启/0关闭
* lein_spawn_delay 3.0 重生延迟时间
* lein.ys168.com
*/
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
new cvar_spawn_delay
public plugin_init()
{
register_plugin("lein_respawn","0.3","lein")
register_event("DeathMsg","deathmsg","a")
register_cvar("lein_respawn","0")
cvar_spawn_delay = register_cvar("lein_spawn_delay","3.0") // 获取写在Amxx.cfg里的延迟时间
}
public deathmsg()
{
if (get_cvar_num("lein_respawn") == 1) //如果lein_respawn的值为1,则。。。
{
set_task(get_pcvar_float(cvar_spawn_delay), "respawn_player", read_data(2))
// 事件DeathMsg返回的第二个数据read_data(2) 就是被杀者id
// 用set_task设置延时及传递获取到的任务id给"respawn_player"这个public!
}
return PLUGIN_CONTINUE //否则退出public “deathmsg”
}
public respawn_player(id)
{
// Disconnected, already spawned, or switched to Spectator
// 这里是几个判断,判断玩家如果没有连接&还或者&是观察者,则return这个public,即不执行后面参数,防插件出错!
if (!is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
return;
// (Debug only)
// client_print(0, print_chat, "Player %d is being respawned", id)
// Try to spawn the player setting the appropiate dead flag and forcing a think
//使用fakemeta模块对玩家进行重生!
set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
dllfunc(DLLFunc_Think, id)
// Fix for CZ Bots: DLLFunc_Think won't work on them,
// but DLLFunc_Spawn does the job without any bugs.
// (for some reason I'm not suprised...)
//下面是针对ZBOT的fix,因为fakemeta模块了的 DLLFunc_Think对Zbot不起作用,但是DLLFunc_Spawn可以!
if (is_user_bot(id) && pev(id, pev_deadflag) == DEAD_RESPAWNABLE)
{
dllfunc(DLLFunc_Spawn, id)
}
}
2013年03月20日 05点03分