-
Notifications
You must be signed in to change notification settings - Fork 25
/
dumb_menu.cpp
3705 lines (3085 loc) · 105 KB
/
dumb_menu.cpp
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
/*
PROJECT: mod_sa
LICENSE: See LICENSE in the top level directory
COPYRIGHT: Copyright we_sux, BlastHack
mod_sa is available from https://github.com/BlastHackNet/mod_s0beit_sa/
mod_sa is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
mod_sa is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with mod_sa. If not, see <http://www.gnu.org/licenses/>.
*/
#include "main.h"
#define ID_NONE - 1
#define ID_MENU_MAIN 0
#define ID_MENU_CHEATS 1
#define ID_MENU_CHEATS_INVULN 1
#define ID_MENU_CHEATS_MONEY 2
#define ID_MENU_CHEATS_MODS 135
#define ID_MENU_CHEATS_WEATHER 5
#define ID_MENU_CHEATS_TIME 6
#define ID_MENU_CHEATS_HANDLING 111
#define ID_MENU_PATCHES 7
#define ID_MENU_WEAPONS 8
#define ID_MENU_VEHICLES 9
#define ID_MENU_TELEPORTS 11
#define ID_MENU_MISC 12
#define ID_MENU_DEBUG 13
#define ID_MENU_PLAYERS 14
#define ID_MENU_PLAYERS_WARP 100
#define ID_MENU_PLAYERS_VEHWARP 101
#define ID_MENU_PLAYERS_SPEC 102
#define ID_MENU_PLAYERS_INFO 113
#define ID_MENU_PLAYERS_MUTE 114
#define ID_MENU_PLAYERS_VMUTE 115
#define ID_MENU_SAMPPATCHES 20
#define ID_MENU_SERVER_LIST 21
#define ID_MENU_HUDINDICATORS 22
#define ID_MENU_INTERIORS 23
#ifdef __CHEAT_VEHRECORDING_H__
#define ID_MENU_ROUTES 26
#define ID_MENU_ROUTES_LOAD 27
#define ID_MENU_ROUTES_DROP 28
#endif
#define ID_CHEAT_INVULN 10
#define ID_CHEAT_WEAPONS 20
#define ID_CHEAT_MONEY 30
#define ID_CHEAT_MODS 40
#define ID_CHEAT_PROT 50
#define ID_CHEAT_WARP_NEAR 60
#define ID_CHEAT_JETPACK 70
#define ID_CHEAT_UNLOCK 80
#define ID_CHEAT_WEATHER 90
#define ID_CHEAT_TIME 100
#define ID_CHEAT_HP 110
#define ID_CHEAT_ARMOR 120
#define ID_CHEAT_GRAVITY 130
#define ID_CHEAT_MAP 140
#define ID_CHEAT_TELETEXTS 150
#define ID_CHEAT_GAME_SPEED 160
#define ID_CHEAT_HANDLING 170
#define ID_CHEAT_KEEP_TRAILER 180
#define ID_CHEAT_NOCOLS 190
#define ID_CHEAT_CHAMS 200
#define ID_CHEAT_CUSTOM_RUNSTYLE 210
#define ID_CHEAT_FLY_SPEED 220
#define ID_CHEAT_DISABLE_WAVES 230
#define ID_CHEAT_MAP_DRAW_LINES 231
#define ID_CHEAT_SURF 232
#define ID_CHEAT_FREEZEROT 233
#define ID_CHEAT_INVULN_ACTOR 0
#define ID_CHEAT_INVULN_VEHICLE 1
#define ID_CHEAT_INVULN_TIRES 2
#define ID_CHEAT_INVULN_MIN_HP 3
#define ID_CHEAT_INVULN_REGEN 5
#define ID_CHEAT_INVULN_REGEN_ONFOOT 6
#define ID_CHEAT_INVULN_DISABLE_EXTRA_INV 7
#define ID_CHEAT_INVULN_ACT_EXPL_INV 8
#define ID_CHEAT_INVULN_ACT_FALL_INV 9
#define ID_CHEAT_INVULN_ACT_FIRE_INV 10
#define ID_CHEAT_MONEY_GIVE_500 0
#define ID_CHEAT_MONEY_GIVE_1000 1
#define ID_CHEAT_MONEY_GIVE_5000 2
#define ID_CHEAT_MONEY_GIVE_10000 3
#define ID_CHEAT_MONEY_GIVE_20000 4
#define ID_CHEAT_MONEY_GIVE_99999999 5
#define ID_CHEAT_MONEY_GIVE_CUSTOM 6
#define ID_CHEAT_MONEY_MAX 7
#define ID_CHEAT_MONEY_RAND_MIN 8
#define ID_CHEAT_MONEY_RAND_MAX 9
#define ID_CHEAT_MONEY_IVAL_MIN 10
#define ID_CHEAT_MONEY_IVAL_MAX 11
#define ID_CHEAT_MODS_COLOR1 10
#define ID_CHEAT_MODS_COLOR2 20
#define ID_CHEAT_MODS_PAINTJOB 30
#define ID_CHEAT_HANDLING_MASS 0
#define ID_CHEAT_HANDLING_TURNMASS 1
#define ID_CHEAT_HANDLING_DRAGCOEFF 2
#define ID_CHEAT_HANDLING_TRACMULT 3
#define ID_CHEAT_HANDLING_ENGNACCEL 4
#define ID_CHEAT_HANDLING_MAXVEL 5
#define ID_CHEAT_HANDLING_BRAKEDECEL 6
#define ID_CHEAT_HANDLING_SUSPFORCELVL 7
#define ID_CHEAT_HANDLING_COLDMGMULT 8
#define ID_CHEAT_HANDLING_MULTIPLIER 9
#define ID_CHEAT_HANDLING_TRACTIONLOSS 10
#define ID_CHEAT_HANDLING_TRACTIONBIAS 11
#define ID_CHEAT_HANDLING_SUSPANTIDIVEMULT 12
#define ID_WEAPON_ENABLE 0
#define ID_WEAPON_RANDOM 1
#define ID_WEAPON_ITEM 2
#define ID_VEHICLES_IWARP 0
#define ID_VEHICLES_FREEZE 1
#define ID_MENU_VEHICLES_SUB 106
#define ID_MISC_COORDS 0
#define ID_MISC_RELOAD 1
#define ID_MISC_HUDTEXT 2
#define ID_MISC_BAD_WEAPONS 3
#define ID_MISC_TRAILERS 4
#define ID_MISC_FPSLIMIT 5
#define ID_MISC_TOGGLEWINDOWED 6
#define ID_DEBUG_ENABLE 0
#define ID_DEBUG_SELF_ACTOR 1
#define ID_DEBUG_SAMP_DLL 2
#define ID_DEBUG_SELF_VEHICLE 3
#define ID_DEBUG_SAMP_INFO 4
#define ID_DEBUG_SAMP_PLAYER_LIST 5
#define ID_DEBUG_SAMP_LOCAL_INFO 6
#define ID_DEBUG_SAMP_CHAT_INFO 7
#define ID_DEBUG_SAMP_CHAT_IPT_INFO 8
#define ID_DEBUG_SAMP_KILL_INFO 9
#define ID_DEBUG_SAMP_VEHICLE_LIST 10
#define ID_DEBUG_SAMP_LOCAL_SAMPPED 11
#ifdef __CHEAT_VEHRECORDING_H__
#define ID_ROUTES_ACTIVATED 0
#define ID_ROUTES_WRITE 1
#define ID_ROUTES_OPTIMIZE 2
#endif
#define ID_HUDIND_BAR 0
#define ID_HUDIND_TSHADOWS 1
#define ID_HUDIND_INV 2
#define ID_HUDIND_WEAPON 3
#define ID_HUDIND_MONEY 4
#define ID_HUDIND_FREEZE 5
#define ID_HUDIND_INVEH_AIRBRK 6
#define ID_HUDIND_INVEH_STICK 7
#define ID_HUDIND_INVEH_BRKDANCE 8
#define ID_HUDIND_ONFOOT_AIRBRK 9
#define ID_HUDIND_ONFOOT_STICK 10
#define ID_HUDIND_ONFOOT_AIM 11
#define ID_HUDIND_POS 12
#define ID_HUDIND_FPS 13
#define ID_HUDIND_LB_BARS 14
#define ID_HUDIND_INVEH_SPIDER 15
#define ID_HUDIND_INVEH_FLY 16
#define ID_HUDIND_ONFOOT_FLY 17
#define ID_HUDIND_SURF 18
#define ID_HUDIND_FREEZEROT 19
#define ID_MENU_SAMPMISC 0
#define ID_MENU_SAMPMISC_VEHICLES_INSTANT 108
#define ID_MENU_SAMPMISC_FAKE_KILL 105
#define ID_MENU_SAMPMISC_SPOOF_WEAPON 3
#define ID_MENU_SAMPMISC_SAMP_INFO_LIST 4
#define ID_MENU_SAMPMISC_CHAT_TEXT 6
#define ID_MENU_SAMPMISC_CHAT_TEXTLINES 7
#define ID_MENU_SAMPMISC_GAMESTATE 9
#define ID_MENU_SAMPMISC_SPECIALACTION 12
#define ID_MENU_SAMPMISC_SAMP_DRUNK 13
#define ID_MENU_SAMPMISC_TELEOBJECT 109
#define ID_MENU_SAMPMISC_TELEPICKUP 110
#define ID_MENU_SAMPMISC_RENDEROBJTXT 15
#define ID_MENU_SAMPMISC_RENDERPCKTXT 16
#define ID_MENU_SAMPMISC_M0DCOMMANDS 17
#define ID_MENU_SAMPMISC_EXTRAGM 18
#define ID_MENU_SPECIAL_ACTION_NONE 0
#define ID_MENU_SPECIAL_ACTION_USEJETPACK 2
#define ID_MENU_SPECIAL_ACTION_DANCE1 5
#define ID_MENU_SPECIAL_ACTION_DANCE2 6
#define ID_MENU_SPECIAL_ACTION_DANCE3 7
#define ID_MENU_SPECIAL_ACTION_DANCE4 8
#define ID_MENU_SPECIAL_ACTION_HANDSUP 10
#define ID_MENU_SPECIAL_ACTION_USECELLPHONE 11
#define ID_MENU_SPECIAL_ACTION_STOPUSECELLPHONE 13
#define ID_MENU_SPECIAL_ACTION_DRINK_BEER 20
#define ID_MENU_SPECIAL_ACTION_SMOKE_CIGGY 21
#define ID_MENU_SPECIAL_ACTION_DRINK_WINE 22
#define ID_MENU_SPECIAL_ACTION_DRINK_SPRUNK 23
#define ID_MENU_SPECIAL_ACTION_CUFFED 24
#define ID_MENU_SPECIAL_ACTION_CARRY 25
#define ID_MENU_SPECIAL_ACTION_URINATE 68
#define ID_MENU_NETPATCHES_INRPC 10024
#define ID_MENU_NETPATCHES_OUTRPC 10025
#define ID_MENU_NETPATCHES_INPACKET 10026
#define ID_MENU_NETPATCHES_OUTPACKET 10027
#define ID_MENU_NETPATCHES_TOGGLE_ALL INI_NETPATCHES_MAX
struct menu *menu_active = NULL;
int menu_init = 0, menu_mouseover = -1;
extern int iGTAPatchesCount, iSAMPPatchesCount, iNetPatchesCount, iServersCount;
static struct menu *menu_new ( struct menu *parent, int id, menu_callback callback )
{
struct menu *menu = (struct menu *)calloc( 1, sizeof(struct menu) );
if ( menu == NULL )
return NULL;
menu->id = id;
menu->parent = parent;
menu->callback = callback;
return menu;
}
static struct menu_item *menu_item_add ( struct menu *menu, struct menu *submenu, const char *name, int id,
D3DCOLOR color, void *data )
{
struct menu_item *item;
int i;
i = menu->count++;
menu->item = (struct menu_item *)realloc( menu->item, sizeof(struct menu_item) * menu->count );
item = &menu->item[i];
memset( item, 0, sizeof(menu_item) );
item->submenu = submenu;
item->menu = menu;
item->name = _strdup( name );
item->id = id;
item->color = color;
item->data = data;
return item;
}
static void menu_item_name_set ( struct menu_item *item, const char *fmt, ... )
{
const char *name_new;
char name[64];
va_list ap;
memset( name, 0, sizeof(name) );
va_start( ap, fmt );
vsnprintf( name, sizeof(name)-1, fmt, ap );
va_end( ap );
if ( (name_new = _strdup(name)) != NULL )
{
free( (void *)item->name );
item->name = name_new;
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//menu_callback_cheats_mods
static void menu_cheats_mods_populate ( struct menu *menu )
{
// clear menu
menu_items_free( menu );
// get vehicle_info
struct vehicle_info *vinfo = vehicle_info_get( VEHICLE_SELF, 0 );
if ( vinfo == NULL )
return;
struct actor_info *ainfo = actor_info_get( ACTOR_SELF, 0 );
if ( vinfo->passengers[0] != ainfo )
return;
// some variables
int iModelID = vinfo->base.model_alt_id;
char name[64];
/* i... like... colors & paint
#define ID_CHEAT_MODS_COLOR1 10
#define ID_CHEAT_MODS_COLOR2 20
#define ID_CHEAT_MODS_PAINTJOB 30
*/
snprintf( name, sizeof(name), "Color 1: %d", vinfo->color[0] );
menu_item_add( menu, NULL, name, ID_CHEAT_MODS_COLOR1, MENU_COLOR_DEFAULT, NULL );
snprintf( name, sizeof(name), "Color 2: %d", vinfo->color[1] );
menu_item_add( menu, NULL, name, ID_CHEAT_MODS_COLOR2, MENU_COLOR_DEFAULT, NULL );
snprintf( name, sizeof(name), "Paintjob: %d", vehicle_getPaintJob(vinfo) );
menu_item_add( menu, NULL, name, ID_CHEAT_MODS_PAINTJOB, MENU_COLOR_DEFAULT, NULL );
// No upgrades for these types
eClientVehicleType vehicleType = GetVehicleType( iModelID );
if ( vehicleType == CLIENTVEHICLE_BOAT
|| vehicleType == CLIENTVEHICLE_TRAIN
|| vehicleType == CLIENTVEHICLE_HELI
|| vehicleType == CLIENTVEHICLE_PLANE
|| vehicleType == CLIENTVEHICLE_BIKE
|| vehicleType == CLIENTVEHICLE_BMX ) return;
for ( int iUpgradeInfo = 0; iUpgradeInfo < VEHICLE_UPGRADES_COUNT; iUpgradeInfo++ )
{
if ( isUpgradeCompatible(cveh_upgrade_info[iUpgradeInfo].iModelID, vinfo) )
{
snprintf( name, sizeof(name), "%s %s", cveh_upgrade_info[iUpgradeInfo].upgradeCategoryName,
cveh_upgrade_info[iUpgradeInfo].upgradeName );
menu_item_add( menu, NULL, name, cveh_upgrade_info[iUpgradeInfo].iModelID, MENU_COLOR_DEFAULT, NULL );
// skip matching sideskirt
if ( cveh_upgrade_info[iUpgradeInfo].upgradeCategoryName == "Sideskirt"
|| cveh_upgrade_info[iUpgradeInfo].upgradeCategoryName == "Vents" ) iUpgradeInfo++;
}
}
}
static void menu_cheats_spoof_kill_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL )
return;
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PLAYERS; i++ )
{
D3DCOLOR color = MENU_COLOR_DEFAULT;
if ( g_Players->iIsListed[i] != 1 )
continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData == NULL )
continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData->pSAMP_Actor == NULL )
continue;
if ( g_Players->pRemotePlayer[i] != NULL )
color = samp_color_get( i );
snprintf( text, sizeof(text), "Fake killed by %s (ID: %d)", getPlayerName(i), i );
menu_item_add( menu, NULL, text, ID_MENU_SAMPMISC_FAKE_KILL, color, (void *)(UINT_PTR) i );
}
}
static void menu_vehicles_populate ( struct menu *menu, int class_id )
{
const struct actor_info *actor_self = actor_info_get( ACTOR_SELF, 0 );
char name[64];
int i;
menu_items_free( menu );
if ( pool_vehicle != NULL )
{
for ( i = 0; i < pool_vehicle->size; i++ )
{
static const struct vehicle_entry unknown = { 0, VEHICLE_CLASS_CAR, "[Unknown vehicle]" };
const struct vehicle_info *info = vehicle_info_get( i, VEHICLE_ALIVE );
const struct vehicle_entry *vehicle;
float dist[3] = { 0.0f, 0.0f, 0.0f };
if ( info == NULL )
continue;
vehicle = gta_vehicle_get_by_id( info->base.model_alt_id );
if ( vehicle == NULL )
vehicle = &unknown;
if ( vehicle->class_id != class_id )
continue;
if ( actor_self != NULL )
vect3_vect3_sub( &info->base.matrix[4 * 3], &actor_self->base.matrix[4 * 3], dist );
if ( vect3_near_zero( &info->base.matrix[4 * 3] ) )
continue;
snprintf( name, sizeof(name), "%s (%.2fm%s)", vehicle->name, vect3_length(dist),
(info->passengers[0] == NULL) ? "" : ", Occupied" );
menu_item_add( menu, NULL, name, i, MENU_COLOR_DEFAULT, NULL );
}
}
}
static void menu_players_warp_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL )
return;
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PLAYERS; i++ )
{
D3DCOLOR color = MENU_COLOR_DEFAULT;
if ( g_Players->iIsListed[i] != 1 )
continue;
if(g_Players->pRemotePlayer[i] == NULL)
continue;
// can obtain position data?
if( vect3_near_zero(g_stStreamedOutInfo.fPlayerPos[i])
&& (g_Players->pRemotePlayer[i]->pPlayerData == NULL ||
g_Players->pRemotePlayer[i]->pPlayerData->pSAMP_Actor == NULL) )
continue;
color = samp_color_get( i );
snprintf( text, sizeof(text), "%s (ID: %d)", getPlayerName(i), i );
menu_item_add( menu, NULL, text, i, color, NULL );
}
}
static void menu_players_vehwarp_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL )
return;
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PLAYERS; i++ )
{
D3DCOLOR color = MENU_COLOR_DEFAULT;
if ( g_Players->iIsListed[i] != 1 )
continue;
if ( g_Players->pRemotePlayer[i] == NULL )
continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData == NULL )
continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData->pSAMP_Actor == NULL )
continue;
//if(vect3_near_zero(g_stStreamedOutInfo.fPlayerPos[i])) continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData->bytePlayerState != PLAYER_STATE_DRIVER
&& g_Players->pRemotePlayer[i]->pPlayerData->bytePlayerState != PLAYER_STATE_PASSENGER ) continue;
if ( g_Players->pRemotePlayer[i] != NULL )
color = samp_color_get( i );
snprintf( text, sizeof(text), "%s (ID: %d)", getPlayerName(i), i );
menu_item_add( menu, NULL, text, i, color, NULL );
}
}
static void menu_vehicles_instant_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL && g_Vehicles == NULL )
return;
const struct vehicle_entry *vehicle;
char text[64];
int v;
for ( v = 0; v < SAMP_MAX_VEHICLES; v++ )
{
if ( g_Vehicles->iIsListed[v] != 1 )
continue;
if ( g_Vehicles->pSAMP_Vehicle[v] == NULL )
continue;
if ( g_Vehicles->pSAMP_Vehicle[v]->pGTA_Vehicle == NULL )
continue;
vehicle = gta_vehicle_get_by_id( g_Vehicles->pSAMP_Vehicle[v]->pGTA_Vehicle->base.model_alt_id );
snprintf( text, sizeof(text), "%s (ID: %d)", vehicle->name, v );
menu_item_add( menu, NULL, text, v, D3DCOLOR_XRGB(150, 150, 150), NULL );
}
}
static void menu_players_spectator_mode_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL )
return;
menu_item_add( menu, NULL, "Disable", ID_NONE, MENU_COLOR_DEFAULT, NULL );
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PLAYERS; i++ )
{
D3DCOLOR color = MENU_COLOR_DEFAULT;
if ( g_Players->iIsListed[i] != 1 )
continue;
if ( g_Players->pRemotePlayer[i] == NULL )
continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData == NULL )
continue;
if ( g_Players->pRemotePlayer[i]->pPlayerData->pSAMP_Actor == NULL )
continue;
color = samp_color_get( (int)g_Players->pRemotePlayer[i]->pPlayerData->sPlayerID );
snprintf( text, sizeof(text), "Spectate %s (ID: %d)", getPlayerName(i), i );
menu_item_add( menu, NULL, text, i, color, (void *)(UINT_PTR) i );
}
}
static void menu_telepickup_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_SAMP->pPools->pPickup == NULL )
return;
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PICKUPS; i++ )
{
if ( g_SAMP->pPools->pPickup->pickup[i].iModelID == 0 )
continue;
if ( g_SAMP->pPools->pPickup->pickup[i].iType == 0 )
continue;
D3DCOLOR color = MENU_COLOR_DEFAULT;
snprintf( text, sizeof(text), "Pickup (%d, ModelID: %d)", i, g_SAMP->pPools->pPickup->pickup[i].iModelID );
menu_item_add( menu, NULL, text, i, color, NULL );
}
}
static int menu_callback_telepickup ( int op, struct menu_item *item )
{
if ( op == MENU_OP_SELECT )
{
int id = item->id;
if ( g_SAMP->pPools->pPickup == NULL )
return 0;
if ( g_SAMP->pPools->pPickup->pickup[id].iType == 0 )
return 0;
if ( g_SAMP->pPools->pPickup->pickup[id].iModelID == 0 )
return 0;
if ( item->id == ID_NONE )
return 0;
float pos[3];
vect3_copy( g_SAMP->pPools->pPickup->pickup[id].fPosition, pos );
pos[1] += 2.0f;
cheat_teleport( pos, 0 );
return 1;
}
return 0;
}
static void menu_teleobject_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_SAMP->pPools->pObject == NULL )
return;
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_OBJECTS; i++ )
{
D3DCOLOR color = MENU_COLOR_DEFAULT;
if ( g_SAMP->pPools->pObject->iIsListed[i] != 1 )
continue;
if ( g_SAMP->pPools->pObject->object[i] == NULL )
continue;
if ( g_SAMP->pPools->pObject->object[i]->pGTAEntity == NULL )
continue;
float pos[3];
vect3_copy( &g_SAMP->pPools->pObject->object[i]->pGTAEntity->base.matrix[4 * 3], pos );
if ( vect3_near_zero(pos) )
continue;
snprintf( text, sizeof(text), "Object (%d, ModelID %d)", i,
g_SAMP->pPools->pObject->object[i]->pGTAEntity->base.model_alt_id );
menu_item_add( menu, NULL, text, i, color, NULL );
}
}
static int menu_callback_teleobject ( int op, struct menu_item *item )
{
if ( op == MENU_OP_SELECT )
{
if ( g_SAMP->pPools->pObject == NULL )
return 0;
if ( item->id == ID_NONE )
return 0;
int id = item->id;
float pos[3];
if ( g_SAMP->pPools->pObject->iIsListed[id] != 1 )
{
addMessageToChatWindow( "Object does not exist." );
return 0;
}
if ( g_SAMP->pPools->pObject->object[id]->pGTAEntity == NULL )
{
addMessageToChatWindow( "Invalid object info." );
return 0;
}
vect3_copy( &g_SAMP->pPools->pObject->object[id]->pGTAEntity->base.matrix[4 * 3], pos );
pos[2] += 2.0f;
cheat_teleport( pos, 0 );
return 1;
}
return 0;
}
static void menu_handling_populate ( struct menu *menu )
{
CVehicle *cveh = getSelfCVehicle();
if ( cveh == NULL )
return;
if ( cveh->GetHandlingData() == NULL )
return;
traceLastFunc( "menu_handling_populate()" );
char text[64];
menu_items_free( menu );
snprintf( text, sizeof(text), "Multiplier: %0.2f", set.handling_multiplier );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_MULTIPLIER, MENU_COLOR_DEFAULT, NULL );
menu_item_add( menu, NULL, "\tHandling", ID_NONE, MENU_COLOR_SEPARATOR, NULL );
snprintf( text, sizeof(text), "Engine acceleration: %0.2f", cveh->GetHandlingData()->GetEngineAccelleration() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_ENGNACCEL, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Brake decelleration: %0.2f", cveh->GetHandlingData()->GetBrakeDecelleration() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_BRAKEDECEL, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Drag coefficient: %0.2f", cveh->GetHandlingData()->GetDragCoeff() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_DRAGCOEFF, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Max velocity: %0.2f", cveh->GetHandlingData()->GetMaxVelocity() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_MAXVEL, MENU_COLOR_DEFAULT, NULL );
// these can't be used because they don't always show up right etc... possibly mapped wrong
snprintf( text, sizeof(text), "Traction multiplier: %0.2f", cveh->GetHandlingData()->GetTractionMultiplier() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_TRACMULT, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Traction loss: %0.2f", cveh->GetHandlingData()->GetTractionLoss() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_TRACTIONLOSS, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Traction bias: %0.2f", cveh->GetHandlingData()->GetTractionBias() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_TRACTIONBIAS, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Suspension force level: %0.2f", cveh->GetHandlingData()->GetSuspensionForceLevel() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_SUSPFORCELVL, MENU_COLOR_DEFAULT, NULL );
//snprintf( text, sizeof(text), "Suspension anti-dive multiplier: %0.2f", cveh->GetHandlingData()->GetSuspensionAntidiveMultiplier() );
//menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_SUSPANTIDIVEMULT, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Mass: %0.2f", cveh->GetHandlingData()->GetMass() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_MASS, MENU_COLOR_DEFAULT, NULL );
snprintf( text, sizeof(text), "Turn mass: %0.2f", cveh->GetHandlingData()->GetTurnMass() );
menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_TURNMASS, MENU_COLOR_DEFAULT, NULL );
//snprintf( text, sizeof(text), "Collision damage multiplier: %0.2f",
// cveh->GetHandlingData()->GetCollisionDamageMultiplier() );
//menu_item_add( menu, NULL, text, ID_CHEAT_HANDLING_COLDMGMULT, MENU_COLOR_DEFAULT, NULL );
}
static void menu_playerinfo_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL )
return;
menu_item_add( menu, NULL, "Disable", SAMP_MAX_PLAYERS + 1, MENU_COLOR_DEFAULT, NULL );
menu_item_add( menu, NULL, "Local Player", -2, MENU_COLOR_DEFAULT, (void *)(UINT_PTR) - 2 );
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PLAYERS; i++ )
{
if ( g_Players->iIsListed[i] != 1 )
continue;
if ( g_Players->pRemotePlayer[i] == NULL )
continue;
snprintf( text, sizeof(text), "View %s (ID: %d)", getPlayerName(i), i );
menu_item_add( menu, NULL, text, i, MENU_COLOR_DEFAULT, (void *)(UINT_PTR) i );
}
}
static void menu_playermute_populate ( struct menu *menu )
{
menu_items_free( menu );
if ( g_Players == NULL )
return;
char text[64];
int i;
for ( i = 0; i < SAMP_MAX_PLAYERS; i++ )
{
if ( g_Players->iIsListed[i] != 1 || g_Players->pRemotePlayer[i] == NULL )
{
g_bPlayerMuted[i] = false;
continue;
}
snprintf( text, sizeof(text), "Mute %s (ID: %d)", getPlayerName(i), i );
menu_item_add( menu, NULL, text, i, MENU_COLOR_DEFAULT, (void *)(UINT_PTR) i );
}
}
#ifdef __CHEAT_VEHRECORDING_H__
static void menu_routes_drop_populate ( struct menu *menu )
{
menu_items_free( menu );
// now get me some data from the database
char table_name_[64];
char *table_name;
int num_tables = rec_sqlite_getNumTables();
if ( num_tables <= 0 )
{
menu_item_add( menu, NULL, (num_tables < 0) ? "Error Reading Database" : "No Saved Routes", ID_NONE,
MENU_COLOR_DEFAULT, NULL );
return;
}
for ( int i = 0; i < num_tables; i++ )
{
table_name = rec_sqlite_getTableName(i);
if ( table_name == NULL )
continue;
// remember to change menu_callback_routes_drop, if you change the "Delete" text
_snprintf_s( table_name_, sizeof(table_name_)-1, "Delete '%s'", table_name );
menu_item_add( menu, NULL, table_name_, i, MENU_COLOR_DEFAULT, NULL );
}
}
static void menu_routes_load_populate ( struct menu *menu )
{
menu_items_free( menu );
// now get me some data from the database
int num_tables = rec_sqlite_getNumTables();
char *table_name;
if ( num_tables <= 0 )
{
menu_item_add( menu, NULL, (num_tables < 0) ? "Error Reading Database" : "No Saved Routes", ID_NONE,
MENU_COLOR_DEFAULT, NULL );
return;
}
for ( int i = 0; i < num_tables; i++ )
{
table_name = rec_sqlite_getTableName(i);
if ( table_name == NULL )
continue;
menu_item_add( menu, NULL, table_name, i, MENU_COLOR_DEFAULT, NULL );
}
}
#endif
// called when a menu is going to be displayed
static void menu_event_activate ( struct menu *menu )
{
if ( menu == NULL )
return;
switch ( menu->id )
{
case ID_MENU_CHEATS_MODS:
menu_cheats_mods_populate( menu );
break;
case ID_MENU_PLAYERS_WARP:
menu_players_warp_populate( menu );
break;
case ID_MENU_PLAYERS_VEHWARP:
menu_players_vehwarp_populate( menu );
break;
case ID_MENU_PLAYERS_SPEC:
menu_players_spectator_mode_populate( menu );
break;
case ID_MENU_SAMPMISC_FAKE_KILL:
menu_cheats_spoof_kill_populate( menu );
break;
case ID_MENU_VEHICLES_SUB:
menu_vehicles_populate( menu, (int)(UINT_PTR) menu->parent->item[menu->parent->pos].data );
break;
case ID_MENU_SAMPMISC_VEHICLES_INSTANT:
menu_vehicles_instant_populate( menu );
break;
case ID_MENU_SAMPMISC_TELEOBJECT:
menu_teleobject_populate( menu );
break;
case ID_MENU_SAMPMISC_TELEPICKUP:
menu_telepickup_populate( menu );
break;
case ID_MENU_CHEATS_HANDLING:
menu_handling_populate( menu );
break;
case ID_MENU_PLAYERS_INFO:
menu_playerinfo_populate( menu );
break;
case ID_MENU_PLAYERS_MUTE:
menu_playermute_populate( menu );
break;
#ifdef __CHEAT_VEHRECORDING_H__
case ID_MENU_ROUTES_DROP:
menu_routes_drop_populate( menu );
break;
case ID_MENU_ROUTES_LOAD:
menu_routes_load_populate( menu );
break;
#endif
}
}
/* run every frame */
void menu_run ( void )
{
struct menu_item *item;
static uint32_t key_time_updown, key_time_incdec;
if ( menu_active == NULL )
return;
if ( KEYCOMBO_PRESSED(set.key_menu) )
{
menu_toggle((cheat_state->_generic.menu ^= 1) != 0);
}
if ( cheat_state->_generic.menu )
{
if ( KEY_PRESSED(set.key_menu_up) || KEY_PRESSED(set.key_menu_down) )
{
menu_active->pos += KEY_PRESSED( set.key_menu_up ) ? -1 : 1;
key_time_updown = time_get() + MSEC_TO_TIME( MENU_SCROLL_DELAY );
}
if ( KEY_DOWN(set.key_menu_up) || KEY_DOWN(set.key_menu_down) )
{
if ( time_get() > key_time_updown )
{
int diff = time_get() - key_time_updown;
int overruns = diff / MENU_SCROLL_TIME;
int dir = KEY_DOWN( set.key_menu_up ) ? -1 : 1;
menu_active->pos += dir * ( overruns + 1 );
key_time_updown = time_get() + MENU_SCROLL_TIME - ( diff % MENU_SCROLL_TIME );
}
}
if ( menu_active->pos < 0 )
menu_active->pos = menu_active->count - 1;
if ( menu_active->pos >= menu_active->count )
menu_active->pos = 0;
if ( menu_active->count <= 0 )
item = NULL;
else
item = &menu_active->item[menu_active->pos];
if ( KEY_PRESSED(set.key_menu_left) )
{
/* pressing left in the main menu, exits the menu */
if ( menu_active->parent == NULL )
{
menu_toggle(false);
return;
}
menu_active = menu_active->parent;
menu_event_activate( menu_active );
}
if ( KEY_PRESSED(set.key_menu_right) || KEY_PRESSED(set.key_menu_select) )
{
int was_selected = 0;
if ( KEY_PRESSED(set.key_menu_select) && menu_active->callback != NULL && item != NULL )
{
if ( menu_active->callback(MENU_OP_SELECT, item) )
was_selected = 1;
}
if ( !was_selected && item != NULL && item->submenu != NULL )
{
menu_active = item->submenu;
menu_event_activate( menu_active );
}
}
if ( KEY_PRESSED(set.key_menu_dec) || KEY_PRESSED(set.key_menu_inc) )
{
int op = KEY_PRESSED( set.key_menu_dec ) ? MENU_OP_DEC : MENU_OP_INC;
if ( item != NULL )
menu_active->callback( op, item );
key_time_incdec = time_get() + MSEC_TO_TIME( MENU_SCROLL_DELAY );
}
if ( KEY_DOWN(set.key_menu_dec) || KEY_DOWN(set.key_menu_inc) )
{
if ( time_get() > key_time_incdec )
{
int diff = time_get() - key_time_incdec;
int overruns = diff / MENU_SCROLL_TIME;
int op = KEY_DOWN( set.key_menu_dec ) ? MENU_OP_DEC : MENU_OP_INC;
menu_active->callback( op, item );
key_time_incdec = time_get() + MENU_SCROLL_TIME - ( diff % MENU_SCROLL_TIME );
}
}
KEY_CONSUME( set.key_menu_up );
KEY_CONSUME( set.key_menu_right );
KEY_CONSUME( set.key_menu_down );
KEY_CONSUME( set.key_menu_left );
KEY_CONSUME( set.key_menu_select );
KEY_CONSUME( set.key_menu_dec );
KEY_CONSUME( set.key_menu_inc );
}
}
bool menu_wndproc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MOUSEWHEEL:
{
if (menu_active == NULL || !cheat_state->_generic.menu || !cheat_state->_generic.menu_mousecontrol)
break;
POINT point = { LOWORD(lParam), HIWORD(lParam) };
const int ROW_HEIGHT = (int)ceilf(pD3DFont->DrawHeight());
const int MENU_HEIGHT = (int)ceilf(pD3DFont->DrawHeight() * (float)MENU_ROWS) + 2;
int left = pPresentParam.BackBufferWidth / 2 - MENU_WIDTH / 2;
int top = pPresentParam.BackBufferHeight - MENU_HEIGHT - 20;
int pos = 0;
if (uMsg == WM_MOUSEWHEEL)
{
// WM_MOUSEWHEEL has global cursor coords
ScreenToClient(pPresentParam.hDeviceWindow, &point);
if (LOWORD(wParam) == MK_SHIFT)
{
menu_item *item = nullptr;
if (menu_active->count > 0)
item = &menu_active->item[menu_active->pos];
int op = short(HIWORD(wParam)) > 0 ? MENU_OP_INC : MENU_OP_DEC;