File size: 20,636 Bytes
b40783c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
1- First we will include the necessary include files
Code:
#include < amxmodx >
#include < fun >
#include < zombie_plague_advance >
Instead of using fake meta to set the default attributes for players, i will be using fun because it is not only efficient but is also easy for beginners to understand.

2- Now we will make a customizations section where users can customize the game modes according to there requirements
Code:
// This is the chance value according to which this game mode will be called
// The higher the value the lesser the chance of calling this game mode
new const g_chance = 15
 
// This is the access flag required to start the game mode
// through the admin menu. Look in users.ini for more details
new const g_access_flag[] = "a"
 
// This is the sound which is played when the game mode is triggered
// Add as many as you want [Randomly chosen if more than one]
new const g_play_sounds[][] =
{
    "zombie_plague/nemesis1.wav" ,
    "zombie_plague/survivor1.wav"
}
 
// Comment the following line to disable ambience sounds
// Just add two slashes ( // )
#define AMBIENCE_SOUNDS
 
#if defined AMBIENCE_SOUNDS
// Ambience Sounds (only .wav and .mp3 formats supported)
// Add as many as you want [Randomly chosen if more than one]
new const g_sound_ambience[][] =
{ 
    "zombie_plague/swarm.mp3" ,
    "zombie_plague/plague.mp3"
}
// Duration in seconds of each sound
new const Float:g_sound_ambience_duration[] = { 58.0 , 56.0 }
#endif
Now were done with the customizations section we have added support for all necassary things which make a gamemode more enjoy able to play

3- Now we will create the plugin init and declare some variables
I have commented it well so it will be easy to understand:
Code:
// Variables
new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_assahp, g_msg_sync
 
// Ambience sounds task
// This value should be different from other task values present in other plugins
// Change it every time you make a new game mode
#define TASK_AMB 2957
 
public plugin_init( )
{
    // Plugin registeration.
    register_plugin ( "[ZP] Example Game Mode","1.0", "@bdul!"  )
 
    // Register some cvars
    // Edit these according to your liking
 
    // Min players required for this game mode
    cvar_minplayers = register_cvar ( "zp_avsm_minplayers", "2" )
 
    // Sniper's HP multiplier
    cvar_sniperhp =   register_cvar ( "zp_avsm_sniper_hp", "1.5" )
 
    // Assassin's HP multiplier
    cvar_assahp =     register_cvar ( "zp_avsm_assassin_hp", "1.0" )
 
    // Infection ratio i.e this number * alive players = no of assassins
    cvar_ratio =      register_cvar ( "zp_avsm_inf_ratio", "0.5" )
 
    // Get maxplayers
    g_maxplayers = get_maxplayers( )
 
    // Hud stuff needed
    g_msg_sync = CreateHudSyncObj( )
}

4- Now we will precache our resources this is very necessary
Game Modes MUST be registered in plugin precache ONLY
Code:
public plugin_precache( )
{
    // Read the access flags
    // Convert them in to bitsums
    new access_flag = read_flags( g_access_flag )
    new i
 
    // Loop through all play sounds
    // Precache the play sounds
    for (i = 0; i < sizeof g_play_sounds; i++)
        precache_sound( g_play_sounds[i] )
 
    // Precache the ambience sounds
    #if defined AMBIENCE_SOUNDS
    new sound[100]
    for (i = 0; i < sizeof g_sound_ambience; i++)
    {
        // If mp3 sounds then precache them seperately
        if (equal(g_sound_ambience[i][strlen(g_sound_ambience[i])-4], ".mp3"))
        {
            formatex(sound, sizeof sound - 1, "sound/%s", g_sound_ambience[i])
 
            // mp3 sounds are generic resources to half life
            precache_generic( sound )
        }
        else
        {
            // Precache the sound normally
            precache_sound( g_sound_ambience[i] )
        }
    }
    #endif
 
    // Register our game mode
    g_gameid = zp_register_game_mode( "Assassin vs Snipers Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}
Now we have registered our game mode
zp_register_game_mode takes 5 parameters
The first parameter is its normal name
The second parameter is the access flag required to activate this game mode manually through the admin menu
The third parameter is its chance level....setting this to zero will cause the game mode to be always called by the main plugin
The fourth parameter is whether to allow infection in this round or not
set this to 1 and attacks by zombies on humans will infect them instead of killing them
The fifth parameter is the type of deathmatch you want during this game mode
I will paste the code from Zombie Plague Advance's include file regarding deathmatch modes
Code:
/* Death Match modes for zp_register_game_mode */
enum
{
      ZP_DM_NONE = 0, // Disable death match during the custom mode round
      ZP_DM_HUMAN,    // Respawn as human only
      ZP_DM_ZOMBIE,   // Respawn as zombie only
      ZP_DM_RANDOM,   // Respawn randomly as humans or zombies
      ZP_DM_BALANCE   // Respawn as humans or zombies to keep both team balanced
}

5- In order to catch the game mode we will use the zp_round_started_pre forward instead of zp_round_started because the first one is called for custom game modes and allows them to either start or stop while informing the main plugin whether to give other game modes a chance or not.
Code:
public zp_round_started_pre( game )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Check for min players
        if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
        {
           /**
             * Note:
             * This very necessary, you should return ZP_PLUGIN_HANDLED if
             * some conditions required by your game mode are not met
             * This will inform the main plugin that you have rejected
             * the offer and so the main plugin will allow other game modes
             * to be given a chance
             */
            return ZP_PLUGIN_HANDLED
        }
        // Start our new mode
        start_avs_mode( )
    }

    // Make the compiler happy =)
    return PLUGIN_CONTINUE
}
start_avs_mode is the function where our code for the game mode will be present

