1.1 --- a/scripting/dm_equipment.sp Wed Nov 14 07:28:14 2007 +0000
1.2 +++ b/scripting/dm_equipment.sp Wed Nov 14 07:28:57 2007 +0000
1.3 @@ -98,6 +98,8 @@
1.4 RegConsoleCmd("say_team", Command_Say);
1.5
1.6 cssdm_enable_equipment = CreateConVar("cssdm_enable_equipment", "1", "Sets whether the equipment plugin is enabled");
1.7 + HookConVarChange(cssdm_enable_equipment, OnEquipmentEnableChange);
1.8 +
1.9 g_ArmorOffset = FindSendPropOffs("CCSPlayer", "m_ArmorValue");
1.10 g_NVOffset = FindSendPropOffs("CCSPlayer", "m_bHasNightVision");
1.11 g_HealthOffset = FindSendPropOffs("CCSPlayer", "m_iHealth");
1.12 @@ -112,21 +114,26 @@
1.13 AddMenuItem(g_hEquipMenu, "", "Random weapons every time");
1.14 }
1.15
1.16 +public OnEquipmentEnableChange(Handle:convar, const String:oldValue[], const String:newValue[])
1.17 +{
1.18 + g_IsEnabled = StringToInt(newValue) ? true : false;
1.19 +}
1.20 +
1.21 public OnConfigsExecuted()
1.22 {
1.23 LoadDefaults();
1.24
1.25 + if ((g_IsEnabled = LoadConfigFile("cfg/cssdm/cssdm.equip.txt")) == false)
1.26 + {
1.27 + LogError("[CSSDM] Could not find equipment file \"%s\"", "cfg/cssdm/cssdm.equip.txt");
1.28 + return;
1.29 + }
1.30 +
1.31 if (!GetConVarInt(cssdm_enable_equipment))
1.32 {
1.33 g_IsEnabled = false;
1.34 return;
1.35 }
1.36 -
1.37 - if ((g_IsEnabled = LoadConfigFile("cfg/cssdm/cssdm.equip.txt")) == false)
1.38 - {
1.39 - LogError("[CSSDM] Could not find equipment file \"%s\"", "cfg/cssdm/cssdm.equip.txt");
1.40 - return;
1.41 - }
1.42
1.43 /** See if there is a map version */
1.44 decl String:map[64];
1.45 @@ -169,6 +176,11 @@
1.46
1.47 public DM_OnClientSpawned(client)
1.48 {
1.49 + if (!ShouldRun())
1.50 + {
1.51 + return;
1.52 + }
1.53 +
1.54 if (!IsFakeClient(client))
1.55 {
1.56 if (g_ArmorAmount > 0)
1.57 @@ -191,7 +203,9 @@
1.58 {
1.59 GiveNightVision(client);
1.60 }
1.61 - } else {
1.62 + }
1.63 + else
1.64 + {
1.65 /* See if we'll need to strip this bot */
1.66 if (g_BotSecondaryCount || g_BotPrimaryCount)
1.67 {
1.68 @@ -530,8 +544,10 @@
1.69 {
1.70 weapon_index = GetRandomInt(0, g_PrimaryCount-1);
1.71 weapon_index = g_PrimaryList[weapon_index];
1.72 + } else if (g_PrimaryCount == 1) {
1.73 + weapon_index = g_PrimaryList[0];
1.74 } else {
1.75 - weapon_index = g_PrimaryList[0];
1.76 + return;
1.77 }
1.78 } else {
1.79 weapon_index = g_PrimaryList[list_index];
1.80 @@ -561,8 +577,10 @@
1.81 {
1.82 weapon_index = GetRandomInt(0, g_SecondaryCount-1);
1.83 weapon_index = g_SecondaryList[weapon_index];
1.84 + } else if (g_SecondaryCount == 1) {
1.85 + weapon_index = g_SecondaryList[0];
1.86 } else {
1.87 - weapon_index = g_SecondaryList[0];
1.88 + return;
1.89 }
1.90 } else {
1.91 weapon_index = g_SecondaryList[list_index];