aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-11-07 03:53:07 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-11-07 03:53:07 +0000
commit35dfd937798d105238db23ea86f90f21be46694b (patch)
treed0e1ee639bc6177649dbcbde054f1e6094fc054c /Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut
parente79a58640e1ef1ea1c3c954aefccd36c3cb55286 (diff)
downloadNorthstarMods-35dfd937798d105238db23ea86f90f21be46694b.tar.gz
NorthstarMods-35dfd937798d105238db23ea86f90f21be46694b.zip
code cleanup, xp, postgame and some small changes
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut')
-rw-r--r--Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut48
1 files changed, 48 insertions, 0 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut b/Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut
new file mode 100644
index 000000000..8dc0300f7
--- /dev/null
+++ b/Northstar.Custom/mod/scripts/vscripts/_disallowed_weapons.gnut
@@ -0,0 +1,48 @@
+global function DisallowedWeapons_Init
+
+struct {
+ array<string> disallowedWeapons
+ string disallowedWeaponsStringLastVal
+ string disallowedWeaponReplacement
+} file
+
+void function DisallowedWeapons_Init()
+{
+ UpdateDisallowedWeaponList()
+ AddCallback_OnPlayerRespawned( ReplacePlayerWeaponsForSpawn )
+}
+
+void function UpdateDisallowedWeaponList()
+{
+ string cvar = GetConVarString( "ns_disallowed_weapons" )
+ if ( file.disallowedWeaponsStringLastVal == cvar )
+ return
+
+ file.disallowedWeapons = split( cvar, "," )
+ foreach ( string weapon in file.disallowedWeapons )
+ StringReplace( weapon, " ", "" )
+
+ file.disallowedWeaponReplacement = GetConVarString( "ns_disallowed_weapon_primary_replacement" )
+}
+
+void function ReplacePlayerWeaponsForSpawn( entity player )
+{
+ UpdateDisallowedWeaponList()
+ if ( file.disallowedWeapons.len() == 0 )
+ return
+
+ bool hadDisallowedWeapon = false
+
+ foreach ( entity weapon in player.GetMainWeapons() )
+ {
+ if ( file.disallowedWeapons.contains( weapon.GetWeaponClassName() ) )
+ {
+ player.TakeWeaponNow( weapon.GetWeaponClassName() )
+ player.GiveWeapon( file.disallowedWeaponReplacement )
+ hadDisallowedWeapon = true
+ }
+ }
+
+ if ( hadDisallowedWeapon )
+ SendHudMessage( player, "Restricted weapons were removed", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
+} \ No newline at end of file