6- Now we will catch the round started forward from ZP to check if our game mode has started fully so we can show a hudmessage for it and start play sounds and ambience sounds.
Code:
public zp_round_started( game, id )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Show HUD notice
        set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
        ShowSyncHudMsg(0, g_msg_sync, "Assassins vs Snipers Mode !!!")
 
        // Play the starting sound
        client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
 
        // Remove ambience task affects
        remove_task( TASK_AMB )
 
        // Set task to start ambience sounds
        #if defined AMBIENCE_SOUNDS
        set_task( 2.0, "start_ambience_sounds", TASK_AMB )
        #endif
    }
}

7- Next we will check if our game mode was manually selected
if so, then start our game mode with out any checks.
Code:
// This is called when an admin selects a custom game mode
public zp_game_mode_selected( gameid, id )
{
    // Check if our game mode was called
    if( gameid == g_gameid )
        start_avs_mode( )
 
    // Make the compiler happy again =)
    return PLUGIN_CONTINUE
}

8- Now lets create a function where our actual game mode is hidden
Code:
// This function contains the whole code behind this game mode
start_avs_mode( )
{
    // Create and initialize some important vars
    static i_assassins, i_max_assassins, id, i_alive
 
    // Get alive players
    // This function will be discussed later in the tutorial
    i_alive = fn_get_alive_players()
    id = 0
 
    // Get the no of players we have to turn into assassins
    i_max_assassins = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )
    i_assassins = 0
 
    // Randomly turn players into Assassins
    while (i_assassins < i_max_assassins)
    {
        // Keep looping through all players
        // As the while loop continues, 1 is added to the "id" variable so every single time the 
        // while loop completes a new player is selected for the task of making him into an assassin
        // If the variable "id" has exceeded max players number than its value is reset 1 so we 
        // can loop through the players again
        if ( (++id) > g_maxplayers) id = 1
 
        // Dead
        if ( !is_user_alive(id) )
            continue;
 
        // Random chance to convert players so we dont convert players with a smaller id
        if (random_num(1, 5) == 1)
        {
            // Make user assassin
            zp_make_user_assassin(id)
 
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_assahp)) )
 
            // Increase counter
            i_assassins++
        }
    }
 
    // Turn the remaining players into snipers
    for (id = 1; id <= g_maxplayers; id++)
    {
        // Only those of them who are alive and are not assassins
        if ( !is_user_alive(id) || zp_get_user_assassin(id) )
            continue;
 
        // Turn into a sniper
        zp_make_user_sniper(id)
 
        // Set his health
        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
    }
}

9- Now i will display the code to start our ambience sound
i wont be explaning it more since i have commented it well.
Code:
#if defined AMBIENCE_SOUNDS
public start_ambience_sounds( )
{
    // Variables
    static amb_sound[64], sound, Float:duration
 
    // Select our ambience sound randomly
    sound = random_num( 0, sizeof g_sound_ambience - 1 )
 
    // Copy the string into the amb_sound variable
    copy( amb_sound, sizeof amb_sound - 1 , g_sound_ambience[ sound ] )
 
    // Get the duration for the ambience sound
    duration = g_sound_ambience_duration[ sound ]
 
    // Check whether it's a wav or mp3, then play it on clients
    if ( equal( amb_sound[ strlen( amb_sound ) - 4 ], ".mp3" ) )
        client_cmd( 0, "mp3 play ^"sound/%s^"", amb_sound )
    else
        client_cmd( 0, "spk ^"%s^"", sound )
 
    // Start the ambience sounds again after the duration is completed
    set_task( duration, "start_ambience_sounds", TASK_AMB )
}
public zp_round_ended( winteam )
{
    // Stop ambience sounds on round end
    remove_task( TASK_AMB )
}
#endif

