-
Notifications
You must be signed in to change notification settings - Fork 30
/
commands.sp
2681 lines (2429 loc) · 73.3 KB
/
commands.sp
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
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
public Action Command_Vip(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (!g_bflagTitles[client][0])
{
PrintToChat(client, "[%cCK%c] This command requires the VIP title.", MOSSGREEN, WHITE);
return Plugin_Handled;
}
Menu vipEffects = CreateMenu(h_vipEffects);
char szMenuItem[128];
SetMenuTitle(vipEffects, "Exclusive VIP effects: ");
if (!g_bTrailOn[client])
Format(szMenuItem, 128, "[OFF] Player Trail");
else
Format(szMenuItem, 128, "[ON] Player Trail");
AddMenuItem(vipEffects, "", szMenuItem);
Format(szMenuItem, 128, "Trail Color: %s", RGB_COLOR_NAMES[g_iTrailColor[client]]);
AddMenuItem(vipEffects, "", szMenuItem);
AddMenuItem(vipEffects, "", "Vote to extend map (!ve)");
if (GetConVarBool(g_hAllowVipMute))
AddMenuItem(vipEffects, "", "Mute a player (!vmute)");
else
AddMenuItem(vipEffects, "", "Mute a player (!vmute)", ITEMDRAW_DISABLED);
AddMenuItem(vipEffects, "", "More to come...", ITEMDRAW_DISABLED);
SetMenuExitButton(vipEffects, true);
DisplayMenu(vipEffects, client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int h_vipEffects(Menu tMenu, MenuAction action, int client, int item)
{
switch (action)
{
case MenuAction_Select:
{
switch (item)
{
case 0:
{
toggleTrail(client);
CreateTimer(0.1, RefreshVIPMenu, client, TIMER_FLAG_NO_MAPCHANGE);
}
case 1:
{
CreateTimer(0.1, RefreshVIPMenu, client, TIMER_FLAG_NO_MAPCHANGE);
changeTrailColor(client);
}
case 2:
{
Command_VoteExtend(client, 0);
}
case 3:
{
Command_MutePlayer(client, 0);
}
}
}
case MenuAction_End:
{
CloseHandle(tMenu);
}
}
}
public Action Command_MutePlayer (int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (!GetConVarBool(g_hAllowVipMute))
{
ReplyToCommand(client, "[%cCK%c] VIP muting has been disabled on this server.", MOSSGREEN, WHITE);
return Plugin_Handled;
}
if (!g_bflagTitles[client][0])
{
ReplyToCommand(client, "[%cCK%c] This command requires the VIP title.", MOSSGREEN, WHITE);
return Plugin_Handled;
}
if (args > 0)
{
char szName[MAX_NAME_LENGTH], szBuffer[MAX_NAME_LENGTH];
GetCmdArg(1, szName, MAX_NAME_LENGTH);
int target = Client_FindByName(szName, true, false);
if (target != -1)
{
if (BaseComm_IsClientMuted(target))
{
if (BaseComm_SetClientMute(target, false))
PrintToChatAll("[%cCK%c] %s was unmuted by a VIP.", MOSSGREEN, WHITE, szBuffer);
}
else
{
if (BaseComm_SetClientMute(target, true))
PrintToChatAll("[%cCK%c] %s was muted by a VIP.", MOSSGREEN, WHITE, szBuffer);
}
return Plugin_Handled;
}
else
{
PrintToChat(client, "[%cCK%c] Could not find a player with the name of %s.", MOSSGREEN, WHITE, szName);
return Plugin_Handled;
}
}
Menu mMutePlayers = CreateMenu(h_MutePlayers);
SetMenuTitle(mMutePlayers, "Select player to mute or unmute");
char szMenuItem[48], id[8], count;
for (int i = 0; i < MAXPLAYERS+1; i++)
{
if (IsValidClient(i) && !IsFakeClient(i) && client != i)
{
count++;
IntToString(i, id, 8);
if (BaseComm_IsClientMuted(i))
{
GetClientName(i, szMenuItem, 48);
Format(szMenuItem, 48, "[ON] %s", szMenuItem);
}
else
{
GetClientName(i, szMenuItem, 48);
Format(szMenuItem, 48, "[OFF] %s", szMenuItem);
}
AddMenuItem(mMutePlayers, id, szMenuItem);
}
}
if (count == 0)
{
ReplyToCommand(client, "[%cCK%c] No valid players found.", MOSSGREEN, WHITE);
CloseHandle(mMutePlayers);
return Plugin_Handled;
}
SetMenuExitButton(mMutePlayers, true);
DisplayMenu(mMutePlayers, client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int h_MutePlayers(Menu tMenu, MenuAction action, int client, int item)
{
switch (action)
{
case MenuAction_Select:
{
char aID[8];
GetMenuItem(tMenu, item, aID, sizeof(aID));
int clientID = StringToInt(aID);
if (IsValidClient(clientID))
{
char szName[MAX_NAME_LENGTH];
GetClientName(clientID, szName, MAX_NAME_LENGTH);
if (BaseComm_IsClientMuted(clientID))
{
if (BaseComm_SetClientMute(clientID, false))
PrintToChatAll("[%cCK%c] %s was unmuted by a VIP.", MOSSGREEN, WHITE, szName);
}
else
{
if (BaseComm_SetClientMute(clientID, true))
PrintToChatAll("[%cCK%c] %s was muted by a VIP.", MOSSGREEN, WHITE, szName);
}
}
}
case MenuAction_End:
{
CloseHandle(tMenu);
}
}
}
public Action Command_SetTitle(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (!g_bHasTitle[client])
{
PrintToChat(client, "[%cCK%c] You don't have access to any custom titles.", MOSSGREEN, WHITE);
return Plugin_Handled;
}
Menu playersTitles = CreateMenu(H_PlayersTitles);
SetMenuTitle(playersTitles, "Your available titles: ");
char id[8], szMenuItem[54];
for (int i = 0; i < TITLE_COUNT; i++)
{
if (g_bflagTitles[client][i] && !StrEqual(g_szflagTitle[i], ""))
{
IntToString(i, id, 8);
if (g_iTitleInUse[client] == i)
Format(szMenuItem, 54, "[ON] %s", g_szflagTitle[i]);
else
Format(szMenuItem, 54, "[OFF] %s", g_szflagTitle[i]);
AddMenuItem(playersTitles, id, szMenuItem);
}
}
SetMenuExitButton(playersTitles, true);
DisplayMenu(playersTitles, client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int H_PlayersTitles(Menu tMenu, MenuAction action, int client, int item)
{
switch (action)
{
case MenuAction_Select:
{
if (!IsValidClient(client))
return;
char aID[8], szSteamID[32];
GetMenuItem(tMenu, item, aID, sizeof(aID));
int titleID = StringToInt(aID);
if (g_iTitleInUse[client] == titleID)
g_iTitleInUse[client] = -1;
else
g_iTitleInUse[client] = titleID;
SetPlayerRank(client);
CreateTimer(0.5, SetClanTag, client, TIMER_FLAG_NO_MAPCHANGE);
//GetClientAuthString(client, szSteamID, 32, true);
GetClientAuthId(client, AuthId_Steam2, szSteamID, MAX_NAME_LENGTH, true);
db_updatePlayerTitleInUse(g_iTitleInUse[client], szSteamID);
}
case MenuAction_End:
{
CloseHandle(tMenu);
}
}
}
public Action Command_VoteExtend(int client, int args)
{
if(!IsValidClient(client))
return Plugin_Handled;
if (!g_bflagTitles[client][0])
{
ReplyToCommand(client, "[CK] This command requires the VIP title.");
return Plugin_Handled;
}
if (IsVoteInProgress())
{
ReplyToCommand(client, "[CK] Please wait until the current vote has finished.");
return Plugin_Handled;
}
if (g_VoteExtends >= GetConVarInt(g_hMaxVoteExtends))
{
ReplyToCommand(client, "[CK] There have been too many extends this map.");
return Plugin_Handled;
}
// Here we go through and make sure this user has not already voted. This persists throughout map.
for (int i = 0; i < g_VoteExtends; i++)
{
if (StrEqual(g_szUsedVoteExtend[i], g_szSteamID[client], false))
{
ReplyToCommand(client, "[CK] You have already used your vote to extend this map.");
return Plugin_Handled;
}
}
StartVoteExtend(client);
return Plugin_Handled;
}
public void StartVoteExtend(int client)
{
char szPlayerName[MAX_NAME_LENGTH];
GetClientName(client, szPlayerName, MAX_NAME_LENGTH);
CPrintToChatAll("[{olive}CK{default}] Vote to Extend started by {green}%s{default}", szPlayerName);
g_szUsedVoteExtend[g_VoteExtends] = g_szSteamID[client]; // Add the user's steam ID to the list
g_VoteExtends++; // Increment the total number of vote extends so far
Menu voteExtend = CreateMenu(H_VoteExtend);
SetVoteResultCallback(voteExtend, H_VoteExtendCallback);
char szMenuTitle[128];
char buffer[8];
IntToString(RoundToFloor(GetConVarFloat(g_hVoteExtendTime)), buffer, sizeof(buffer));
Format(szMenuTitle, sizeof(szMenuTitle), "Extend map for %s minutes?", buffer);
SetMenuTitle(voteExtend, szMenuTitle);
AddMenuItem(voteExtend, "", "Yes");
AddMenuItem(voteExtend, "", "No");
SetMenuExitButton(voteExtend, false);
VoteMenuToAll(voteExtend, 20);
}
public int H_VoteExtend(Menu tMenu, MenuAction action, int client, int item)
{
if (action == MenuAction_End)
{
CloseHandle(tMenu);
}
}
public void H_VoteExtendCallback(Menu menu, int num_votes, int num_clients, const int[][] client_info, int num_items, const int[][] item_info)
{
int votesYes = 0;
int votesNo = 0;
if (item_info[0][VOTEINFO_ITEM_INDEX] == 0) { // If the winner is Yes
votesYes = item_info[0][VOTEINFO_ITEM_VOTES];
if (num_items > 1) {
votesNo = item_info[1][VOTEINFO_ITEM_VOTES];
}
}
else { // If the winner is No
votesNo = item_info[0][VOTEINFO_ITEM_VOTES];
if (num_items > 1) {
votesYes = item_info[1][VOTEINFO_ITEM_VOTES];
}
}
if (votesYes > votesNo) // A tie is a failure
{
CPrintToChatAll("[{olive}CK{default}] Vote to Extend succeeded - Votes Yes: %i | Votes No: %i", votesYes, votesNo);
ExtendMapTimeLimit(RoundToFloor(GetConVarFloat(g_hVoteExtendTime)*60));
}
else
{
CPrintToChatAll("[{olive}CK{default}] Vote to Extend failed - Votes Yes: %i | Votes No: %i", votesYes, votesNo);
}
}
public Action Command_normalMode(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
Client_Stop(client, 1);
if (g_bPracticeMode[client])
{
g_bPracticeMode[client] = false;
g_fLastTimePracUsed[client] = GetGameTime();
}
Command_Restart(client, 1);
LimitSpeed(client);
PrintToChat(client, "%t", "PracticeNormal", MOSSGREEN, WHITE, MOSSGREEN);
return Plugin_Handled;
}
public Action Command_createPlayerCheckpoint(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (g_iClientInZone[client][0] == 1 || g_iClientInZone[client][0] == 5)
{
PrintToChat(client, "%t", "PracticeInStartZone", MOSSGREEN, WHITE);
return Plugin_Handled;
}
float CheckpointTime = GetGameTime();
// Move old checkpoint to the undo values, if the last checkpoint was made more than a second ago
if (g_bCreatedTeleport[client] && (CheckpointTime - g_fLastPlayerCheckpoint[client]) > 1.0)
{
g_fLastPlayerCheckpoint[client] = CheckpointTime;
Array_Copy(g_fCheckpointLocation[client], g_fCheckpointLocation_undo[client], 3);
Array_Copy(g_fCheckpointVelocity[client], g_fCheckpointVelocity_undo[client], 3);
Array_Copy(g_fCheckpointAngle[client], g_fCheckpointAngle_undo[client], 3);
}
g_bCreatedTeleport[client] = true;
GetClientAbsOrigin(client, g_fCheckpointLocation[client]);
GetEntPropVector(client, Prop_Data, "m_vecVelocity", g_fCheckpointVelocity[client]);
GetClientEyeAngles(client, g_fCheckpointAngle[client]);
PrintToChat(client, "%t", "PracticePointCreated", MOSSGREEN, WHITE, MOSSGREEN, WHITE);
return Plugin_Handled;
}
public Action Command_goToPlayerCheckpoint(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (g_fCheckpointLocation[client][0] != 0.0 && g_fCheckpointLocation[client][1] != 0.0 && g_fCheckpointLocation[client][2] != 0.0)
{
if (g_bPracticeMode[client] == false)
{
PrintToChat(client, "%t", "PracticeStarted", MOSSGREEN, WHITE, MOSSGREEN, WHITE, MOSSGREEN, WHITE);
PrintToChat(client, "%t", "PracticeStarted2", MOSSGREEN, WHITE, MOSSGREEN, WHITE, MOSSGREEN, WHITE);
g_bPracticeMode[client] = true;
g_fLastTimePracUsed[client] = GetGameTime();
}
SetEntPropVector(client, Prop_Data, "m_vecVelocity", view_as<float>( { 0.0, 0.0, 0.0 } ));
TeleportEntity(client, g_fCheckpointLocation[client], g_fCheckpointAngle[client], g_fCheckpointVelocity[client]);
}
else
PrintToChat(client, "%t", "PracticeStartError", MOSSGREEN, WHITE, MOSSGREEN);
return Plugin_Handled;
}
public Action Command_undoPlayerCheckpoint(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (g_fCheckpointLocation_undo[client][0] != 0.0 && g_fCheckpointLocation_undo[client][1] != 0.0 && g_fCheckpointLocation_undo[client][2] != 0.0)
{
float tempLocation[3], tempVelocity[3], tempAngle[3];
// Location
Array_Copy(g_fCheckpointLocation_undo[client], tempLocation, 3);
Array_Copy(g_fCheckpointLocation[client], g_fCheckpointLocation_undo[client], 3);
Array_Copy(tempLocation, g_fCheckpointLocation[client], 3);
// Velocity
Array_Copy(g_fCheckpointVelocity_undo[client], tempVelocity, 3);
Array_Copy(g_fCheckpointVelocity[client], g_fCheckpointVelocity_undo[client], 3);
Array_Copy(tempVelocity, g_fCheckpointVelocity[client], 3);
// Angle
Array_Copy(g_fCheckpointAngle_undo[client], tempAngle, 3);
Array_Copy(g_fCheckpointAngle[client], g_fCheckpointAngle_undo[client], 3);
Array_Copy(tempAngle, g_fCheckpointAngle[client], 3);
PrintToChat(client, "%t", "PracticeUndo", MOSSGREEN, WHITE);
}
else
PrintToChat(client, "%t", "PracticeUndoError", MOSSGREEN, WHITE, MOSSGREEN);
return Plugin_Handled;
}
public Action Command_Teleport(int client, int args)
{
// Throttle using !back to fix errors with replays
if ((GetGameTime() - g_fLastCommandBack[client]) < 1.0)
return Plugin_Handled;
else
g_fLastCommandBack[client] = GetGameTime();
if (g_Stage[g_iClientInZone[client][2]][client] == 1)
{
teleportClient(client, g_iClientInZone[client][2], 1, false);
return Plugin_Handled;
}
teleportClient(client, g_iClientInZone[client][2], g_Stage[g_iClientInZone[client][2]][client], false);
return Plugin_Handled;
}
public Action Command_HowTo(int client, int args)
{
ShowMOTDPanel(client, "ckSurf - How To Surf", "http://koti.kapsi.fi/~mukavajoni/how", MOTDPANEL_TYPE_URL);
return Plugin_Handled;
}
public Action Command_Zones(int client, int args)
{
if (IsValidClient(client))
{
ZoneMenu(client);
resetSelection(client);
}
return Plugin_Handled;
}
public Action Command_ListBonuses(int client, int args)
{
if (IsValidClient(client))
{
ListBonuses(client, 1);
}
return Plugin_Handled;
}
public void ListBonuses(int client, int type)
{
// Types: Start(1), End(2), Stage(3), Checkpoint(4), Speed(5), TeleToStart(6), Validator(7), Chekcer(8), Stop(0)
char buffer[3];
Menu listBonusesMenu;
if (type == 1)
{
listBonusesMenu = new Menu(MenuHandler_SelectBonus);
}
else
{
listBonusesMenu = new Menu(MenuHandler_SelectBonusTop);
}
listBonusesMenu.SetTitle("Choose a bonus");
if (g_mapZoneGroupCount > 1)
{
for (int i = 1; i < g_mapZoneGroupCount; i++)
{
IntToString(i, buffer, 3);
listBonusesMenu.AddItem(buffer, g_szZoneGroupName[i]);
}
}
else
{
PrintToChat(client, "[%cCK%c] There are no bonuses in this map.", MOSSGREEN, WHITE);
return;
}
listBonusesMenu.ExitButton = true;
listBonusesMenu.Display(client, 60);
}
public int MenuHandler_SelectBonusTop(Menu sMenu, MenuAction action, int client, int item)
{
switch (action)
{
case MenuAction_Select:
{
char aID[3];
GetMenuItem(sMenu, item, aID, sizeof(aID));
int zoneGrp = StringToInt(aID);
db_selectBonusTopSurfers(client, g_szMapName, zoneGrp);
}
case MenuAction_End:
{
delete sMenu;
}
}
}
public int MenuHandler_SelectBonus(Menu sMenu, MenuAction action, int client, int item)
{
switch (action)
{
case MenuAction_Select:
{
char aID[3];
GetMenuItem(sMenu, item, aID, sizeof(aID));
int zoneGrp = StringToInt(aID);
teleportClient(client, zoneGrp, 1, true);
}
case MenuAction_End:
{
delete sMenu;
}
}
}
public Action Command_ToBonus(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
// If not enough arguments, or there is more than one bonus
if (args < 1 && g_mapZoneGroupCount > 2) // Tell player to select specific bonus
{
ListBonuses(client, 1);
return Plugin_Handled;
}
int zoneGrp;
if (g_mapZoneGroupCount > 2) // If there is more than one bonus in the map, get the zGrp from command
{
char arg1[3];
GetCmdArg(1, arg1, sizeof(arg1));
if (!arg1[0])
zoneGrp = args;
else
zoneGrp = StringToInt(arg1);
if (zoneGrp == 0) {
Command_Restart(client, 1);
return Plugin_Handled;
}
}
else
zoneGrp = 1;
teleportClient(client, zoneGrp, 1, true);
return Plugin_Handled;
}
public Action Command_SelectStage(int client, int args)
{
if (IsValidClient(client))
ListStages(client, g_iClientInZone[client][2]);
return Plugin_Handled;
}
public void ListStages(int client, int zonegroup)
{
// Types: Start(1), End(2), Stage(3), Checkpoint(4), Speed(5), TeleToStart(6), Validator(7), Chekcer(8), Stop(0)
Menu sMenu = CreateMenu(MenuHandler_SelectStage);
SetMenuTitle(sMenu, "Stage selector");
int amount = 0;
char StageName[64], ZoneInfo[6];
int StageIds[MAXZONES] = { -1, ... };
if (g_mapZonesCount > 0)
{
for (int i = 0; i <= g_mapZonesCount; i++)
{
if (g_mapZones[i][zoneType] == 3 && g_mapZones[i][zoneGroup] == zonegroup)
{
StageIds[amount] = i;
amount++;
}
}
if (amount == 0)
{
AddMenuItem(sMenu, "", "The map is linear.", ITEMDRAW_DISABLED);
}
else
{
amount = 0;
for (int t = 0; t < 128; t++)
{
if (StageIds[t] >= 0)
{
amount++;
Format(StageName, sizeof(StageName), "Stage %i", (amount + 1));
IntToString(amount + 1, ZoneInfo, 6);
AddMenuItem(sMenu, ZoneInfo, StageName);
}
}
}
}
else
{
AddMenuItem(sMenu, "", "No stages are available.", ITEMDRAW_DISABLED);
}
SetMenuExitButton(sMenu, true);
DisplayMenu(sMenu, client, MENU_TIME_FOREVER);
}
public int MenuHandler_SelectStage(Menu tMenu, MenuAction action, int client, int item)
{
switch (action)
{
case MenuAction_Select:
{
char aID[64];
GetMenuItem(tMenu, item, aID, sizeof(aID));
int id = StringToInt(aID);
teleportClient(client, g_iClientInZone[client][2], id, true);
}
case MenuAction_End:
{
CloseHandle(tMenu);
}
}
}
public Action Command_ToStage(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (args < 1)
{
// Remove chat output to reduce chat spam
//PrintToChat(client, "Teleport to stage 1 | Default usage: !s <stage number>");
teleportClient(client, g_iClientInZone[client][2], 1, true);
}
else
{
char arg1[3];
GetCmdArg(1, arg1, sizeof(arg1));
int StageId = StringToInt(arg1);
teleportClient(client, g_iClientInZone[client][2], StageId, true);
}
return Plugin_Handled;
}
public Action Command_ToEnd(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (!GetConVarBool(g_hCommandToEnd))
{
ReplyToCommand(client, "[%cCK%c] Teleportation to the end zone has been disabled on this server.", MOSSGREEN, WHITE);
return Plugin_Handled;
}
teleportClient(client, g_iClientInZone[client][2], -1, true);
return Plugin_Handled;
}
public Action Command_Restart(int client, int args)
{
if (GetConVarBool(g_hDoubleRestartCommand) && args == 0)
{
if (GetGameTime() - g_fClientRestarting[client] > 5.0)
g_bClientRestarting[client] = false;
// Check that the client has a timer running, the zonegroup he is in has stages and that this is the first click
if (IsValidClient(client) && g_bTimeractivated[client] && g_mapZonesTypeCount[g_iClientInZone[client][2]][3] > 0 && !g_bClientRestarting[client] && g_Stage[g_iClientInZone[client][2]][client] > 1)
{
g_fClientRestarting[client] = GetGameTime();
g_bClientRestarting[client] = true;
PrintToChat(client, "[%cCK%c] Are you sure you want to restart your run? Use %c!r%c again to restart.", MOSSGREEN, WHITE, GREEN, WHITE);
ClientCommand(client, "play ambient/misc/clank4");
return Plugin_Handled;
}
}
g_bClientRestarting[client] = false;
teleportClient(client, 0, 1, true);
return Plugin_Handled;
}
public Action Client_HideChat(int client, int args)
{
HideChat(client);
if (g_bHideChat[client])
PrintToChat(client, "%t", "HideChat1", MOSSGREEN, WHITE);
else
PrintToChat(client, "%t", "HideChat2", MOSSGREEN, WHITE);
return Plugin_Handled;
}
public void HideChat(int client)
{
if (!g_bHideChat[client])
{
// Hiding
if (g_bViewModel[client])
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR | HIDE_CHAT | HIDE_CROSSHAIR);
else
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR | HIDE_CHAT);
}
else
{
// Displaying
if (g_bViewModel[client])
SetEntProp(client, Prop_Send, "m_iHideHUD", HIDE_RADAR | HIDE_CROSSHAIR);
else
SetEntProp(client, Prop_Send, "m_iHideHUD", HIDE_RADAR);
}
g_bHideChat[client] = !g_bHideChat[client];
}
public Action ToggleCheckpoints(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
if (g_bCheckpointsEnabled[client])
{
g_bCheckpointsEnabled[client] = false;
if (g_bActivateCheckpointsOnStart[client])
g_bActivateCheckpointsOnStart[client] = false;
PrintToChat(client, "%t", "ToogleCheckpoints1", MOSSGREEN, WHITE);
}
else
{
if (g_bTimeractivated[client])
{
PrintToChat(client, "%t", "ToggleCheckpoints3", MOSSGREEN, WHITE);
g_bActivateCheckpointsOnStart[client] = true;
}
else
{
g_bCheckpointsEnabled[client] = true;
PrintToChat(client, "%t", "ToggleCheckpoints2", MOSSGREEN, WHITE);
}
}
return Plugin_Handled;
}
public Action Client_HideWeapon(int client, int args)
{
HideViewModel(client);
if (g_bViewModel[client])
PrintToChat(client, "%t", "HideViewModel2", MOSSGREEN, WHITE);
else
PrintToChat(client, "%t", "HideViewModel1", MOSSGREEN, WHITE);
return Plugin_Handled;
}
public void HideViewModel(int client)
{
Client_SetDrawViewModel(client, !g_bViewModel[client]);
if (!g_bViewModel[client])
{
// Display
if (!g_bHideChat[client])
SetEntProp(client, Prop_Send, "m_iHideHUD", HIDE_RADAR);
else
SetEntProp(client, Prop_Send, "m_iHideHUD", HIDE_RADAR | HIDE_CHAT);
}
else
{
// Hiding
if (!g_bHideChat[client])
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR | HIDE_CROSSHAIR);
else
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR | HIDE_CHAT | HIDE_CROSSHAIR);
}
g_bViewModel[client] = !g_bViewModel[client];
}
public Action Client_Wr(int client, int args)
{
if (IsValidClient(client))
{
if (g_fRecordMapTime == 9999999.0)
PrintToChat(client, "%t", "NoRecordTop", MOSSGREEN, WHITE);
else
PrintMapRecords(client);
}
return Plugin_Handled;
}
public Action Command_Tier(int client, int args)
{
if (IsValidClient(client) && g_bTierFound[0]) //the second condition is only checked if the first passes
PrintToChat(client, g_sTierString[0]);
}
public Action Command_bTier(int client, int args)
{
if (IsValidClient(client))
{
if (g_mapZoneGroupCount == 1)
{
PrintToChat(client, "[%cCK%c] There are no bonuses in this map.", MOSSGREEN, WHITE);
return;
}
int found = 0;
for (int i = 1; i < MAXZONEGROUPS; i++)
{
if (g_bTierFound[i])
{
PrintToChat(client, g_sTierString[i]);
found++;
}
}
if (found == 0)
{
PrintToChat(client, "[%cCK%c] Bonus tiers have not been set on this map.", MOSSGREEN, WHITE);
}
}
}
public Action Client_Avg(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;
char szProTime[32];
FormatTimeFloat(client, g_favg_maptime, 3, szProTime, sizeof(szProTime));
if (g_MapTimesCount == 0)
Format(szProTime, 32, "N/A");
PrintToChat(client, "%t", "AvgTime", MOSSGREEN, WHITE, GRAY, DARKBLUE, WHITE, szProTime, g_MapTimesCount);
if (g_bhasBonus)
{
char szBonusTime[32];
for (int i = 1; i < g_mapZoneGroupCount; i++)
{
FormatTimeFloat(client, g_fAvg_BonusTime[i], 3, szBonusTime, sizeof(szBonusTime));
if (g_iBonusCount[i] == 0)
Format(szBonusTime, 32, "N/A");
PrintToChat(client, "%t", "AvgTimeBonus", MOSSGREEN, WHITE, GRAY, YELLOW, WHITE, szBonusTime, g_iBonusCount[i]);
}
}
return Plugin_Handled;
}
public Action Client_Flashlight(int client, int args)
{
if (IsValidClient(client) && IsPlayerAlive(client))
SetEntProp(client, Prop_Send, "m_fEffects", GetEntProp(client, Prop_Send, "m_fEffects") ^ 4);
return Plugin_Handled;
}
public Action Client_Challenge(int client, int args)
{
if (!g_bChallenge[client] && !g_bChallenge_Request[client])
{
if (IsPlayerAlive(client))
{
if (GetConVarBool(g_hCvarNoBlock))
{
Menu menu2 = CreateMenu(ChallengeMenuHandler2);
char tmp[64];
if (GetConVarBool(g_hPointSystem))
Format(tmp, 64, "ckSurf - Challenge: Player Bet?\nYour Points: %i", g_pr_points[client]);
else
Format(tmp, 64, "ckSurf - Challenge: Player Bet?\nPlayer point system disabled", g_pr_points[client]);
SetMenuTitle(menu2, tmp);
AddMenuItem(menu2, "0", "No bet");
if (GetConVarBool(g_hPointSystem))
{
Format(tmp, 64, "%i", g_pr_PointUnit * 50);
if (g_pr_PointUnit * 50 <= g_pr_points[client])
AddMenuItem(menu2, tmp, tmp);
Format(tmp, 64, "%i", (g_pr_PointUnit * 100));
if ((g_pr_PointUnit * 100) <= g_pr_points[client])
AddMenuItem(menu2, tmp, tmp);
Format(tmp, 64, "%i", (g_pr_PointUnit * 250));
if ((g_pr_PointUnit * 250) <= g_pr_points[client])
AddMenuItem(menu2, tmp, tmp);
Format(tmp, 64, "%i", (g_pr_PointUnit * 500));
if ((g_pr_PointUnit * 500) <= g_pr_points[client])
AddMenuItem(menu2, tmp, tmp);
}
SetMenuOptionFlags(menu2, MENUFLAG_BUTTON_EXIT);
DisplayMenu(menu2, client, MENU_TIME_FOREVER);
}
else
PrintToChat(client, "%t", "ChallengeFailed1", RED, WHITE);
}
else
PrintToChat(client, "%t", "ChallengeFailed2", RED, WHITE);
}
else
PrintToChat(client, "%t", "ChallengeFailed3", RED, WHITE);
return Plugin_Handled;
}
public int ChallengeMenuHandler2(Menu menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
{
char info[32];
GetMenuItem(menu, param2, info, sizeof(info));
int value = StringToInt(info);
if (value == g_pr_PointUnit * 50)
g_Challenge_Bet[param1] = 50;
else
if (value == (g_pr_PointUnit * 100))
g_Challenge_Bet[param1] = 100;
else
if (value == (g_pr_PointUnit * 250))
g_Challenge_Bet[param1] = 250;
else
if (value == (g_pr_PointUnit * 500))
g_Challenge_Bet[param1] = 500;
else
g_Challenge_Bet[param1] = 0;
char szPlayerName[MAX_NAME_LENGTH];
Menu menu2 = CreateMenu(ChallengeMenuHandler3);
SetMenuTitle(menu2, "ckSurf - Challenge: Select your Opponent");
int playerCount = 0;
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && IsPlayerAlive(i) && i != param1 && !IsFakeClient(i))
{
GetClientName(i, szPlayerName, MAX_NAME_LENGTH);
AddMenuItem(menu2, szPlayerName, szPlayerName);
playerCount++;
}
}
if (playerCount > 0)
{
SetMenuOptionFlags(menu2, MENUFLAG_BUTTON_EXIT);