Despawn weapons.
author[furrycat] <furrycat@furryclan.net>
Mon, 1 Jun 2009 21:59:23 +0000 (17:59 -0400)
committer[furrycat] <furrycat@furryclan.net>
Mon, 1 Jun 2009 21:59:23 +0000 (17:59 -0400)
Weapons are immediately despawned after use.

limited_weapons.sp [new file with mode: 0644]

diff --git a/limited_weapons.sp b/limited_weapons.sp
new file mode 100644 (file)
index 0000000..ce71fa1
--- /dev/null
@@ -0,0 +1,43 @@
+#include <sourcemod>\r
+#define Version "0.1"\r
+\r
+new Handle:despawn;\r
+\r
+public Plugin:myinfo = {\r
+  name = "Limited weapons",\r
+  author = "furrycat",\r
+  description = "Limits weapon availibility.",\r
+  version = Version,\r
+};\r
+\r
+public OnPluginStart() {\r
+  decl String:ModName[50];\r
+  GetGameFolderName(ModName, sizeof(ModName));\r
+\r
+  if (!StrEqual(ModName, "left4dead", false)) {\r
+    SetFailState("This mod is for Left 4 Dead only.");\r
+  }\r
+\r
+  /* Set up cvars. */\r
+  despawn = CreateConVar("limited_weapons_despawn", "1", "Remove weapon spawners immediately after use.");\r
+\r
+  AutoExecConfig(true, "limited_weapons");\r
+\r
+  /* Hooks. */\r
+  HookEvent("spawner_give_item", spawner_give_item_callback);\r
+}\r
+\r
+/* Remove item spawner as soon as it has given an item. */\r
+public spawner_give_item_callback(Handle:event, const String:name[], bool:dontBroadcast) {\r
+  if (GetConVarInt(despawn)) {\r
+    new spawner = GetEventInt(event, "spawner");\r
+    if (IsValidEntity(spawner)) RemoveEdict(spawner);\r
+  }\r
+}\r
\r
+public OnMapStart() {\r
+}\r
+\r
+public OnMapEnd() {\r
+}\r
+\r