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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#include common_scripts/utility;
#include maps/mp/gametypes_zm/_hud_util;
#include maps/mp/zombies/_zm_utility;
init()
{
level thread onPlayerConnect();
}
onPlayerConnect()
{
while(1)
{
level waittill("connected", player);
player thread onPlayerSpawned();
}
}
onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
while(1)
{
self waittill("spawned_player");
// Waits for the black preload screen to pass so it can load the mods
flag_wait( "initial_blackscreen_passed" );
// Mod that adds a zombie counter to the bottom of the screen
self thread zombieCounter(self, level, 100, 190);
// Mod that adds a health counter to the bottom of the screen
self thread healthCounter(self, -100, 190);
}
}
/*
* Function that draws a zombie counter
*/
zombieCounter(p, l, x, y)
{
p.zombiecounter = drawCounter(p.zombiecounter, x, y);
while(1)
{
p.zombiecounter.alpha = checkAfterlife(p);
zombies = l.zombie_total + get_current_zombie_count();
if ( zombies > 0 )
{
p.zombiecounter.label = &"Zombies Left: ^1";
}
else
{
p.zombiecounter.label = &"Zombies Left: ^6";
}
p.zombiecounter setvalue(zombies);
wait 0.05;
}
}
/*
* Function that draws a health counter
*/
healthCounter(p, x, y)
{
p.healthcounter = drawCounter(p.healthcounter, x, y);
while(1)
{
p.healthcounter.alpha = checkAfterlife(p);
// Setting Counter Colors
health = p.health;
if( health <= 15 )
{
p.healthcounter.label = &"Health: ^1";
}
else if ( health <= 50 )
{
p.healthcounter.label = &"Health: ^3";
}
else
{
p.healthcounter.label = &"Health: ^2";
}
p.healthcounter setValue(health);
wait 0.05;
}
}
// Aux Functions
/*
* Draws the counter in desired position
*/
drawCounter(counterVar, x, y)
{
counterVar = createfontstring( "Objective", 1.7 );
counterVar setpoint( "CENTER", "CENTER", x, y);
counterVar.alpha = 1;
counterVar.hidewheninmenu = 1;
counterVar.hidewhendead = 1;
return counterVar;
}
/*
* Checks if the player has entered afterlife
*/
checkAfterlife(p)
{
if(isdefined(p.afterlife) && p.afterlife)
{
return 0.2;
}
return 1;
}
|