From 60798042e173682377de70ed57530e2cd0bf2c7d Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sat, 19 Nov 2011 14:16:39 +0200 Subject: [PATCH] Remove consumable items when the player disconnects, respawns, or gets eaten --- data/qcsrc/server/cl_client.qc | 13 ++++++++++++- data/qcsrc/server/t_items.qc | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index aae54ae1..9b26c490 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -803,6 +803,8 @@ Called when a client spawns in the server //void() ctf_playerchanged; void PutClientInServer (void) { + entity e; + if(clienttype(self) == CLIENTTYPE_BOT) { self.classname = "player"; @@ -849,6 +851,16 @@ void PutClientInServer (void) Vore_Disconnect(); self.swallow_progress_pred = self.swallow_progress_prey = 0; + for(e = world; (e = find(e, classname, "consumable")); ) + { + // remove consumable items when we respawn + if(e.predator == self) + { + e.nextthink = 0; + remove(e); + e = world; + } + } self.classname = "player"; self.wasplayer = TRUE; @@ -1018,7 +1030,6 @@ void PutClientInServer (void) weapon_action(j, WR_RESETPLAYER); // all weapons must be fully loaded when we spawn - entity e; e = get_weaponinfo(j); if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars self.(weapon_load[j]) = cvar(strcat("g_balance_", e.netname, "_reload_ammo")); diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index 8932a2e1..75bac5bf 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -230,6 +230,19 @@ void Item_Consumable_Think() return; } + if(self.predator.classname != "player") + { + // no longer a player, remove consumable items + Item_Consumable_Remove(); + return; + } + if(self.predator.stat_eaten) + { + // prey can't hold consumable items + Item_Consumable_Remove(); + return; + } + dprint("!!!!!!!!\n"); self.nextthink = time; } -- 2.39.2