From fc1981e2344e6161960feadffa3a266943419c67 Mon Sep 17 00:00:00 2001 From: BotoX Date: Tue, 12 Jan 2016 21:18:11 +0100 Subject: [PATCH] added WeaponEquip plugin --- WeaponEquip/scripting/WeaponEquip.sp | 62 +++++++++++++++++++ .../scripting/include/zombiereloaded.inc | 1 + 2 files changed, 63 insertions(+) create mode 100644 WeaponEquip/scripting/WeaponEquip.sp create mode 120000 WeaponEquip/scripting/include/zombiereloaded.inc diff --git a/WeaponEquip/scripting/WeaponEquip.sp b/WeaponEquip/scripting/WeaponEquip.sp new file mode 100644 index 00000000..b379dc97 --- /dev/null +++ b/WeaponEquip/scripting/WeaponEquip.sp @@ -0,0 +1,62 @@ +#pragma semicolon 1 + +#include +#include +#include +#include +#include + +#pragma newdecls required + +Handle g_hCvar_WeaponSecondary = INVALID_HANDLE; +Handle g_hCvar_WeaponPrimary = INVALID_HANDLE; + +public Plugin myinfo = +{ + name = "WeaponEquip", + author = "zaCade + BotoX", + description = "Equip players with weapons when they spawn", + version = "2.0", + url = "" +}; + +public void OnPluginStart() +{ + g_hCvar_WeaponSecondary = CreateConVar("sm_weaponequip_secondary", "weapon_elite", "The name of the secondary weapon to give.", FCVAR_PLUGIN); + g_hCvar_WeaponPrimary = CreateConVar("sm_weaponequip_primary", "weapon_p90", "The name of the secondary weapon to give.", FCVAR_PLUGIN); + + AutoExecConfig(true, "plugin.WeaponEquip"); +} + +public void OnClientPutInServer(int client) +{ + SDKHook(client, SDKHook_SpawnPost, Hook_OnPlayerSpawn); +} + +public void Hook_OnPlayerSpawn(int client) +{ + if(IsPlayerAlive(client) && ZR_IsClientHuman(client)) + { + static char sSecondary[32]; + GetConVarString(g_hCvar_WeaponSecondary, sSecondary, sizeof(sSecondary)); + + static char sPrimary[32]; + GetConVarString(g_hCvar_WeaponPrimary, sPrimary, sizeof(sPrimary)); + + int Secondary = -1; + if((Secondary = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY)) != -1) + RemoveEdict(Secondary); + + int Primary = -1; + if((Primary = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY)) != -1) + RemoveEdict(Primary); + + int Grenade = -1; + while((Grenade = GetPlayerWeaponSlot(client, CS_SLOT_GRENADE)) != -1) + RemoveEdict(Grenade); + + GivePlayerItem(client, sSecondary); + GivePlayerItem(client, sPrimary); + GivePlayerItem(client, "weapon_hegrenade"); + } +} diff --git a/WeaponEquip/scripting/include/zombiereloaded.inc b/WeaponEquip/scripting/include/zombiereloaded.inc new file mode 120000 index 00000000..c9a376e8 --- /dev/null +++ b/WeaponEquip/scripting/include/zombiereloaded.inc @@ -0,0 +1 @@ +../../../includes/zombiereloaded.inc \ No newline at end of file