- UID
- 2402564
- 主题
- 0
- 阅读权限
- 20
- 帖子
- 20
- 精华
- 0
- 积分
- 10
- 金钱
- 140
- 荣誉
- 0
- 人气
- 0
- 在线时间
- 19 小时
- 评议
- 0
- 帖子
- 20
- 精华
- 0
- 积分
- 10
- 金钱
- 140
- 荣誉
- 0
- 人气
- 0
- 评议
- 0
|
玩了那么久除了红外其他的基本是多余的,所以想找个只有红外线的插件
如果没的话看下可不可以帮我把下面的技能都关了只留红外
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Survivor Upgrades - A modification for the game Left4Dead */
/* Note: The upgrades were created by Valve - this mod simply makes them available. */
/* Version History
* 1.0
* -Initial release.
* 1.1
* - Filtered out #L4D_Upgrade_laser_sight_expire text broadcast when turning off a laser.
* - Added cvars to allow disabling of specific upgrades. (Hot Meal is disabled, by default.)
* - Added verbosity cvar. 0 for no messages, 1 for expire events only, 2 for expire events
* and short self messages, 3 for everything.
* - Added potential fix for bots taking over for players getting upgrades.
*/
#include <sourcemod>
#include <sdktools>
#define NUPGRADES 31
#define NVALID 14
#define PLUGIN_VERSION "1.1"
#define PLUGIN_NAME "Survivor Upgrades"
#define PLUGIN_TAG "[SurUp]"
//CTerrorPlayer::AddUpgrade(SurvivorUpgradeType)
//_ZN13CTerrorPlayer10AddUpgradeE19SurvivorUpgradeType
new Handle:AddUpgrade = INVALID_HANDLE;
//CTerrorPlayer::RemoveUpgrade(SurvivorUpgradeType)
//_ZN13CTerrorPlayer13RemoveUpgradeE19SurvivorUpgradeType
new Handle:RemoveUpgrade = INVALID_HANDLE;
//CTerrorPlayer::GiveRandomUpgrade()
//_ZN13CTerrorPlayer17GiveRandomUpgradeEv
new Handle:GiveRandomUpgrade = INVALID_HANDLE;
new bool:bHooked = false;
new bool:bUpgraded[MAXPLAYERS+1];
new bool:bBotControlled[MAXPLAYERS+1];
new IndexToUpgrade[NVALID];
new bool:bClientHasUpgrade[MAXPLAYERS+1][NVALID];
new String:UpgradeShortInfo[NVALID][256];
new String:UpgradeLongInfo[NVALID][1024];
new Handle:UpgradeAllowed[NVALID];
new Handle:AlwaysLaser = INVALID_HANDLE;
new Handle:UpgradesAtSpawn = INVALID_HANDLE;
new Handle:UpgradesAtWitchKillKiller = INVALID_HANDLE;
new Handle:UpgradesAtWitchKillAll = INVALID_HANDLE;
new Handle:UpgradesAtTankSpawn = INVALID_HANDLE;
new Handle:UpgradesAtTankKillKiller = INVALID_HANDLE;
new Handle:UpgradesAtTankKillAll = INVALID_HANDLE;
new Handle:Verbosity = INVALID_HANDLE;
new bool:bBlockUntilRoundStart;
new UserMsg:sayTextMsgId;
public OnPluginStart()
{
// Try the windows version first.
StartPrepSDKCall(SDKCall_Player);
if (!PrepSDKCall_SetSignature(SDKLibrary_Server, "\xA1****\x83***\x57\x8B\xF9\x0F*****\x8B***\x56\x51\xE8****\x8B\xF0\x83\xC4\x04", 34))
{
PrepSDKCall_SetSignature(SDKLibrary_Server, "@_ZN13CTerrorPlayer10AddUpgradeE19SurvivorUpgradeType", 0);
}
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByValue);
AddUpgrade = EndPrepSDKCall();
StartPrepSDKCall(SDKCall_Player);
if (!PrepSDKCall_SetSignature(SDKLibrary_Server, "\x51\x53\x55\x8B***\x8B\xD9\x56\x8B\xCD\x83\xE1\x1F\xBE\x01\x00\x00\x00\x57\xD3\xE6\x8B\xFD\xC1\xFF\x05\x89***", 32))
{
PrepSDKCall_SetSignature(SDKLibrary_Server, "@_ZN13CTerrorPlayer13RemoveUpgradeE19SurvivorUpgradeType", 0);
}
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByValue);
RemoveUpgrade = EndPrepSDKCall();
StartPrepSDKCall(SDKCall_Player);
if (!PrepSDKCall_SetSignature(SDKLibrary_Server, "\x83\xEC\x18\xA1****\x56\x33\xF6\x39\x70\x30\x89***\x0F*****\x53\x55\x57\x33\xED\x33\xDB\x33\xFF", 33))
{
PrepSDKCall_SetSignature(SDKLibrary_Server, "@_ZN13CTerrorPlayer17GiveRandomUpgradeEv", 0);
}
GiveRandomUpgrade = EndPrepSDKCall();
IndexToUpgrade[0] = 1;
UpgradeShortInfo[0] = "護身裝甲 - (受到更少傷害)";
UpgradeLongInfo[0] = "當你穿上裝甲, 感染者攻擊對你造成更少傷害";
UpgradeAllowed[0] = CreateConVar("surup_allow_kevlar_body_armor", "1", "能否得到護身裝甲", FCVAR_PLUGIN);
IndexToUpgrade[1] = 8;
UpgradeShortInfo[1] = "雨衣 - (擋住BOOMER的嘔吐物) [即用即棄]";
UpgradeLongInfo[1] = "這件雨衣用來擋住BOOMER的嘔吐物, 可惜雨衣會被侵食, 不能再用了";
UpgradeAllowed[1] = CreateConVar("surup_allow_raincoat", "1", "能否得到雨衣", FCVAR_PLUGIN);
IndexToUpgrade[2] = 11;
UpgradeShortInfo[2] = "防滑粉 - (掛牆自救) [即用即棄]";
UpgradeLongInfo[2] = "攀登專用的粉, 防止手滑一下以致空中飛人, 可惜這點份量只可以使用一次";
UpgradeAllowed[2] = CreateConVar("surup_allow_climbing_chalk", "1", "能否得到防滑粉", FCVAR_PLUGIN);
IndexToUpgrade[3] = 12;
UpgradeShortInfo[3] = "怪風 - (倒地自救) [即用即棄]";
UpgradeLongInfo[3] = "恭喜你, 當你倒地時會有一陣怪風助你站起來, 注意中途受到攻擊的話又會再倒下去";
UpgradeAllowed[3] = CreateConVar("surup_allow_second_wind", "1", "能否得到怪風幫助", FCVAR_PLUGIN);
IndexToUpgrade[4] = 13;
UpgradeShortInfo[4] = "護目鏡 - (防止BOOMER將嘔吐物降低視力)";
UpgradeLongInfo[4] = "即使被BOOMER噴到全身濕透, 雙眼依然清楚見到一切, 可是感染者依然會追打你!";
UpgradeAllowed[4] = CreateConVar("surup_allow_goggles", "1", "能否得到護目鏡", FCVAR_PLUGIN);
IndexToUpgrade[5] = 16;
UpgradeShortInfo[5] = "聖誕大餐 - (額外血量) [即時生效]";
UpgradeLongInfo[5] = "吃過豐富的大餐, 血量即時提升至150";
UpgradeAllowed[5] = CreateConVar("surup_allow_hot_meal", "0", "能否得到聖誕大餐", FCVAR_PLUGIN);
IndexToUpgrade[6] = 17;
UpgradeShortInfo[6] = "雷射瞄準器 - (槍前出現鮮紅色的光束)";
UpgradeLongInfo[6] = "雷射助你更準確瞄準敵人";
UpgradeAllowed[6] = CreateConVar("surup_allow_laser_sight", "0", "能否得到雷射瞄準器", FCVAR_PLUGIN);
IndexToUpgrade[7] = 19;
UpgradeShortInfo[7] = "彈性背帶 - (減少後座力)";
UpgradeLongInfo[7] = "開火時後座力更低, 更易瞄準";
UpgradeAllowed[7] = CreateConVar("surup_allow_combat_sling", "1", "能否得到彈性背帶", FCVAR_PLUGIN);
IndexToUpgrade[8] = 20;
UpgradeShortInfo[8] = "大彈夾 - (增加彈夾容量)";
UpgradeLongInfo[8] = "每次發射更多子彈才上彈, 更有效清除感染者";
UpgradeAllowed[8] = CreateConVar("surup_allow_large_clip", "1", "能否得到大彈夾", FCVAR_PLUGIN);
IndexToUpgrade[9] = 21;
UpgradeShortInfo[9] = "中空彈 - (增加子彈傷害)";
UpgradeLongInfo[9] = "子彈有碗一樣的彈頭邊緣增加刻痕, 子彈能將皮膚與肌肉撕扯開來, 造成大量出血";
UpgradeAllowed[9] = CreateConVar("surup_allow_hollow_point_ammo", "1", "能否得到中空彈", FCVAR_PLUGIN);
IndexToUpgrade[10] = 26;
UpgradeShortInfo[10] = "銳利的膠刀 - (防止受到HUNTER及SMOKER克制) [即用即棄]";
UpgradeLongInfo[10] = "特製的膠刀可以用作近身攻擊要害, 亦可切斷SMOKER的長舌, 可惜刀子用後會斷裂";
UpgradeAllowed[10] = CreateConVar("surup_allow_knife", "1", "能否得到銳利的膠刀", FCVAR_PLUGIN);
IndexToUpgrade[11] = 27;
UpgradeShortInfo[11] = "阿摩尼亞 - (極速救人)";
UpgradeLongInfo[11] = "阿摩尼亞刺鼻的氣味令你的朋友更快甦醒";
UpgradeAllowed[11] = CreateConVar("surup_allow_smelling_salts", "1", "能否得到阿摩尼亞", FCVAR_PLUGIN);
IndexToUpgrade[12] = 28;
UpgradeShortInfo[12] = "神奇藥膏 - (受傷時依舊行動自如)";
UpgradeLongInfo[12] = "用了這種藥膏, 即使肌肉萎縮依然可以跑起來";
UpgradeAllowed[12] = CreateConVar("surup_allow_ointment", "1", "能否得到神奇藥膏", FCVAR_PLUGIN);
IndexToUpgrade[13] = 29;
UpgradeShortInfo[13] = "上彈器 - (極速上彈)";
UpgradeLongInfo[13] = "上彈器令你更快更有效上彈, 節省時間";
UpgradeAllowed[13] = CreateConVar("surup_allow_reloader", "1", "能否得到上彈器", FCVAR_PLUGIN);
RegAdminCmd("addupgrade", addUpgrade, ADMFLAG_KICK);
RegAdminCmd("removeupgrade", removeUpgrade, ADMFLAG_KICK);
RegAdminCmd("giverandomupgrade", giveRandomUpgrade, ADMFLAG_KICK);
RegConsoleCmd("listupgrades", ListUpgrades);
RegConsoleCmd("laseron", LaserOn);
RegConsoleCmd("laseroff", LaserOff);
RegConsoleCmd("laser", LaserToggle);
ActivateHooks();
CreateConVar("surup_version", PLUGIN_VERSION, "Survivor Upgrades插件的版本", FCVAR_PLUGIN);
AlwaysLaser = CreateConVar("surup_always_laser", "1", "是否一開始就得到雷射瞄準器", FCVAR_PLUGIN);
UpgradesAtSpawn = CreateConVar("surup_upgrades_at_spawn", "3", "每章故事開始每人得到多次特殊裝備", FCVAR_PLUGIN);
UpgradesAtWitchKillKiller = CreateConVar("surup_upgrades_at_witch_kill_killer", "1", "主要殺WITCH者可以得到多少隨機技能", FCVAR_PLUGIN);
UpgradesAtWitchKillAll = CreateConVar("surup_upgrades_at_witch_kill_all", "1", "殺WITCH後每位倖存者可以得到多少隨機技能", FCVAR_PLUGIN);
UpgradesAtTankSpawn = CreateConVar("surup_upgrades_at_tank_spawn", "1", "TANK登場時每位倖存者可以得到多少隨機技能");
UpgradesAtTankKillKiller = CreateConVar("surup_upgrades_at_tank_kill_killer", "1", "主要殺TANK者可以得到多少隨機技能", FCVAR_PLUGIN);
UpgradesAtTankKillAll = CreateConVar("surup_upgrades_at_tank_kill_all", "1", "殺TANK後每位倖存者可以得到多少隨機技能", FCVAR_PLUGIN);
Verbosity = CreateConVar("surup_verbosity", "2", "玩家可以見到多少文字訊息 (0 = 沒有, 3 = 最多, 預設 2).", FCVAR_PLUGIN);
sayTextMsgId = GetUserMessageId("SayText");
HookUserMessage(sayTextMsgId, SayTextHook, true);
bBlockUntilRoundStart = false;
AutoExecConfig(true, "survivor_upgrades");
}
public Plugin:myinfo = {
name = PLUGIN_NAME,
author = "Jerrith",
description = "Gives survivors access to upgrades.",
version = PLUGIN_VERSION,
url = "jerrith.com"
};
public ResetValues()
{
for(new i=1; i < GetMaxClients(); ++i)
{
bUpgraded = false;
bBotControlled = false;
for(new j = 0; j < NVALID; ++j)
{
bClientHasUpgrade[j] = false;
}
}
}
public Action:SayTextHook(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
new String:message[1024];
BfReadByte(bf);
BfReadByte(bf);
BfReadString(bf, message, 1024);
if(StrContains(message, "#L4D_Upgrade_")!=-1)
{
if(StrContains(message, "description")!=-1)
{
return Plugin_Handled;
}
}
if(StrContains(message, "prevent_it_expire")!=-1)
{
CreateTimer(0.1, DelayPrintExpire, 1);
return Plugin_Handled;
}
if(StrContains(message, "ledge_save_expire")!=-1)
{
CreateTimer(0.1, DelayPrintExpire, 2);
return Plugin_Handled;
}
if(StrContains(message, "revive_self_expire")!=-1)
{
CreateTimer(0.1, DelayPrintExpire, 3);
return Plugin_Handled;
}
if(StrContains(message, "knife_expire")!=-1)
{
CreateTimer(0.1, DelayPrintExpire, 4);
return Plugin_Handled;
}
if(StrContains(message, "#L4D_Upgrade_laser_sight_expire")!= -1)
{
return Plugin_Handled;
}
// This sadly does not work. Not a SayText?
if(StrContains(message, "#L4D_NOTIFY_VOMIT_ON")!=-1)
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action:DelayPrintExpire(Handle:hTimer, any:text)
{
if(GetConVarInt(Verbosity) > 0)
{
if(text == 1)
{
PrintToChatAll("BOOMER的嘔吐物被雨衣擋住了!");
}
if(text == 2)
{
PrintToChatAll("使用了防滑粉以便爬上地面!");
}
if(text == 3)
{
PrintToChatAll("有位倒地的倖存者被一陣怪風幫助他站起來了!");
}
if(text == 4)
{
PrintToChatAll("為了逃脫, 使用了銳利的膠刀!");
}
}
}
public ActivateHooks()
{
if(!bHooked)
{
bHooked = true;
HookEvent("round_start", Event_RoundStart);
HookEvent("round_end", Event_RoundEnd);
HookEvent("tank_spawn", Event_TankSpawn);
HookEvent("tank_killed", Event_TankKilled);
HookEvent("witch_killed", Event_WitchKilled);
HookEvent("player_team", Event_PlayerTeam);
HookEvent("player_bot_replace", Event_PlayerBotReplace);
HookEvent("bot_player_replace", Event_BotPlayerReplace);
HookEvent("player_entered_start_area", Event_PlayerEnteredStartArea);
}
}
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
bBlockUntilRoundStart = false;
for(new i=1;i<GetMaxClients();++i)
{
CreateTimer(1.0, GiveInitialUpgrades, i);
}
return Plugin_Continue;
}
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
bBlockUntilRoundStart = true;
ResetValues();
return Plugin_Continue;
}
public Action:Event_TankSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new numUpgrades = GetConVarInt(UpgradesAtTankSpawn);
if(numUpgrades > 0)
{
if(GetConVarInt(Verbosity)>1)
{
PrintToChatAll("TANK來了! 希望對你有幫助...");
for(new i=1;i<GetMaxClients();i++)
{
if(!IsClientInGame(i)) continue;
if(GetClientTeam(i) != 2) continue;
GiveClientUpgrades(i, numUpgrades);
}
}
}
return Plugin_Continue;
}
public Action:Event_TankKilled(Handle:event, const String:name[], bool:dontBroadcast)
{
new numUpgradesAll = GetConVarInt(UpgradesAtTankKillAll);
new numUpgradesKiller = GetConVarInt(UpgradesAtTankKillKiller);
new killerUserId = GetEventInt(event, "attacker");
new killerClient = GetClientOfUserId(killerUserId);
if (numUpgradesAll > 0 || (numUpgradesKiller > 0 && killerClient != 0))
{
if(GetConVarInt(Verbosity)>1)
{
PrintToChatAll("TANK死亡! 每位倖存者得到了特殊裝備...");
}
if(numUpgradesAll > 0)
{
for(new i=1; i<GetMaxClients(); i++)
{
if(!IsClientInGame(i)) continue;
if(GetClientTeam(i) != 2) continue;
GiveClientUpgrades(i, numUpgradesAll);
}
}
if(numUpgradesKiller > 0)
{
if(killerClient != 0)
{
if(GetConVarInt(Verbosity)>2)
{
PrintToChatAll("主要攻擊者亦得到:");
}
else if (GetConVarInt(Verbosity)>1)
{
PrintToChat(killerClient, "是主要攻擊者, 你亦得到:");
}
GiveClientUpgrades(killerClient, numUpgradesKiller);
}
else
{
if(GetConVarInt(Verbosity)>1)
{
PrintToChatAll("由於沒有TANK的主要攻擊者, 所有沒有人得到任何特殊裝備");
}
}
}
}
return Plugin_Continue;
}
public Action:Event_WitchKilled(Handle:event, const String:name[], bool:dontBroadcast)
{
new numUpgradesAll = GetConVarInt(UpgradesAtWitchKillAll);
new numUpgradesKiller = GetConVarInt(UpgradesAtWitchKillKiller);
new killerUserId = GetEventInt(event, "attacker");
new killerClient = GetClientOfUserId(killerUserId);
if (numUpgradesAll > 0 || (numUpgradesKiller > 0 && killerClient != 0))
{
if(GetConVarInt(Verbosity)>1)
{
PrintToChatAll("WITCH死亡! 每位倖存者得到了特殊裝備...");
}
if(numUpgradesAll > 0)
{
for(new i=1; i<GetMaxClients(); i++)
{
if(!IsClientInGame(i)) continue;
if(GetClientTeam(i) != 2) continue;
GiveClientUpgrades(i, numUpgradesAll);
}
}
if(numUpgradesKiller > 0)
{
if(killerClient != 0)
{
if(GetConVarInt(Verbosity)>2)
{
PrintToChatAll("主要攻擊者亦得到:");
}
else if (GetConVarInt(Verbosity)>1)
{
PrintToChat(killerClient, "是主要攻擊者, 你亦得到:");
}
GiveClientUpgrades(killerClient, numUpgradesKiller);
}
else
{
if(GetConVarInt(Verbosity)>1)
{
PrintToChatAll("由於沒有WITCH的主要攻擊者, 所有沒有人得到任何特殊裝備");
}
}
}
}
return Plugin_Continue;
}
public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
new playerClient = GetClientOfUserId(GetEventInt(event, "userid"));
if(GetEventInt(event, "team")==2)
{
CreateTimer(5.0, GiveInitialUpgrades, playerClient);
return;
}
if(GetEventInt(event, "oldteam")==2)
{
CreateTimer(4.0, ClearOldUpgradeInfo, playerClient);
}
}
public OnClientPutInServer(client)
{
CreateTimer(5.0, GiveInitialUpgrades, client);
}
public Action:ClearOldUpgradeInfo(Handle:hTimer, any:playerClient)
{
// This is an attempt to prevent bots from getting extra upgrades... :)
if(bBotControlled[playerClient])
{
return;
}
bUpgraded[playerClient] = false;
for(new i = 0; i < NVALID; ++i)
{
bClientHasUpgrade[playerClient] = false;
}
}
public Action:Event_PlayerBotReplace(Handle:event, const String:name[], bool:dontBroadcast)
{
// Bot replaced a player.
new playerClient = GetClientOfUserId(GetEventInt(event, "player"));
new botClient = GetClientOfUserId(GetEventInt(event, "bot"));
bUpgraded[botClient] = bUpgraded[playerClient];
for(new i = 0; i < NVALID; ++i)
{
bClientHasUpgrade[botClient] = bClientHasUpgrade[playerClient];
}
bBotControlled[botClient] = true;
}
public Action:Event_BotPlayerReplace(Handle:event, const String:name[], bool:dontBroadcast)
{
// Player replaced a bot.
new playerClient = GetClientOfUserId(GetEventInt(event, "player"));
new botClient = GetClientOfUserId(GetEventInt(event, "bot"));
bUpgraded[playerClient] = bUpgraded[botClient];
for(new i = 0; i < NVALID; ++i)
{
bClientHasUpgrade[playerClient] = bClientHasUpgrade[botClient];
}
ListMyTeamUpgrades(playerClient, true);
bBotControlled[botClient] = false;
}
public ListMyTeamUpgrades(client, bool:brief)
{
if(GetConVarInt(Verbosity)>2)
{
for(new i=1;i<GetMaxClients();i++)
{
if(client == i) continue;
if(!IsClientInGame(i)) continue;
if(GetClientTeam(i) != 2) continue;
decl String:name[64];
GetClientName(i, name, 64);
for(new upgrade=0; upgrade < NVALID; ++upgrade)
{
if(bClientHasUpgrade[upgrade])
{
PrintToChat(client, "%s 得到 %s.", name, UpgradeShortInfo[upgrade]);
}
}
}
}
ListMyUpgrades(client, brief);
}
public ListMyUpgrades(client, bool:brief)
{
if(GetConVarInt(Verbosity)>1)
{
decl String:name[64];
GetClientName(client, name, 64);
for(new upgrade=0; upgrade < NVALID; ++upgrade)
{
if(bClientHasUpgrade[client][upgrade])
{
PrintToChat(client, "%s 得到 %s.", name, UpgradeShortInfo[upgrade]);
if(GetConVarInt(Verbosity)>2 || !brief)
{
PrintToChat(client, "%s", UpgradeLongInfo[upgrade]);
}
}
}
}
}
public Action:Event_PlayerEnteredStartArea(Handle:event, const String:name[], bool:dontBroadcast)
{
new playerClient = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(5.0, GiveInitialUpgrades, playerClient);
}
public OnConfigsExecuted()
{
new Handle:SU_CVAR = FindConVar("survivor_upgrades");
SetConVarInt(SU_CVAR, 1);
SetConVarInt(FindConVar("vs_max_team_switches"), 9999);
SetConVarInt(FindConVar("sv_vote_issue_change_difficulty_allowed"), 1, true, false);
SetConVarInt(FindConVar("sv_vote_issue_change_map_now_allowed"), 1, true, false);
SetConVarInt(FindConVar("sv_vote_issue_change_mission_allowed"), 1, true, false);
SetConVarInt(FindConVar("sv_vote_issue_restart_game_allowed"), 1, true, false);
}
public Action:GiveInitialUpgrades(Handle:hTimer, any:client)
{
if(bBlockUntilRoundStart) return;
if(!IsClientInGame(client)) return;
if(GetClientTeam(client) != 2) return;
if(bUpgraded[client]) return;
bUpgraded[client] = true;
if (GetConVarInt(AlwaysLaser)!=0)
{
GiveClientSpecificUpgrade(client, 6);
}
new numStarting = GetConVarInt(UpgradesAtSpawn)
if(numStarting > 0)
{
GiveClientUpgrades(client, numStarting);
}
}
public GiveClientUpgrades(client, numUpgrades)
{
for(new num=0; num<numUpgrades; ++num)
{
new numOwned = GetNumUpgrades(client);
if(numOwned == NVALID)
{
if(GetConVarInt(Verbosity)>1)
{
PrintToChatAll("%s 已經得到所有特殊裝備, 不能再得到更多");
}
return;
}
new offset = GetRandomInt(0,NVALID-(numOwned+1));
new val = 0;
while(offset > 0 || bClientHasUpgrade[client][val] || GetConVarInt(UpgradeAllowed[val])!=1)
{
if(!bClientHasUpgrade[client][val] || GetConVarInt(UpgradeAllowed[val])!=1)
{
offset = offset - 1;
}
val = val + 1;
}
GiveClientSpecificUpgrade(client, val);
}
}
public GiveClientSpecificUpgrade(any:client, upgrade)
{
decl String:name[64];
GetClientName(client, name, 64);
new VerbosityVal = GetConVarInt(Verbosity);
if(VerbosityVal > 2)
{
PrintToChatAll("%s 得到 %s.", name, UpgradeShortInfo[upgrade]);
PrintToChat(client, "%s", UpgradeLongInfo[upgrade]);
}
else if (VerbosityVal > 1)
{
PrintToChat(client, "%s 得到 %s.", name, UpgradeShortInfo[upgrade]);
}
SDKCall(AddUpgrade, client, IndexToUpgrade[upgrade]);
bClientHasUpgrade[client][upgrade]=true;
}
public GetNumUpgrades(client)
{
new num = 0;
for(new i = 0; i < NVALID; ++i)
{
if(bClientHasUpgrade[client] || GetConVarInt(UpgradeAllowed)!=1)
{
++num;
}
}
return num;
}
public Action:addUpgrade(client, args)
{
decl String:arg[3];
GetCmdArg(1, arg, sizeof(arg));
new upgrade = StringToInt(arg);
if ((upgrade < 0) || (upgrade > NUPGRADES))
{
PrintToChat(client, "Bad upgrade number");
return Plugin_Handled;
}
if(GetCmdArgs() > 1)
{
decl String:argN[3];
GetCmdArg(2, argN, sizeof(argN));
new clientNum = StringToInt(argN);
SDKCall(AddUpgrade, clientNum, upgrade);
}
else
{
SDKCall(AddUpgrade, client, upgrade);
}
return Plugin_Handled;
}
public Action:giveRandomUpgrade(client, args)
{
SDKCall(GiveRandomUpgrade, client);
return Plugin_Handled;
}
public Action:removeUpgrade(client, args)
{
decl String:arg[3];
GetCmdArg(1, arg, sizeof(arg));
new upgrade = StringToInt(arg);
if ((upgrade < 0) || (upgrade > NUPGRADES))
{
PrintToChat(client, "Bad upgrade number");
return Plugin_Handled;
}
if(GetCmdArgs() > 1)
{
decl String:argN[3];
GetCmdArg(2, argN, sizeof(argN));
new clientNum = StringToInt(argN);
SDKCall(RemoveUpgrade, clientNum, upgrade);
}
else
{
SDKCall(RemoveUpgrade, client, upgrade);
}
return Plugin_Handled;
}
public Action:ListUpgrades(client, args)
{
ListMyUpgrades(client, false);
return Plugin_Handled;
}
public Action:LaserOn(client, args)
{
if(GetConVarInt(AlwaysLaser) != 1)
{
return;
}
SDKCall(AddUpgrade, client, 17);
bClientHasUpgrade[client][6] = true;
}
public Action:LaserOff(client, args)
{
if(GetConVarInt(AlwaysLaser) != 1)
{
return;
}
SDKCall(RemoveUpgrade, client, 17);
bClientHasUpgrade[client][6] = false;
}
public Action:LaserToggle(client, args)
{
if(GetConVarInt(AlwaysLaser) != 1)
{
return;
}
if (bClientHasUpgrade[client][6])
{
LaserOff(client, 0);
}
else
{
LaserOn(client, 0);
}
} |
|