From 68387329f2dbd953b3419f12a4cd8c843b2d6c41 Mon Sep 17 00:00:00 2001 From: BotoX Date: Sat, 12 Aug 2017 15:06:41 +0200 Subject: [PATCH] fix errors ExtraCommands: add sm_setmvp --- ExtraCommands/scripting/ExtraCommands.sp | 46 +++++++++++++++++++ GlowColors/scripting/GlowColors.sp | 4 +- .../scripting/PlayerVisibility.sp | 4 +- QuickSwitch/scripting/QuickSwitch.sp | 2 +- WeaponCleaner/scripting/WeaponCleaner.sp | 4 ++ includes/zr/infect.zr.inc | 10 ++++ 6 files changed, 67 insertions(+), 3 deletions(-) diff --git a/ExtraCommands/scripting/ExtraCommands.sp b/ExtraCommands/scripting/ExtraCommands.sp index 4316c2dc..4336e60c 100644 --- a/ExtraCommands/scripting/ExtraCommands.sp +++ b/ExtraCommands/scripting/ExtraCommands.sp @@ -53,6 +53,7 @@ public void OnPluginStart() RegAdminCmd("sm_setmodel", Command_SetModel, ADMFLAG_GENERIC, "sm_setmodel <#userid|name> "); RegAdminCmd("sm_setscore", Command_SetScore, ADMFLAG_GENERIC, "sm_setscore <#userid|name> "); RegAdminCmd("sm_setdeaths", Command_SetDeaths, ADMFLAG_GENERIC, "sm_setdeaths <#userid|name> "); + RegAdminCmd("sm_setmvp", Command_SetMvp, ADMFLAG_GENERIC, "sm_setmvp <#userid|name> "); RegAdminCmd("sm_setteamscore", Command_SetTeamScore, ADMFLAG_GENERIC, "sm_setteamscore "); RegAdminCmd("sm_waila", Command_WAILA, ADMFLAG_GENERIC); RegAdminCmd("sm_info", Command_WAILA, ADMFLAG_GENERIC); @@ -1001,6 +1002,51 @@ public Action Command_SetDeaths(int client, int argc) return Plugin_Handled; } +public Action Command_SetMvp(int client, int argc) +{ + if(argc < 2) + { + ReplyToCommand(client, "[SM] Usage: sm_setmvp <#userid|name> "); + return Plugin_Handled; + } + + char sArgs[32]; + char sArgs2[32]; + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sArgs2, sizeof(sArgs2)); + + int iVal = StringToInt(sArgs2); + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + for(int i = 0; i < iTargetCount; i++) + { + CS_SetMVPCount(iTargets[i], iVal); + } + + if(iTargetCount > 1) + { + ShowActivity2(client, "\x01[SM] \x04", "\x01Set MVP to \x04%d\x01 on target \x04%s", iVal, sTargetName); + LogAction(client, -1, "\"%L\" set MVP to \"%d\" on target \"%s\"", client, iVal, sTargetName); + } + else + { + ShowActivity2(client, "\x01[SM] \x04", "\x01Set MVP to \x04%d\x01 on target \x04%s", iVal, sTargetName); + LogAction(client, iTargets[0], "\"%L\" set MVP to \"%d\" on target \"%L\"", client, iVal, iTargets[0]); + } + + return Plugin_Handled; +} + public Action Command_SetTeamScore(int client, int argc) { if(argc < 2) diff --git a/GlowColors/scripting/GlowColors.sp b/GlowColors/scripting/GlowColors.sp index b6858d22..a4015104 100644 --- a/GlowColors/scripting/GlowColors.sp +++ b/GlowColors/scripting/GlowColors.sp @@ -235,7 +235,9 @@ public MRESReturn AcceptInput(int pThis, Handle hReturn, Handle hParams) if(DHookIsNullParam(hParams, 2)) return MRES_Ignored; - int client = DHookGetParam(hParams, 2); + int client = EntRefToEntIndex(DHookGetParam(hParams, 2)); + if(client < 1 || client > MAXPLAYERS) + return MRES_Ignored; char szInputName[32]; DHookGetParamString(hParams, 1, szInputName, sizeof(szInputName)); diff --git a/PlayerVisibility/scripting/PlayerVisibility.sp b/PlayerVisibility/scripting/PlayerVisibility.sp index 72a2fa80..1e3c0edf 100644 --- a/PlayerVisibility/scripting/PlayerVisibility.sp +++ b/PlayerVisibility/scripting/PlayerVisibility.sp @@ -122,7 +122,9 @@ public MRESReturn AcceptInput(int pThis, Handle hReturn, Handle hParams) if(DHookIsNullParam(hParams, 2)) return MRES_Ignored; - int client = DHookGetParam(hParams, 2); + int client = EntRefToEntIndex(DHookGetParam(hParams, 2)); + if(client < 1 || client > MAXPLAYERS) + return MRES_Ignored; if(!g_Client_bEnabled[client]) return MRES_Ignored; diff --git a/QuickSwitch/scripting/QuickSwitch.sp b/QuickSwitch/scripting/QuickSwitch.sp index 331f26e0..90b0ad72 100644 --- a/QuickSwitch/scripting/QuickSwitch.sp +++ b/QuickSwitch/scripting/QuickSwitch.sp @@ -42,7 +42,7 @@ public void OnClientPutInServer(int client) public void OnWeaponSwitch(int client, int weapon) { - if(!g_Cvar_QuickSwitch_Knife.BoolValue || ZR_IsClientZombie(client)) + if(!g_Cvar_QuickSwitch_Knife.BoolValue || !IsPlayerAlive(client) || ZR_IsClientZombie(client)) return; char sWeaponName[32]; diff --git a/WeaponCleaner/scripting/WeaponCleaner.sp b/WeaponCleaner/scripting/WeaponCleaner.sp index 5704d6d1..cdc2be66 100644 --- a/WeaponCleaner/scripting/WeaponCleaner.sp +++ b/WeaponCleaner/scripting/WeaponCleaner.sp @@ -129,6 +129,10 @@ public void OnEntityCreated(int entity, const char[] classname) public void OnEntityDestroyed(int entity) { + // wtf sourcemod? + if(entity == -1) + return; + RemoveWeapon(EntIndexToEntRef(EntRefToEntIndex(entity))); } diff --git a/includes/zr/infect.zr.inc b/includes/zr/infect.zr.inc index 2f74d8fd..93550a7e 100644 --- a/includes/zr/infect.zr.inc +++ b/includes/zr/infect.zr.inc @@ -121,3 +121,13 @@ forward Action ZR_OnClientHuman(int &client, bool &respawn, bool &protect); * @param protect Whether the client has spawn protection. */ forward void ZR_OnClientHumanPost(int client, bool respawn, bool protect); + +/** + * Called in ZRCreateEligibleClientList to determine if a client is eligible to become infected. + * + * @param client The client index. + * + * @return Plugin_Handled is not eligible. Anything else + * (like Plugin_Continue) is eligible. + */ +forward Action ZR_OnClientMotherZombieEligible(int client);