求生之路2玩家复活、自杀插件 l4d2_fuhuo_zisha 插件源码 l4d2_fuhuo_zisha.sp l4d2_fuhuo_zisha.smx。求生之路2,l4d,l4d2,SourceMOD 插件源码。
之前服务器要用,自己写的一东西,现在把源码发出来,注释写的比较清楚,很简单,自己看看。
说明:
控制台变量:l4d2_fuhuo_zisha_enable
0:关闭复活功能 (默认)
1:开启复活功能
用法:
聊天框输入:
!fuhuo,复活自己,平时不允许使用,进行跳跃地图时启用。
!zisha,自杀,人物卡住或者其他情况时使用。
!jump,开关复活功能,输一次开启,再输一次关闭,聊天框有提示,仅插件管理员可用。
/*
求生之路2玩家复活、自杀插件
Time: 2011-9-10 19:33:16
By: Nuclear'Atk
Url: https://lcx.cc/post/2138/
*/
#include <sourcemod>
//#include <sdktools>
new Handle:l4d2_fuhuo_zisha_enable; //是否启用复活功能
public Plugin:myinfo =
{
name = "求生之路2玩家复活、自杀插件",
author = "春哥",
description = "求生之路2玩家复活、自杀插件,玩家可以自定义各种游戏存在的模型。",
version = "1.0",
url = "https://lcx.cc/"
}
public OnPluginStart()
{
//创建控制台变量:l4d2_fuhuo_zisha_enable
l4d2_fuhuo_zisha_enable = CreateConVar("l4d2_fuhuo_zisha_enable", "0", "0:关闭复活功能 1:开启复活功能", FCVAR_PLUGIN);
//注册控制台命令
RegConsoleCmd("sm_fuhuo", Set_FuHuo, "求生之路2玩家复活、自杀插件");
RegConsoleCmd("sm_zisha", Set_ZiSha, "求生之路2玩家复活、自杀插件");
RegConsoleCmd("sm_jump", Set_Jump, "开启、禁用复活功能");
//钩住玩家死亡事件
HookEvent("player_death", Player_Dead);
}
public Action:Set_FuHuo(client, args) //复活
{
if (GetConVarInt(l4d2_fuhuo_zisha_enable)==1) //是否启用复活功能
{
ServerCommand("sm_respawn \"%N\"", client); //执行服务器指令
PrintToChatAll("信春哥得永生,玩家 %N 已成功满血、满状态复活!", client);
PrintHintText(client, "信春哥得永生,你已成功满血、满状态复活!");
}
else
{
PrintHintText(client, "当前不允许使用复活功能!");
}
return Plugin_Handled; //返回函数
}
public Action:Set_ZiSha(client, args) //自杀
{
ServerCommand("sm_slay \"%N\"", client); //执行服务器指令
PrintToChatAll("恭喜玩家 %N 成功自杀!", client);
PrintHintText(client, "恭喜你,自杀成功!");
return Plugin_Handled; //返回函数
}
public Action:Set_Jump(client, args) //开启、关闭复活功能
{
if (GetUserFlagBits(client)!=0) //判断是否是管理
{
if (GetConVarInt(l4d2_fuhuo_zisha_enable)==1) //如果启用了复活功能
{
ServerCommand("l4d2_fuhuo_zisha_enable 0");
PrintToChat(client, "已禁用复活功能!");
}
else
{
ServerCommand("l4d2_fuhuo_zisha_enable 1");
PrintToChat(client, "已启用复活功能!");
}
}
else
{
PrintToChat(client, "只有管理员可以使用本功能!");
}
return Plugin_Handled; //返回函数
}
public Action:Player_Dead(Handle:event, const String:name[], bool:dontBroadcast) //玩家死亡事件
{
if (GetConVarInt(l4d2_fuhuo_zisha_enable)==1) //如果启用了复活功能
{
new client = GetClientOfUserId(GetEventInt(event, "userid")); //获取玩家名字
if(client > 0)
{
if(!IsFakeClient(client)) //判断是否是电脑玩家
{
PrintHintText(client, "按Y或U打开聊天框,输入:!fuhuo,复活自己!");
}
}
}
}