1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
global function DisallowedWeapons_Init
struct {
array<string> disallowedWeapons
string disallowedWeaponsStringLastVal
string disallowedWeaponReplacement
} file
void function DisallowedWeapons_Init()
{
UpdateDisallowedWeaponList()
AddCallback_OnPlayerRespawned( ReplacePlayerWeapons )
AddCallback_OnPlayerGetsNewPilotLoadout( ReplacePlayerWeaponsForLoadoutChange )
}
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 ReplacePlayerWeapons( 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 )
}
void function ReplacePlayerWeaponsForLoadoutChange( entity player, PilotLoadoutDef loadout )
{
ReplacePlayerWeapons( player )
}
|