10- Now we will transform a player into an assassin or a sniper after he respawns
We cant use Hamsandwich's spawn forward because it is not called for CZ bots and for CZ bots we need to register ham forwards seperately
which wil not only lengthen the tutorial but will also confuse beginners
so we will use ZPA's own spawn forward which i made specially for game modes:
Code:
// Player spawn post
public zp_player_spawn_post( id, should_be_zombie )
{
    // Check for current mode
    if( zp_get_current_mode() == g_gameid )
    {
        // Check if the player was to be made a zombie
        if( zp_get_user_zombie( id ))
        {
            // Make him an assassin instead
            zp_make_user_assassin( id )
 
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_assahp)) )
        }
        else
        {
            // Make him a sniper
            zp_make_user_sniper( id )
 
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
        }
    }
}
The first parameter of this forward is the index of the player who is spawning
if the second parameter is 1 then it means that the main plugin wanted the guy to be a zombie . If it is 0 than the player should be a human

11- The final step is to add a function to return the number of alive players
You can use this in your script to get no of alive players
Code:
// This function returns the no of alive players
fn_get_alive_players( )
{
    static i_alive, id
    i_alive = 0
 
    for ( id = 1; id <= g_maxplayers; id++ )
    {
        if ( is_user_alive ( id ) )
            i_alive++
    }
    return i_alive;
}

So finally in the end it will look like this:
PHP Code:
#include < amxmodx >
#include < fun >
#include < zombie_plague_advance >
 
/****************[ Customizations Section ]***************/
 
// This is the chance value according to which this game mode will be called
// The higher the value the lesser the chance of calling this game mode
new const g_chance = 15
 
// This is the access flag required to start the game mode
// through the admin menu. Look in users.ini for more details
new const g_access_flag[] = "a"
 
// This is the sound which is played when the game mode is triggered
// Add as many as you want [Randomly chosen if more than one]
new const g_play_sounds[][] =
{
    "zombie_plague/nemesis1.wav" ,
    "zombie_plague/survivor1.wav"
}
 
// Comment the following line to disable ambience sounds
// Just add two slashes ( // )
#define AMBIENCE_SOUNDS
 
#if defined AMBIENCE_SOUNDS
// Ambience Sounds (only .wav and .mp3 formats supported)
// Add as many as you want [Randomly chosen if more than one]
new const g_sound_ambience[][] =
{ 
    "zombie_plague/ambience.wav"
}
 
// Duration in seconds of each sound
new const Float:g_sound_ambience_duration[] = { 58.0 , 56.0 }
#endif
 
/****************[ Customizations End....!!! ]***************/
 
// Variables
new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_assahp, g_msg_sync
 
// Ambience sounds task
#define TASK_AMB 3256
 
public plugin_init( )
{
    // Plugin registeration.
    register_plugin( "[ZP] Example Game Mode","1.0", "@bdul!" )
 
    // Register some cvars
    // Edit these according to your liking
    cvar_minplayers = register_cvar("zp_avsm_minplayers", "2")
    cvar_sniperhp =   register_cvar("zp_avsm_sniper_hp", "1.5")
    cvar_assahp =   register_cvar("zp_avsm_assassin_hp", "1.0")
    cvar_ratio =    register_cvar("zp_avsm_inf_ratio", "0.5")
 
    // Get maxplayers
    g_maxplayers = get_maxplayers( )
 
    // Hud stuff
    g_msg_sync = CreateHudSyncObj()
}
 
