blob: 2da60753e5209a651345a32e1cd039153db70337 (
plain)
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
|
global function Sv_GGEarnMeter_SetPercentage
global function Sv_GGEarnMeter_AddPercentage
global function AddCallback_GGEarnMeterFull
struct
{
array< bool functionref( entity ) > onGGEarnMeterFullCallbacks
} file
void function Sv_GGEarnMeter_SetPercentage( entity player, float percentage )
{
player.SetPlayerNetFloat( "gunGameLevelPercentage", clamp(percentage, 0.0, 1.0) )
thread CheckPercentage( player )
}
void function Sv_GGEarnMeter_AddPercentage( entity player, float percentage )
{
Sv_GGEarnMeter_SetPercentage(player, player.GetPlayerNetFloat( "gunGameLevelPercentage") + percentage)
}
void function AddCallback_GGEarnMeterFull( bool functionref( entity ) callbackFunc )
{
Assert( !file.onGGEarnMeterFullCallbacks.contains( callbackFunc ), "Already added " + FunctionToString( callbackFunc ) + " with AddCallback_GGEarnMeterFull" )
file.onGGEarnMeterFullCallbacks.append( callbackFunc )
}
void function CheckPercentage( entity player )
{
float percentage = player.GetPlayerNetFloat( "gunGameLevelPercentage")
if ( percentage < 1.0 )
return
wait 0.2
bool lastWeapon = false
foreach ( callbackFunc in file.onGGEarnMeterFullCallbacks )
lastWeapon = callbackFunc( player )
if ( !lastWeapon )
Sv_GGEarnMeter_SetPercentage(player, 0.0)
}
|