求生之路2复活及传送玩家插件 l4d_sm_respawn 插件源码 l4d_sm_respawn.sp l4d_sm_respawn.smx。求生之路2,l4d,l4d2,SourceMOD 插件源码。
官网:https://forums.alliedmods.net/showthread.php?t=96249
#pragma semicolon 1 #include <sourcemod> #include <sdktools> #define PLUGIN_VERSION "1.9.3" public Plugin:myinfo = { name = "L4D SM Respawn", author = "AtomicStryker & Ivailosp", description = "Let's you respawn Players by console", version = PLUGIN_VERSION, url = "http://forums.alliedmods.net/showthread.php?t=96249" } static Float:g_pos[3]; static Handle:hRoundRespawn = INVALID_HANDLE; static Handle:hBecomeGhost = INVALID_HANDLE; static Handle:hState_Transition = INVALID_HANDLE; static Handle:hGameConf = INVALID_HANDLE; public OnPluginStart() { decl String:game_name[24]; GetGameFolderName(game_name, sizeof(game_name)); if (!StrEqual(game_name, "left4dead2", false) && !StrEqual(game_name, "left4dead", false)) { SetFailState("Plugin supports Left 4 Dead and L4D2 only."); } LoadTranslations("common.phrases"); hGameConf = LoadGameConfigFile("l4drespawn"); CreateConVar("l4d_sm_respawn_version", PLUGIN_VERSION, "L4D SM Respawn Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_NOTIFY); RegAdminCmd("sm_respawn", Command_Respawn, ADMFLAG_BAN, "sm_respawn <player1> [player2] ... [playerN] - respawn all listed players and teleport them where you aim"); if (hGameConf != INVALID_HANDLE) { StartPrepSDKCall(SDKCall_Player); PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "RoundRespawn"); hRoundRespawn = EndPrepSDKCall(); if (hRoundRespawn == INVALID_HANDLE) SetFailState("L4D_SM_Respawn: RoundRespawn Signature broken"); StartPrepSDKCall(SDKCall_Player); PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "BecomeGhost"); PrepSDKCall_AddParameter(SDKType_PlainOldData , SDKPass_Plain); hBecomeGhost = EndPrepSDKCall(); if (hBecomeGhost == INVALID_HANDLE && StrEqual(game_name, "left4dead2", false)) LogError("L4D_SM_Respawn: BecomeGhost Signature broken"); StartPrepSDKCall(SDKCall_Player); PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "State_Transition"); PrepSDKCall_AddParameter(SDKType_PlainOldData , SDKPass_Plain); hState_Transition = EndPrepSDKCall(); if (hState_Transition == INVALID_HANDLE && StrEqual(game_name, "left4dead2", false)) LogError("L4D_SM_Respawn: State_Transition Signature broken"); } else { SetFailState("could not find gamedata file at addons/sourcemod/gamedata/l4drespawn.txt , you FAILED AT INSTALLING"); } } public Action:Command_Respawn(client, args) { if (args < 1) { ReplyToCommand(client, "[SM] Usage: sm_respawn <player1> [player2] ... [playerN] - respawn all listed players"); return Plugin_Handled; } decl String:arg1[MAX_TARGET_LENGTH]; decl String:target_name[MAX_TARGET_LENGTH]; new target_list[MAXPLAYERS]; new target_count; new bool:tn_is_ml; GetCmdArg(1, arg1, sizeof(arg1)); if ((target_count = ProcessTargetString( arg1, client, target_list, MAXPLAYERS, 0, // no filtering target_name, sizeof(target_name), tn_is_ml)) <= 0) { /* This function replies to the admin with a failure message */ ReplyToTargetError(client, target_count); return Plugin_Handled; } for (new i = 0; i < target_count; i++) { RespawnPlayer(client, target_list[i]); } ShowActivity2(client, "[SM] ", "Respawned target '%s'", target_name); return Plugin_Handled; } static RespawnPlayer(client, player_id) { switch(GetClientTeam(player_id)) { case 2: { new bool:canTeleport = SetTeleportEndPoint(client); SDKCall(hRoundRespawn, player_id); CheatCommand(player_id, "give", "first_aid_kit"); CheatCommand(player_id, "give", "smg"); if(canTeleport) { PerformTeleport(client,player_id,g_pos); } } case 3: { decl String:game_name[24]; GetGameFolderName(game_name, sizeof(game_name)); if (StrEqual(game_name, "left4dead", false)) return; SDKCall(hState_Transition, player_id, 8); SDKCall(hBecomeGhost, player_id, 1); SDKCall(hState_Transition, player_id, 6); SDKCall(hBecomeGhost, player_id, 1); } } } public bool:TraceEntityFilterPlayer(entity, contentsMask) { return entity > MaxClients || !entity; } static bool:SetTeleportEndPoint(client) { decl Float:vAngles[3], Float:vOrigin[3]; GetClientEyePosition(client,vOrigin); GetClientEyeAngles(client, vAngles); //get endpoint for teleport new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer); if(TR_DidHit(trace)) { decl Float:vBuffer[3], Float:vStart[3]; TR_GetEndPosition(vStart, trace); GetVectorDistance(vOrigin, vStart, false); new Float:Distance = -35.0; GetAngleVectors(vAngles, vBuffer, NULL_VECTOR, NULL_VECTOR); g_pos[0] = vStart[0] + (vBuffer[0]*Distance); g_pos[1] = vStart[1] + (vBuffer[1]*Distance); g_pos[2] = vStart[2] + (vBuffer[2]*Distance); } else { PrintToChat(client, "[SM] %s", "Could not teleport player after respawn"); CloseHandle(trace); return false; } CloseHandle(trace); return true; } PerformTeleport(client, target, Float:pos[3]) { pos[2]+=40.0; TeleportEntity(target, pos, NULL_VECTOR, NULL_VECTOR); LogAction(client,target, "\"%L\" teleported \"%L\" after respawning him" , client, target); } stock CheatCommand(client, String:command[], String:arguments[]="") { new userflags = GetUserFlagBits(client); SetUserFlagBits(client, ADMFLAG_ROOT); new flags = GetCommandFlags(command); SetCommandFlags(command, flags & ~FCVAR_CHEAT); FakeClientCommand(client, "%s %s", command, arguments); SetCommandFlags(command, flags); SetUserFlagBits(client, userflags); }
// This file was auto-generated by SourceMod (v1.3.7-dev) // ConVars for plugin "sm_respawn.smx" // L4D(2) Respawn Version // - // Default: "2.0.1" l4d_sm_respawn_version "2.0.1" // 0:关闭; 1:复活玩家后给予药丸; 2:复活后给予肾上腺素 // - // Default: "0" // Minimum: "0.000000" // Maximum: "2.000000" respawn_give_medicine "2" // 0:关闭; 1:复活玩家后给予药包 // - // Default: "0" // Minimum: "0.000000" // Maximum: "1.000000" respawn_give_medkit "1"
在admin top menu 内显示复活/传送, 选择功能后, 会显示玩家清单以供复活或传送
smx插件放入:X:\left4dead2\addons\sourcemod\plugins
txt文件放入:X:\left4dead2\addons\sourcemod\gamedata
输入!admin 或/admin 显示之admin top menu (管理员管理选单)内,
会增加了一项 [复活/传送]
然后可选择 复活玩家 或 传送玩家
选择后会有一个在线玩家及电脑BOT清单
复活玩家: 任意地复活死去玩家或电脑BOT至管理员准星位置
传召玩家: 保留玩家身上装备地传送至管理员准星位置
移形换影: 将名单一的玩家传送至名单二身边, 选择后会先显示名单一, 然后名单二
新增 sm_respawn.cfg, 可修改参数如下:
// 0:关闭; 1:复活玩家后给予药丸; 2:复活后给予肾上腺素 // - // Default: "0" // Minimum: "0.000000" // Maximum: "2.000000" respawn_give_medicine "0" // 0:关闭; 1:复活玩家后给予药包 // - // Default: "0" // Minimum: "0.000000" // Maximum: "1.000000" respawn_give_medkit "0"
已知Bug:
假如选择者(管理员)复活自己会被传到地图之起点, 可用移形换影传回至同伴身边
管理员复活任何人(不包括自己), 都可复活至管理员之准星位置
下载地址:http://115.com/file/an480cyj,解压密码:fuck115!