-
Notifications
You must be signed in to change notification settings - Fork 57
/
fixes.inc
8923 lines (8154 loc) · 264 KB
/
fixes.inc
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
/*
* ===============
* INTRODUCTION:
* ===============
*
* fixes.inc - Community patch for buggy SA:MP functions.
*
* ================
* LIST OF FIXES:
* ================
*
* FIX: GetPlayerColor
* PROBLEM: Returns "0" if "SetPlayerColor" has never been called.
* SOLUTION: Call "SetPlayerColor" in "OnPlayerConnect".
* SEE: "OnPlayerConnect".
* AUTHOR: KoczkaHUN
*
* FIX: FILTERSCRIPT
* PROBLEM: Despite the fact that is in every new script, many people don't
* define "FILTERSCRIPT" where appropriate.
* SOLUTION: Provide an "IS_FILTERSCRIPT" variable (note the naming to match
* the original macro).
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* SEE: "OnFilterScriptInit" and "OnGameModeInit".
*
* FIX: SpawnPlayer
* PROBLEM: Kills the player if they are in a vehicle.
* SOLUTION: Remove the from the vehicle.
* SEE: "FIXES_SpawnPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetPlayerName
* PROBLEM: Using "SetPlayerName" when the new name only differs from the old
* name in case does not alter the name at all.
* SOLUTION: Change their name twice - once to "_FIXES TEMP NAME" and then to
* the actual required name.
* SEE: "OnPlayerConnect" and "FIXES_SetPlayerName".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* AUTHOR: Slice (https://github.com/oscar-broman/)
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: GetPlayerSkin
* PROBLEM: Returns the new skin after "SetSpawnInfo" is called but before the
* player actually respawns to get the new skin.
* SOLUTION: Record the skin in "OnPlayerSpawn" and always return that one.
* SEE: "OnPlayerSpawn", "FIXES_GetPlayerSkin" and "FIXES_SetPlayerSkin".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GetWeaponName
* PROBLEM: Returns nothing for 18, 44, and 45.
* SOLUTION: Return the correct names ("Molotov Cocktail", "Thermal Goggles",
* and "Night vision Goggles").
* SEE: "FIXES_GetWeaponName".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* FIXED IN: 0.3.7
*
* FIX: SetPlayerWorldBounds
* PROBLEM: Aiming can bypass the edge.
* SOLUTION: Check for the player leaving the area and reset them to their last
* good position if they leave the area (aiming or not).
* SEE: "OnPlayerUpdate" and "FIXES_SetPlayerWorldBounds".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: TogglePlayerControllable
* PROBLEM: Other players see you moving on the spot.
* SOLUTION: Return 0 in OnPlayerUpdate.
* SEE: "FIXES_TogglePlayerControllable" and "OnPlayerUpdate".
* AUTHOR: Slice (https://github.com/oscar-broman/)
* POST: http://forum.sa-mp.com/showpost.php?p=876854
*
* FIX: HydraSniper
* PROBLEM: Entering military aircraft with a sniper rifle messes up views.
* SOLUTION: Set their armed weapon to fists.
* SEE: "OnPlayerStateChange", "FIXES_GivePlayerWeapon",
* "FIXES_SetPlayerArmedWeapon".
* AUTHOR: funky1234
* POST: http://forum.sa-mp.com/showpost.php?p=965644
*
* FIX: IsPlayerInCheckpoint
* PROBLEM: Function returns an undefined value if it is called before any
* other checkpoint functions are called to initialise the value.
* SOLUTION: Call "DisablePlayerCheckpoint" when they connect.
* SEE: "OnPlayerConnect".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: IsPlayerInRaceCheckpoint
* PROBLEM: Function returns an undefined value if it is called before any
* other race checkpoint functions are called to initialise the value.
* SOLUTION: Call "DisablePlayerRaceCheckpoint" when they connect.
* SEE: "OnPlayerConnect".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GetPlayerWeapon
* PROBLEM: Returns the old value after entering in a vehicle.
* SOLUTION: If "SetPlayerArmedWeapon" and other similar functions is called in
* a vehicle, store the new value and return that instead.
* SEE: "OnPlayerStateChange", "FIXES_SetPlayerArmedWeapon", and
* "FIXES_GetPlayerWeapon", "FIXES_GivePlayerWeapon",
* "FIXES_ResetPlayerWeapons".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* AUTHOR: Xerieos (https://github.com/Xerieos/)
*
* FIX: PutPlayerInVehicle
* PROBLEM: If this is used on a passenger the driver of their old vehicle
* doesn't see them in their new vehicle.
* SOLUTION: Remove them from the vehicle first.
* SEE: "OnPlayerStateChange" and "FIXES_PutPlayerInVehicle".
* AUTHOR: leong124
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1265965
*
* FIX: KEY_AIM
* PROBLEM: "KEY_AIM" isn't defined by default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetPlayerCheckpoint
* PROBLEM: If a checkpoint is already set it will use the size of that
* checkpoint instead of the new one.
* SOLUTION: Call "DisablePlayerCheckpoint" before setting the checkpoint.
* SEE: "FIXES_SetPlayerCheckpoint".
* AUTHOR: ziggi (https://github.com/ziggi/)
*
* FIX: SetPlayerRaceCheckpoint
* PROBLEM: If a checkpoint is already set it will use the size of that
* checkpoint instead of the new one.
* SOLUTION: Call "DisablePlayerRaceCheckpoint" before setting the checkpoint.
* SEE: "FIXES_SetPlayerRaceCheckpoint".
* AUTHOR: ziggi (https://github.com/ziggi/)
*
* FIX: TextDrawCreate
* PROBLEM: Crashes on a blank string.
* SOLUTION: Intercept blank strings.
* SEE: "FIXES_TextDrawCreate".
* AUTHOR: wups
*
* FIX: TextDrawSetString
* PROBLEM: Crashes on a blank string and size greater than 1024.
* SOLUTION: Intercept blank strings and truncate long strings.
* SEE: "FIXES_TextDrawSetString".
* AUTHOR: TomTrox
*
* FIX: CreatePlayerTextDraw
* PROBLEM: Crashes on a blank string.
* SOLUTION: Intercept blank strings.
* SEE: "FIXES_CreatePlayerTextDraw".
* AUTHOR: wups
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: PlayerTextDrawSetString
* PROBLEM: Crashes on a blank string and size greater than 1024.
* SOLUTION: Intercept blank strings and truncate long strings.
* SEE: "FIXES_PlayerTextDrawSetString".
* AUTHOR: TomTrox
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: AllowInteriorWeapons
* PROBLEM: Does nothing.
* SOLUTION: Set the player's weapon to fists in an interior.
* SEE: "FIXES_AllowInteriorWeapons", "OnGameModeInit" and
* "OnPlayerUpdate".
* AUTHOR: KoczkaHUN
*
* FIX: OnPlayerEnterVehicle
* PROBLEM: Crashes other players when people enter an invalid seat.
* SOLUTION: Desync the people with invalid seats.
* SEE: "OnPlayerStateChange" and "OnPlayerUpdate".
* AUTHOR: RyDeR`
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1410296
*
* FIX: OnPlayerEnterVehicle_2
* PROBLEM: Crashes the server when hacks enter an invalid vehicle.
* SOLUTION: Desync the people with invalid vehicles.
* SEE: "OnPlayerEnterVehicle".
* AUTHOR: im
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: AllowTeleport
* PROBLEM: 0.3dRC9 removed "AllowPlayerTeleport" and "AllowAdminTeleport" in
* favour of "OnPlayerClickMap". Some scripts used the old code and.
* SOLUTION: Teleport the player in "OnPlayerClickMap".
* SEE: "OnPlayerClickMap", "FIXES_AllowPlayerTeleport", and
* "FIXES_AllowAdminTeleport".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetPlayerSpecialAction
* PROBLEM: Removing jetpacks from players by setting their special action to 0
* causes the sound to stay until death.
* SOLUTION: Call "ClearAnimations" before "SetPlayerSpecialAction".
* SEE: "FIXES_SetPlayerSpecialAction".
* AUTHOR: MP2
*
* FIX: OnDialogResponse
* PROBLEM: Cheaters can spoof the dialogid they are using to respond to ones
* they can't actually see.
* SOLUTION: Store the displayed dialogid and use that instead.
* SEE: "FIXES_OnDialogResponse", "FIXES_ShowPlayerDialog".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* FIXED IN: 0.3e RC6
*
* FIX: GetPlayerDialog
* PROBLEM: This function doesn't exist. Fixed for hidden dialogs.
* SOLUTION: Add it. DEFAULTS TO FALSE!
* SEE: "FIXES_GetPlayerDialog".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: PlayerDialogResponse
* PROBLEM: A player's dialog doesn't hide when the gamemode restarts, causing
* the server to print "Warning: PlayerDialogResponse PlayerId: 0
* dialog ID doesn't match last sent dialog ID".
* SOLUTION: Hide it.
* SEE: "OnPlayerConnect", "OnGameModeExit".
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: SetSpawnInfo
* PROBLEM: Kicks the player if "SpawnPlayer" is called before "SetSpawnInfo".
* SOLUTION: Call "SetSpawnInfo" at least once.
* SEE: "OnPlayerConnect".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetPlayerSkin
* PROBLEM: Breaks sitting on bikes.
* SOLUTION: Put them back in the vehicle after setting their skin.
* SEE: "FIXES_SetPlayerSkin".
* AUTHOR: CyNiC
* POST: http://forum.sa-mp.com/showpost.php?p=1756094
*
* FIX: HideMenuForPlayer
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_HideMenuForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1787297
*
* FIX: valstr
* PROBLEM: Crashes on large numbers.
* SOLUTION: Use "format" instead.
* SEE: "FIXES_valstr".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fclose
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fclose".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fwrite
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fwrite".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fread
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fread".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fputchar
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fputchar".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fgetchar
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fgetchar".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fblockwrite
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fblockwrite".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fblockread
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fblockread".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: fseek
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_fseek".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: flength
* PROBLEM: Crashes on an invalid handle.
* SOLUTION: Check for an invalid handle.
* SEE: "FIXES_flength".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: file_inc
* PROBLEM: Includes or excludes all the file function fixes together (can
* cause major overhead).
* SOLUTION: Optionally group them all under one define. DEFAULTS TO FALSE!
* SEE: "FIX_file_inc".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetPlayerAttachedObject
* PROBLEM: Doesn't remove objects when the mode ends.
* SOLUTION: Remove them.
* SEE: "OnPlayerDisconnect"
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: OnPlayerDeath
* PROBLEM: Clients get stuck when they die with an animation applied.
* SOLUTION: Clear their animations.
* SEE: "OnPlayerDeath" and "OnPlayerUpdate".
* AUTHOR: h02
* POST: http://forum.sa-mp.com/showpost.php?p=1641144
*
* FIX: strins
* PROBLEM: Ignores the "maxlength" parameter causing possible crashes.
* SOLUTION: Manually check the length.
* SEE: "FIXES_strins".
* AUTHOR: Slice (https://github.com/oscar-broman/)
* AUTHOR: Y_Less (https://github.com/Y-Less)
*
* FIX: IsPlayerConnected
* PROBLEM: Only uses the lower two bytes of a passed ID.
* SOLUTION: Mask the numbers.
* SEE: "FIXES_IsPlayerConnected".
* AUTHOR: Slice (https://github.com/oscar-broman/)
*
* FIX: OnPlayerCommandText
* PROBLEM: Can crash ZCMD when passed a null string.
* SOLUTION: Pass NULL if invalid inputs given.
* SEE: "OnPlayerCommandText".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1909511
*
* FIX: TrainExit
* PROBLEM: When getting out of a train entered by "PutPlayerInVehicle", the
* camera does not reset properly.
* SOLUTION: Reset the camera.
* SEE: "FIXES_PutPlayerInVehicle", "FIXES_OnPlayerStateChange".
* AUTHOR: Terminator3
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: Kick
* PROBLEM: Calling "Kick" in "OnPlayerConnect" doesn't work properly.
* SOLUTION: Defer it.
* SEE: "OnPlayerConnect", "FIXES_Kick".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1989453
* FIXED IN: 0.3x
*
* FIX: OnVehicleMod
* PROBLEM: Crashes other players when invalid mods are applied.
* SOLUTION: Desync the player.
* SEE: "OnVehicleMod".
* AUTHOR: JernejL (https://github.com/JernejL/)
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1671500
*
* FIX: random
* PROBLEM: Doesn't work with negative numbers.
* SOLUTION: Invert then reinvert. DEFAULTS TO FALSE!
* SEE: "FIXES_random".
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: sleep
* PROBLEM: Leaks bytes from the stack.
* SOLUTION: Call a function to store the correct value.
* SEE: "FIXES_sleep".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: AddMenuItem
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_AddMenuItem".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetMenuColumnHeader
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_SetMenuColumnHeader".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: ShowMenuForPlayer
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_ShowMenuForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: HideMenuForPlayer
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_HideMenuForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showpost.php?p=1787297
*
* FIX: HideMenuForPlayer_2
* PROBLEM: Ignores the "menuid" parameter.
* SOLUTION: Only hide the correct menu. DEFAULTS TO FALSE!
* SEE: "FIXES_HideMenuForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: DisableMenu
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_DisableMenu".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: DisableMenuRow
* PROBLEM: Crashes when passed an invalid menu ID.
* SOLUTION: Don't hide it when passed an invalid menu.
* SEE: "FIXES_DisableMenuRow".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: Menus
* PROBLEM: All menu function fixes are included separately for major overhead.
* SOLUTION: Optionally group them all under one define.
* SEE: "FIX_Menus", "_FIX_Menus"
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GetPlayerMenu
* PROBLEM: Returns previous menu when none is displayed.
* SOLUTION: Return the correct value.
* SEE: "FIXES_GetPlayerMenu", "OnPlayerSelectedMenuRow".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GetPlayerInterior
* PROBLEM: Always returns 0 for NPCs.
* SOLUTION: Return the correct value.
* SEE: "FIXES_GetPlayerInterior", "FIXES_SetPlayerInterior".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: ClearAnimations
* PROBLEM: Use ClearAnimation while you are in a vehicle cause the player exit
* from it.
* SOLUTION: Apply an animation instead of clear animation.
* SEE: "FIXES_ClearAnimations".
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: ClearAnimations_2
* PROBLEM: ClearAnimations doesn't do anything when the animation ends if we
* pass 1 for the freeze parameter in ApplyAnimation.
* SOLUTION: Apply an idle animation for stop and then use ClearAnimation.
* SEE: "FIXES_ClearAnimations".
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: DriveBy
* PROBLEM: If you press KEY_CROUCH while you're passenger and if you are
* armed, the player start to aim; if you repress KEY_CROUCH the
* player don't return in vehicle.
* SOLUTION: Apply the animation to return the player in the vehicle.
* SEE: "OnPlayerKeyStateChange".
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: GangZoneCreate
* PROBLEM: Gang zones bug on the main map for players at certain angles
* relative to them.
* SOLUTION: Set a non floating value for the gang zone co-ordinate.
* SEE: "FIXES_GangZoneCreate".
* AUTHOR: simonepri (https://github.com/simonepri/)
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SPECIAL_ACTION_PISSING
* PROBLEM: "SPECIAL_ACTION_PISSING" isn't defined by default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: IsValidVehicle
* PROBLEM: "IsValidVehicle" isn't defined by default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: ApplyAnimation
* PROBLEM: Passing an invalid animation library in ApplyAnimation causes a
* client crash for streamed in players.
* SOLUTION: Block ApplyAnimation when an invalid library is passed.
* SEE: "FIXES_ApplyAnimation".
* AUTHOR: simonepri (https://github.com/simonepri/)
*
* FIX: ApplyAnimation_2
* PROBLEM: First time a library is used, it does nothing.
* SOLUTION: Apply animations twice when first using a library.
* SEE: "FIXES_ApplyAnimation".
* AUTHOR: simonepri (https://github.com/simonepri/)
* AUTHOR: Lordzy (https://github.com/Lordzy/)
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: ApplyActorAnimation
* PROBLEM: Passing an invalid animation library in ApplyAnimation causes a
* client crash for streamed in players.
* SOLUTION: Block ApplyActorAnimation when an invalid library is passed.
* SEE: "FIXES_ApplyActorAnimation".
* AUTHOR: simonepri (https://github.com/simonepri/)
* AUTHOR: ziggi (https://github.com/ziggi/)
*
* FIX: ApplyActorAnimation_2
* PROBLEM: First time a library is used, it does nothing.
* SOLUTION: Apply animations twice when first using a library.
* SEE: "FIXES_ApplyActorAnimation".
* AUTHOR: simonepri (https://github.com/simonepri/)
* AUTHOR: Lordzy (https://github.com/Lordzy/)
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* AUTHOR: ziggi (https://github.com/ziggi/)
*
* FIX: OnPlayerSpawn
* PROBLEM: San Andreas deducts $100 from players.
* SOLUTION: Give them it back.
* SEE: "OnPlayerSpawn".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GetGravity
* PROBLEM: "GetGravity" isn't defined by default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: Whitetiger (https://github.com/Whitetigerswt)
* POST: http://forum.sa-mp.com/showpost.php?p=1706447
*
* FIX: gpci
* PROBLEM: "gpci" isn't defined by default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: simonepri (https://github.com/simonepri/)
* POST: http://pastebin.com/VQSGpbSm
*
* FIX: Natives
* PROBLEM: Several natives are included by default, this enables or disables
* them all. Therefore this is an umbrella fix for several fixes.
* SOLUTION: Define them.
* SEE: "FIX_GetGravity", "FIX_gpci", "FIX_IsValidVehicle".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: OnPlayerConnect
* PROBLEM: This function isn't called for players when a filterscript starts.
* SOLUTION: Call it for all connected players.
* SEE: "FIXES_OnFilterScriptInit".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: OnPlayerDisconnect
* PROBLEM: This function isn't called for players when a filterscript ends.
* SOLUTION: Call it for all connected players.
* SEE: "FIXES_OnFilterScriptExit".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GameText
* PROBLEM: Several styles do not display for the time specified.
* SOLUTION: Recreate the styles in Text Draws and use those instead.
* SEE: "FIXES_GameTextForAll", "FIXES_GameTextForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GameTextStyles
* PROBLEM: San Andreas has fixed styles for area and vehicle names, but they
* are not included in the GameText styles list.
* SOLUTION: Add them. DEFAULTS TO FALSE.
* SEE: "FIXES_GameTextForAll", "FIXES_GameTextForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: HideGameText
* PROBLEM: There is no "HideGameTextForXYZ" function.
* SOLUTION: Show a single space for a game text. DEFAULTS TO FALSE.
* SEE: "FIXES_HideGameTextForAll", "FIXES_HideGameTextForPlayer".
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: WEAPONS
* PROBLEM: Some weapons are not defined by default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: ziggi (https://github.com/ziggi)
*
* FIX: BODYPARTS
* PROBLEM: The bodyparts to be used in OnPlayer(Take/Give)Damage are not
* defined by default
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: Whitetiger (https://github.com/Whitetigerswt)
*
* FIX: CAMERAMODES
* PROBLEM: The camera modes for GetPlayerCameraMode are not defined by
* default.
* SOLUTION: Define it.
* SEE: N/A.
* AUTHOR: Whitetiger (https://github.com/Whitetigerswt)
* POST: http://forum.sa-mp.com/showpost.php?p=1309730
*
* FIX: SetPlayerCamera
* PROBLEM: Using the camera functions directly after enabling spectator mode
* doesn't work.
* SOLUTION: Defer them.
* SEE: "FIXES_SetPlayerCameraPos", "FIXES_SetPlayerCameraLookAt",
* "FIXES_TogglePlayerSpectating".
* AUTHOR: Emmet_ (https://github.com/emmet-jones)
*
* FIX: SetPlayerTime
* PROBLEM: Using this function under "OnPlayerConnect" doesn't work.
* SOLUTION: Defer it.
* SEE: "FIXES_SetPlayerTime"
* AUTHOR: Emmet_ (https://github.com/emmet-jones)
*
* FIX: OnPlayerRequestClass
* PROBLEM: Random blunts and bottles sometimes appear in class selection.
* SOLUTION: Call "RemoveBuildingForPlayer".
* SEE: "OnPlayerRequestClass"
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: SetPlayerColor
* PROBLEM: If used under OnPlayerConnect, the affecting player will not
* see the color in the TAB menu.
* SOLUTION: Defer it.
* SEE: "FIXES_SetPlayerColor"
* AUTHOR: Emmet_ (https://github.com/emmet-jones)
* POST: http://forum.sa-mp.com/showthread.php?t=452407
*
* FIX: FileMaths
* PROBLEM: You can write gibberish like "File:a; ++a;".
* SOLUTION: Remove the operators.
* SEE: "File:operator"
* AUTHOR: Y_Less (https://github.com/Y-Less/)
*
* FIX: GetPlayerWeaponData
* PROBLEM: Old weapons with no ammo left are still returned.
* SOLUTION: Set "weapons" to 0. DEFAULTS TO FALSE!
* SEE: "FIXES_GetPlayerWeaponData"
* AUTHOR: Y_Less (https://github.com/Y-Less/)
* POST: http://forum.sa-mp.com/showthread.php?t=567400
*
* FIX: strcmp
* PROBLEM: Return 0 if anyone of the string is empty.
* SOLUTION: Add a check for empty string.
* SEE: "FIXES_strcmp".
* AUTHOR: Y_Less (https://github.com/Y-Less)
*
* FIX: GetPVarString
* PROBLEM: Wrong symbol code for symbols with code 128 and above.
* SOLUTION: Use logical conjunction on symbol and 0xFF.
* SEE: "FIXES_GetPVarString".
* AUTHOR: ziggi (https://github.com/ziggi)
* AUTHOR: Mutha_X
* AUTHOR: Daniel_Cortez (https://github.com/Daniel-Cortez)
* POST: http://forum.sa-mp.com/showthread.php?t=572724&page=11
* POST: http://pro-pawn.ru/showthread.php?13007
*
* FIX: GetSVarString
* PROBLEM: Wrong symbol code for symbols with code 128 and above.
* SOLUTION: Use logical conjunction on symbol and 0xFF.
* SEE: "FIXES_GetSVarString".
* AUTHOR: ziggi (https://github.com/ziggi)
* AUTHOR: Mutha_X
* AUTHOR: Daniel_Cortez (https://github.com/Daniel-Cortez)
* POST: http://forum.sa-mp.com/showthread.php?t=572724&page=11
* POST: http://pro-pawn.ru/showthread.php?13007
*
* FIX: toupper
* PROBLEM: Not working on Linux for symbols with code 128 and above.
* SOLUTION: Recreate the function.
* SEE: "FIXES_toupper".
* AUTHOR: ziggi (https://github.com/ziggi)
* POST: http://pro-pawn.ru/showthread.php?13466&p=72954#post72954
*
* FIX: tolower
* PROBLEM: Not working on Linux for symbols with code 128 and above.
* SOLUTION: Recreate the function.
* SEE: "FIXES_tolower".
* AUTHOR: ziggi (https://github.com/ziggi)
* POST: http://pro-pawn.ru/showthread.php?13466&p=72954#post72954
*
* FIX: PassengerSeating
* PROBLEM: Teleporting player to passenger seat after delay.
* SOLUTION: Call ClearAnimation after some delay.
* SEE: "OnPlayerEnterVehicle", "OnPlayerStateChange".
* AUTHOR: ziggi (https://github.com/ziggi)
*
* FIX: GogglesSync
* PROBLEM: Visual effects show for all players.
* SOLUTION: return 0 in OnPlayerUpdate after key pressed.
* SEE: "OnPlayerUpdate".
* AUTHOR: ziggi (https://github.com/ziggi)
*
* ==============
* STYLE RULES:
* ==============
*
* All globals should be "static stock" whenever possible (so they can only be
* accessed from this one file).
*
* Statics must start with "FIXES_gs", and all other globals with "FIXES_g".
*
* All functions not overriding existing functions must start with "FIXES_".
*
* Macros must be upper case, use underscores, and start "FIXES_":
* "FIXES_LIKE_THIS".
*
* Functions should be upper camel case (as the original functions are)
* "FIXES_LikeThis".
*
* Globals (after the prefix) should be upper camel case "LikeThis", and locals
* lower camel case "likeThis".
*
* ALS should be used to hook functions and callbacks. See this topic for more
* details:
*
* http://forum.sa-mp.com/showthread.php?t=570910
*
* The ALS prefix for chaining is "FIXES_".
*
* When redefining a native, add a "BAD_" external name declaration with the
* "_ALS_" definition so that others may use the original native if they so
* desire (with the caveat that it may break all fixes). Note the "BAD_"
* name is meant to indicate the possibility of breaking the fix, not a
* comment on the original native function.
*
* The ALS hook defines used here are a little different to the normal ones as
* this file assumes that it is always first. The pattern is:
*
* #if defined _ALS_NameOfFixHere
* #error _ALS_NameOfFixHere defined
* #endif
* native BAD_NameOfFixHere(params) = NameOfFixHere;
*
* #if FIX_NameOfFixHere
* stock FIXES_NameOfFixHere(params)
* {
* return 0;
* }
*
* #define _ALS_NameOfFixHere
* #define NameOfFixHere FIXES_NameOfFixHere
* #endif
*
* A copyable version of this pattern is at the end of the file.
*
* Enums start with "E_" or "e_" depending on type, then follow rules for
* macros.
*
* NO libraries should be included - not even the default SA:MP ones. Let the
* user do it.
*
* Due to the above rule, you cannot assume any third party libraries AT ALL, so
* do not use them. This can lead to some code duplication, but also means
* that the version of the code used here can be tailored for optimisations.
*
* Certain terms may be shortened when dealing with long callback names to avoid
* compile truncation warnings (max symbol length is 31). Current list:
*
* "Checkpoint" -> "CP"
* "Update" -> "Upd"
* "TextDraw" -> "TD"
* "Object" -> "Obj"
* "Player" -> "P"
*
* Document all fixes at the top of the file, and highlight code.
*
* 4 space TABS - do not edit this file in PAWNO unless you know how to correct
* the indentation.
*
* All rules have exceptions, but they must be justifiable. For example
* "IS_FILTERSCRIPT" is a global variable, but is not called
* "FIXES_gIsFilterscript" to better match the "FILTERSCRIPT" macro it
* replaces. Now a macro for "_FIXES_gIsFilterscript".
*
* Variables which need to be fully global (i.e. not "static"), but should not
* actually be used by other people (e.g. appear inside a macro) should be
* prefixed with "_FIXES" instead of "FIXES" to indicate their private use.
*
* No comments beyond the end of column 80 (where the line in "PAWNO" is).
*
* If a bug is fixed in some version of the server it can be conditionally
* included here. This is done by checking for the existance of a native
* function introduced in the same server version. For example
* "TogglePlayerControllable" was fixed in 0.3eRC6, the same time as the
* "SetObjectMaterial" native was introduced, thus the inclusion becomes:
*
* #if !defined FIX_TogglePlayerControllable
* #if defined SetObjectMaterial
* #define FIX_TogglePlayerControllable (0)
* #else
* #define FIX_TogglePlayerControllable (1)
* #endif
* #elseif _FIXES_IS_UNSET(FIX_TogglePlayerControllable)
* #undef FIX_TogglePlayerControllable
* #define FIX_TogglePlayerControllable (2)
* #endif
*
* This only includes this fix if that native doesn't exist. A copyable
* version of this pattern is at the end of the file.
*
* To reduce general memory consumption, strings in this include are stored
* globally in constant arrays and referenced. This is EXACTLY as fast as
* using the string constants directly, but means that strings are not
* stored in the assembly multiple times (unless the string is only used
* once, in which case it's more work for no gain). See this post for more
* details:
*
* http://forum.sa-mp.com/showpost.php?p=1795601
*
* DO NOT EDIT THIS FILE IN PAWNO OR ON GITHUB. Both mess up the spacing -
* GitHub in an almost irreversible way (except for the fact that nothing is
* irreversible in source control. Pawno spacing is less tricky to solve,
* and can be worked around if you know when it uses spaces and tabs - in
* short, always write code first THEN indent and you won't have a problem
* (in that editor at least, that is normally a bad way to write code).
*
* Documentation explanation:
*
* FIX: <Short name>
* PROBLEM: <Description of problem>
* SOLUTION: <Description of solution>
* SEE: <List of relevant functions>
* AUTHOR: <Person who wrote the fix>
* POST: <Optional link to the original post where applicable>
* FIXED IN: <Optional server version of official fix where applicable>
*
*/
#if defined _INC_SAMP_Community_fixes
#endinput
#endif
#define _INC_SAMP_Community_fixes
#if !defined _inc_fixes
#define _inc_fixes
#endif
#define _FIXES_IS_UNSET(%0) ((2*%0-1+1)==-1)
// We can add server version compiler code here to only compile fixes that apply
// to the version of the includes for which the user is compiling.
#if !defined FIX_GetPlayerColour
#if defined FIX_GetPlayerColor
#if _FIXES_IS_UNSET(FIX_GetPlayerColor)
#define FIX_GetPlayerColour (2)
#else
#define FIX_GetPlayerColour (FIX_GetPlayerColor)
#endif
#else
#define FIX_GetPlayerColour (1)
#endif
#elseif _FIXES_IS_UNSET(FIX_GetPlayerColour)
#undef FIX_GetPlayerColour
#define FIX_GetPlayerColour (2)
#endif
#if !defined FIX_FILTERSCRIPT
#define FIX_FILTERSCRIPT (1)
#elseif _FIXES_IS_UNSET(FIX_FILTERSCRIPT)
#undef FIX_FILTERSCRIPT
#define FIX_FILTERSCRIPT (2)
#endif
#if !defined FIX_SpawnPlayer
#define FIX_SpawnPlayer (1)
#elseif _FIXES_IS_UNSET(FIX_SpawnPlayer)
#undef FIX_SpawnPlayer
#define FIX_SpawnPlayer (2)
#endif
#if !defined FIX_SetPlayerName
#define FIX_SetPlayerName (1)
#elseif _FIXES_IS_UNSET(FIX_SetPlayerName)
#undef FIX_SetPlayerName
#define FIX_SetPlayerName (2)
#endif
#if !defined FIX_GetPlayerSkin
#define FIX_GetPlayerSkin (1)
#elseif _FIXES_IS_UNSET(FIX_GetPlayerSkin)
#undef FIX_GetPlayerSkin
#define FIX_GetPlayerSkin (2)
#endif
#if !defined FIX_GetWeaponName
#if defined GetVehicleParamsSirenState
#define FIX_GetWeaponName (0)
#else
#define FIX_GetWeaponName (1)
#endif
#elseif _FIXES_IS_UNSET(FIX_GetWeaponName)
#undef FIX_GetWeaponName
#define FIX_GetWeaponName (2)
#endif
#if !defined FIX_SetPlayerWorldBounds
#define FIX_SetPlayerWorldBounds (1)
#elseif _FIXES_IS_UNSET(FIX_SetPlayerWorldBounds)
#undef FIX_SetPlayerWorldBounds
#define FIX_SetPlayerWorldBounds (2)
#endif
#if !defined FIX_TogglePlayerControllable
#if defined SetObjectMaterial
#define FIX_TogglePlayerControllable (0)
#else
#define FIX_TogglePlayerControllable (1)
#endif
#elseif _FIXES_IS_UNSET(FIX_TogglePlayerControllable)
#undef FIX_TogglePlayerControllable
#define FIX_TogglePlayerControllable (2)
#endif
#if !defined FIX_HydraSniper
#define FIX_HydraSniper (1)
#elseif _FIXES_IS_UNSET(FIX_HydraSniper)
#undef FIX_HydraSniper
#define FIX_HydraSniper (2)
#endif
#if !defined FIX_IsPlayerInCheckpoint
#define FIX_IsPlayerInCheckpoint (1)
#elseif _FIXES_IS_UNSET(FIX_IsPlayerInCheckpoint)
#undef FIX_IsPlayerInCheckpoint
#define FIX_IsPlayerInCheckpoint (2)
#endif
#if !defined FIX_IsPlayerInRaceCheckpoint
#define FIX_IsPlayerInRaceCheckpoint (1)
#elseif _FIXES_IS_UNSET(FIX_IsPlayerInRaceCheckpoint)
#undef FIX_IsPlayerInRaceCheckpoint
#define FIX_IsPlayerInRaceCheckpoint (2)
#endif
#if !defined FIX_GetPlayerWeapon
#define FIX_GetPlayerWeapon (1)
#elseif _FIXES_IS_UNSET(FIX_GetPlayerWeapon)
#undef FIX_GetPlayerWeapon
#define FIX_GetPlayerWeapon (2)
#endif
#if !defined FIX_PutPlayerInVehicle
#define FIX_PutPlayerInVehicle (1)
#elseif _FIXES_IS_UNSET(FIX_PutPlayerInVehicle)
#undef FIX_PutPlayerInVehicle
#define FIX_PutPlayerInVehicle (2)
#endif
#if !defined FIX_KEY_AIM
#if defined KEY_AIM
#define FIX_KEY_AIM (0)
#else
#define FIX_KEY_AIM (1)
#endif
#elseif _FIXES_IS_UNSET(FIX_KEY_AIM)
#undef FIX_KEY_AIM
#define FIX_KEY_AIM (2)
#endif
#if !defined FIX_SPECIAL_ACTION_PISSING
#if defined SPECIAL_ACTION_PISSING
#define FIX_SPECIAL_ACTION_PISSING (0)
#else
#define FIX_SPECIAL_ACTION_PISSING (1)
#endif
#elseif _FIXES_IS_UNSET(FIX_SPECIAL_ACTION_PISSING)
#undef FIX_SPECIAL_ACTION_PISSING
#define FIX_SPECIAL_ACTION_PISSING (2)
#endif
#if !defined FIX_Natives
#define FIX_Natives (1)
#elseif _FIXES_IS_UNSET(FIX_Natives)
#undef FIX_Natives
#define FIX_Natives (2)
#endif
#if !defined FIX_IsValidVehicle
#if defined IsValidVehicle
#define FIX_IsValidVehicle (0)
#else
#define FIX_IsValidVehicle (FIX_Natives)
#endif
#elseif _FIXES_IS_UNSET(FIX_IsValidVehicle)
#undef FIX_IsValidVehicle
#define FIX_IsValidVehicle (2)
#endif
#if !defined FIX_GetGravity
#if defined GetGravity
#define FIX_GetGravity (0)
#else
#define FIX_GetGravity (FIX_Natives)
#endif
#elseif _FIXES_IS_UNSET(FIX_GetGravity)
#undef FIX_GetGravity
#define FIX_GetGravity (2)
#endif
#if !defined FIX_gpci
#if defined gpci
#define FIX_gpci (0)
#else
#define FIX_gpci (FIX_Natives)
#endif
#elseif _FIXES_IS_UNSET(FIX_gpci)
#undef FIX_gpci
#define FIX_gpci (2)
#endif
#if !defined FIX_WEAPONS