// Game modes MUST be registered in plugin precache ONLY
public plugin_precache( )
{
    // Read the access flag
    new access_flag = read_flags( g_access_flag )
    new i
 
    // Precache the play sounds
    for (i = 0; i < sizeof g_play_sounds; i++)
        precache_sound( g_play_sounds[i] )
 
    // Precache the ambience sounds
    #if defined AMBIENCE_SOUNDS
    new sound[100]
    for (i = 0; i < sizeof g_sound_ambience; i++)
    {
        if (equal(g_sound_ambience[i][strlen(g_sound_ambience[i])-4], ".mp3"))
        {
            formatex(sound, sizeof sound - 1, "sound/%s", g_sound_ambience[i])
            precache_generic( sound )
        }
        else
        {
            precache_sound( g_sound_ambience[i] )
        }
    }
    #endif
 
    // Register our game mode
    g_gameid = zp_register_game_mode( "Assassin vs Snipers Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}
 
// Player spawn post
public zp_player_spawn_post( id, should_be_zombie )
{
    // Check for current mode
    if( zp_get_current_mode() == g_gameid )
    {
        // Check if the player was to be made a zombie
        if( zp_get_user_zombie( id ))
        {
            // Make him an assassin instead
            zp_make_user_assassin( id )
 
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_assahp)) )
        }
        else
        {
            // Make him a sniper
            zp_make_user_sniper( id )
 
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
        }
    }
}
 
public zp_round_started_pre( game )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Check for min players
        if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
        {
            /**
            * Note:
            * This very necessary, you should return ZP_PLUGIN_HANDLED if
            * some conditions required by your game mode are not met
            * This will inform the main plugin that you have rejected
            * the offer and so the main plugin will allow other game modes
            * to be given a chance
            */
            return ZP_PLUGIN_HANDLED
        }
        // Start our new mode
        start_avs_mode( )
    }
    // Make the compiler happy =)
    return PLUGIN_CONTINUE
}
 
public zp_round_started( game, id )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Show HUD notice
        set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
        ShowSyncHudMsg(0, g_msg_sync, "Assassins vs Snipers Mode !!!")
 
        // Play the starting sound
        client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
 
        // Remove ambience task affects
        remove_task( TASK_AMB )
 
        // Set task to start ambience sounds
        #if defined AMBIENCE_SOUNDS
        set_task( 2.0, "start_ambience_sounds", TASK_AMB )
        #endif
    }
}
 
public zp_game_mode_selected( gameid, id )
{
    // Check if our game mode was called
    if( gameid == g_gameid )
        start_avs_mode( )
 
    // Make the compiler happy again =)
    return PLUGIN_CONTINUE
}
 
// This function contains the whole code behind this game mode
start_avs_mode( )
{
    // Create and initialize some important vars
    static i_assassins, i_max_assassins, id, i_alive
    i_alive = fn_get_alive_players()
    id = 0
 
    // Get the no of players we have to turn into assassins
    i_max_assassins = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )
    i_assassins = 0
 
    // Randomly turn players into Assassins
    while (i_assassins < i_max_assassins)
    {
        // Keep looping through all players
        if ( (++id) > g_maxplayers) id = 1
 
        // Dead
        if ( !is_user_alive(id) )
            continue;
 
        // Random chance
        if (random_num(1, 5) == 1)
        {
            // Make user assassin
            zp_make_user_assassin(id)
 
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_assahp)) )
 
            // Increase counter
            i_assassins++
        }
    }
 
    // Turn the remaining players into snipers
    for (id = 1; id <= g_maxplayers; id++)
    {
        // Only those of them who are alive and are not assassins
        if ( !is_user_alive(id) || zp_get_user_assassin(id) )
            continue;
 
        // Turn into a sniper
        zp_make_user_sniper(id)
 
        // Set his health
        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
    }
}
 
#if defined AMBIENCE_SOUNDS
public start_ambience_sounds( )
{
    // Variables
    static amb_sound[64], sound, Float:duration
 
    // Select our ambience sound
    sound = random_num( 0, sizeof g_sound_ambience - 1 )
    copy( amb_sound, sizeof amb_sound - 1 , g_sound_ambience[ sound ] )
    duration = g_sound_ambience_duration[ sound ]
 
    // Check whether it's a wav or mp3, then play it on clients
    if ( equal( amb_sound[ strlen( amb_sound ) - 4 ], ".mp3" ) )
        client_cmd( 0, "mp3 play ^"sound/%s^"", amb_sound )
    else
        client_cmd( 0, "spk ^"%s^"", sound )
 
    // Start the ambience sounds
    set_task( duration, "start_ambience_sounds", TASK_AMB )
}
 
public zp_round_ended( winteam )
{
    // Stop ambience sounds on round end
    remove_task( TASK_AMB )
}
#endif
 
// This function returns the no. of alive players
fn_get_alive_players( )
{
    static i_alive, id
    i_alive = 0
 
    for ( id = 1; id <= g_maxplayers; id++ )
    {
        if( is_user_alive( id ) )
            i_alive++
    }
    return i_alive;
}