diff --git a/changelog.txt b/changelog.txt
index 94b565ba..e935fd8f 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -124,6 +124,9 @@ CubeScript
[*] onKill - Native alias that is executed when a player is killed.
[*] onFlagEvent - Native alias that is executed when a flag event occurs.
[*] onLastMin - Native alias that is executed when the last minute of the current round is reached.
+[*] onPickup - Native alias that is executed when you pick up an item.
+[*] onWeaponSwitch - Native alias that is executed when you switch to a different weapon.
+[*] onDisconnect - Native alias that is executed when you disconnect from a server.
[*] onReload - Native alias that is executed when you reload a weapon.
[*] onNewMap - Native alias that is executed when you execute the /newmap command.
[*] afterinit - Native alias that is executed immediately after saved.cfg is loaded.
diff --git a/config/docs.cfg b/config/docs.cfg
index ec47e934..2c8b4a69 100644
--- a/config/docs.cfg
+++ b/config/docs.cfg
@@ -625,7 +625,10 @@ docexample [echo $votepending] [Output: if there is currently a vote pending, re
docident [onSpawn] [If this alias exists it will be run every time someone spawns.];
docident [onKill] [If this alias exists it will be run every time a player is killed.];
docident [onFlag] [If this alias exists it will be run every time a flag action occurs.];
+docident [onPickup] [If this alias exists it will be run every time you pick up an item.];
+docident [onWeaponSwitch] [If this alias exists it will be run every time you switch to a different weapon.];
docident [onConnect] [If this alias exists it will be run every time you or another player join(s) your server.];
+docident [onDisconnect] [If this alias exists it will be run every time you disconnect from a server.];
docident [onNameChange] [If this alias exists it will be run every time you or another player change(s) of name.];
docident [mdldyncache] [];
docargument [V] [] [min 1/max 32/default 2];
diff --git a/docs/reference.xml b/docs/reference.xml
index 4034b5f2..84787b6d 100644
--- a/docs/reference.xml
+++ b/docs/reference.xml
@@ -2034,13 +2034,32 @@ addOnLoadAlways [
If defined, this will be executed each time a flag action occurs.
-
+
+
+
+
+
+
+ If defined, this will be executed each time you pick up an item.
+
+
+
+
+
+
+ If defined, this will be executed each time you switch to a different weapon.
+
+
If defined, this will be executed when you or another player join(s) a server.
+
+
+ If defined, this will be executed when you disconnect from a server.
+
diff --git a/source/src/client.cpp b/source/src/client.cpp
index 06ff4dba..c7c299ee 100644
--- a/source/src/client.cpp
+++ b/source/src/client.cpp
@@ -215,6 +215,8 @@ void disconnect(int onlyclean, int async)
}
#endif
if(!onlyclean) localconnect();
+
+ if(identexists("onDisconnect")) execute("onDisconnect");
}
void trydisconnect()
diff --git a/source/src/entities.cpp b/source/src/entities.cpp
index 964588d8..5a2a6f0f 100644
--- a/source/src/entities.cpp
+++ b/source/src/entities.cpp
@@ -307,23 +307,23 @@ void pickupeffects(int n, playerent *d)
if(identexists("onPickup"))
{
string o;
- itemstat tmp;
+ itemstat *tmp = NULL;
switch(e.type)
{
- case I_CLIPS: tmp = ammostats[GUN_PISTOL]; break;
- case I_AMMO: tmp = ammostats[player1->primary]; break;
- case I_GRENADE: tmp = ammostats[GUN_GRENADE]; break;
- case I_AKIMBO: tmp = ammostats[GUN_AKIMBO]; break;
+ case I_CLIPS: tmp = &ammostats[GUN_PISTOL]; break;
+ case I_AMMO: tmp = &ammostats[player1->primary]; break;
+ case I_GRENADE: tmp = &ammostats[GUN_GRENADE]; break;
+ case I_AKIMBO: tmp = &ammostats[GUN_AKIMBO]; break;
case I_HEALTH:
case I_HELMET:
- case I_ARMOUR: tmp = powerupstats[e.type-I_HEALTH]; break;
+ case I_ARMOUR: tmp = &powerupstats[e.type-I_HEALTH]; break;
default: break;
}
- if(m_lss && e.type == I_GRENADE)
- formatstring(o)("onPickup %d %d", e.type - 3, 2);
- else
- formatstring(o)("onPickup %d %d", e.type - 3, tmp);
- execute(o);
+ if(tmp)
+ {
+ formatstring(o)("onPickup %d %d", e.type - 3, m_lss && e.type == I_GRENADE ? 2 : tmp->add);
+ execute(o);
+ }
}
}
else audiomgr.playsound(is.sound, d);
@@ -662,5 +662,4 @@ void syncentchanges(bool force)
}
changedents.setsize(0);
lastentsync = lastmillis;
-}
-
+}
\ No newline at end of file