Y_Less

fixes3.inc

Jul 17th, 2012
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 118.89 KB | None | 0 0
  1. /*
  2.  * ===============
  3.  *  INTRODUCTION:
  4.  * ===============
  5.  *
  6.  * fixes.inc - Community patch for buggy SA:MP functions.
  7.  *
  8.  * ================
  9.  *  LIST OF FIXES:
  10.  * ================
  11.  *
  12.  * FIX:      GetPlayerColor
  13.  * PROBLEM:  Returns "0" if "SetPlayerColor" has never been called.
  14.  * SOLUTION: Call "SetPlayerColor" in "OnPlayerConnect".
  15.  * SEE:      "OnPlayerConnect".
  16.  * AUTHOR:   KoczkaHUN
  17.  * POST:     http://forum.sa-mp.com/showpost.php?p=1486048
  18.  *
  19.  * FIX:      FILTERSCRIPT
  20.  * PROBLEM:  Despite the fact that is in every new script, many people don't
  21.  *           define "FILTERSCRIPT" where appropriate.
  22.  * SOLUTION: Provide an "IS_FILTERSCRIPT" variable (note the naming to match
  23.  *           the original macro).
  24.  * AUTHOR:   Y_Less
  25.  * SEE:      "OnFilterScriptInit" and "OnGameModeInit".
  26.  *
  27.  * FIX:      SpawnPlayer
  28.  * PROBLEM:  Kills the player if they are in a vehicle.
  29.  * SOLUTION: Remove the from the vehicle.
  30.  * SEE:      "FIXES_SpawnPlayer".
  31.  * AUTHOR:   Y_Less
  32.  *
  33.  * FIX:      SetPlayerName
  34.  * PROBLEM:  Using "SetPlayerName" when the new name only differs from the old
  35.  *           name in case does not alter the name at all.
  36.  * SOLUTION: Change their name twice - once to "_FIXES TEMP NAME" and then to
  37.  *           the actual required name.
  38.  * SEE:      "OnPlayerConnect" and "FIXES_SetPlayerName".
  39.  * AUTHOR:   Y_Less/Slice
  40.  *
  41.  * FIX:      GetPlayerSkin
  42.  * PROBLEM:  Returns the new skin after "SetSpawnInfo" is called but before the
  43.  *           player actually respawns to get the new skin.
  44.  * SOLUTION: Record the skin in "OnPlayerSpawn" and always return that one.
  45.  * SEE:      "OnPlayerSpawn", "FIXES_GetPlayerSkin" and "FIXES_SetPlayerSkin".
  46.  * AUTHOR:   Y_Less
  47.  *
  48.  * FIX:      GetWeaponName
  49.  * PROBLEM:  Returns nothing for 18, 44, and 45.
  50.  * SOLUTION: Return the correct names ("Molotov Cocktail", "Thermal Goggles",
  51.  *           and "Night vision Goggles").
  52.  * SEE:      "FIXES_GetWeaponName".
  53.  * AUTHOR:   Y_Less
  54.  *
  55.  * FIX:      SetPlayerWorldBounds
  56.  * PROBLEM:  Aiming can bypass the edge.
  57.  * SOLUTION: Check for the player leaving the area and reset them to their last
  58.  *           good position if they leave the area (aiming or not).
  59.  * SEE:      "OnPlayerUpdate" and "FIXES_SetPlayerWorldBounds".
  60.  * AUTHOR:   Y_Less
  61.  *
  62.  * FIX:      TogglePlayerControllable
  63.  * PROBLEM:  Other players see you moving on the spot.
  64.  * SOLUTION: Return 0 in OnPlayerUpdate.
  65.  * SEE:      "FIXES_TogglePlayerControllable" and "OnPlayerUpdate".
  66.  * AUTHOR:   Slice
  67.  * POST:     http://forum.sa-mp.com/showpost.php?p=876854
  68.  *
  69.  * FIX:      HydraSniper
  70.  * PROBLEM:  Entring military aircraft with a sniper rifle messes up vies.
  71.  * SOLUTION: Set their armed weapon to fists.
  72.  * SEE:      "OnPlayerStateChange", "FIXES_GivePlayerWeapon",
  73.  *           "FIXES_SetPlayerArmedWeapon".
  74.  * AUTHOR:   funky1234
  75.  * POST:     http://forum.sa-mp.com/showpost.php?p=965644
  76.  *
  77.  * FIX:      IsPlayerInCheckpoint
  78.  * PROBLEM:  Function returns an undefined value if it is called before any
  79.  *           other checkpoint functions are called to initialise the value.
  80.  * SOLUTION: Call "DisablePlayerCheckpoint" when they connect.
  81.  * SEE:      "OnPlayerConnect".
  82.  * AUTHOR:   Y_Less
  83.  *
  84.  * FIX:      IsPlayerInRaceCheckpoint
  85.  * PROBLEM:  Function returns an undefined value if it is called before any
  86.  *           other race checkpoint functions are called to initialise the value.
  87.  * SOLUTION: Call "DisablePlayerRaceCheckpoint" when they connect.
  88.  * SEE:      "OnPlayerConnect".
  89.  * AUTHOR:   Y_Less
  90.  *
  91.  * FIX:      GetPlayerWeapon
  92.  * PROBLEM:  Returns the old value after using "SetPlayerArmedWeapon" when they
  93.  *           are in a vehicle.
  94.  * SOLUTION: If "SetPlayerArmedWeapon" is called in a vehicle, store the new
  95.  *           value and return that instead.
  96.  * SEE:      "OnPlayerStateChange", "FIXES_SetPlayerArmedWeapon", and
  97.  *           "FIXES_GetPlayerWeapon".
  98.  * AUTHOR:   Y_Less
  99.  *
  100.  * FIX:      PutPlayerInVehicle
  101.  * PROBLEM:  If this is used on a passenger the driver of their old vehicle
  102.  *           doesn't see them in their new vehicle.
  103.  * SOLUTION: Remove them from the vehicle first.
  104.  * SEE:      "OnPlayerStateChange" and "FIXES_PutPlayerInVehicle".
  105.  * AUTHOR:   leong124/Y_Less
  106.  * POST:     http://forum.sa-mp.com/showpost.php?p=1265965
  107.  *
  108.  * FIX:      KEY_AIM
  109.  * PROBLEM:  "KEY_AIM" isn't defined by default.
  110.  * SOLUTION: Define it.
  111.  * SEE:      N/A.
  112.  * AUTHOR:   Y_Less
  113.  *
  114.  * FIX:      SetPlayerCheckpoint
  115.  * PROBLEM:  If a checkpoint is already set it will use the size of that
  116.  *           checkpoint instead of the new one.
  117.  * SOLUTION: Call "DisablePlayerCheckpoint" before setting the checkpoint.
  118.  * SEE:      "FIXES_SetPlayerCheckpoint".
  119.  * AUTHOR:   KoczkaHUN
  120.  * POST:     http://forum.sa-mp.com/showpost.php?p=1482401
  121.  *
  122.  * FIX:      SetPlayerRaceCheckpoint
  123.  * PROBLEM:  If a checkpoint is already set it will use the size of that
  124.  *           checkpoint instead of the new one.
  125.  * SOLUTION: Call "DisablePlayerRaceCheckpoint" before setting the checkpoint.
  126.  * SEE:      "FIXES_SetPlayerRaceCheckpoint".
  127.  * AUTHOR:   KoczkaHUN
  128.  * POST:     http://forum.sa-mp.com/showpost.php?p=1482401
  129.  *
  130.  * FIX:      TextDrawCreate
  131.  * PROBLEM:  Crashes on a blank string.
  132.  * SOLUTION: Intercept blank strings.
  133.  * SEE:      "FIXES_TextDrawCreate".
  134.  * AUTHOR:   wups
  135.  * POST:     http://forum.sa-mp.com/showpost.php?p=1484008
  136.  *
  137.  * FIX:      TextDrawSetString
  138.  * PROBLEM:  Crashes on a blank string and size greater than 1024.
  139.  * SOLUTION: Intercept blank strings and truncate long strings.
  140.  * SEE:      "FIXES_TextDrawSetString".
  141.  * AUTHOR:   TomTrox
  142.  * POST:     http://forum.sa-mp.com/showpost.php?p=1487870
  143.  *
  144.  * FIX:      AllowInteriorWeapons
  145.  * PROBLEM:  Does nothing.
  146.  * SOLUTION: Set the player's weapon to fists in an interior.
  147.  * SEE:      "FIXES_AllowInteriorWeapons", "OnGameModeInit" and
  148.  *           "OnPlayerUpdate".
  149.  * AUTHOR:   KoczkaHUN
  150.  * POST:     http://forum.sa-mp.com/showpost.php?p=1502696
  151.  *
  152.  * FIX:      OnPlayerEnterVehicle
  153.  * PROBLEM:  Crashes other players when people enter an invalid seat.
  154.  * SOLUTION: Desync the people with invalid seats.
  155.  * SEE:      "OnPlayerStateChange" and "OnPlayerUpdate".
  156.  * AUTHOR:   RyDeR`/Y_Less
  157.  * POST:     http://forum.sa-mp.com/showpost.php?p=1410296
  158.  *
  159.  * FIX:      AllowTeleport
  160.  * PROBLEM:  0.3dRC9 removed "AllowPlayerTeleport" and "AllowAdminTeleport" in
  161.  *           favour of "OnPlayerClickMap".  Some scripts used the old code and.
  162.  * SOLUTION: Teleport the player in "OnPlayerClickMap".
  163.  * SEE:      "OnPlayerClickMap", "FIXES_AllowPlayerTeleport", and
  164.  *           "FIXES_AllowAdminTeleport".
  165.  * AUTHOR:   Y_Less
  166.  *
  167.  * FIX:      SetPlayerSpecialAction
  168.  * PROBLEM:  Removing jetpacks from players by setting their special action to 0
  169.  *           causes the sound to stay until death.
  170.  * SOLUTION: Call "ClearAnimations" before "SetPlayerSpecialAction".
  171.  * SEE:      "FIXES_SetPlayerSpecialAction".
  172.  * AUTHOR:   MP2
  173.  * POST:     Private message from MP2.
  174.  *
  175.  * FIX:      OnDialogResponse
  176.  * PROBLEM:  Cheaters can spoof the dialogid they are using to respond to ones
  177.  *           they can't actually see.
  178.  * SOLUTION: Store the displayed dialogid and use that instead.
  179.  * SEE:      "FIXES_OnDialogResponse", "FIXES_ShowPlayerDialog".
  180.  * AUTHOR:   Y_Less
  181.  * FIXED IN: 0.3e RC6
  182.  *
  183.  * FIX:      GetPlayerDialog
  184.  * PROBLEM:  This function doesn't exist.
  185.  * SOLUTION: Add it.  DEFAULTS TO FALSE!
  186.  * SEE:      "FIXES_GetPlayerDialog".
  187.  * AUTHOR:   Y_Less
  188.  *
  189.  * FIX:      SetSpawnInfo
  190.  * PROBLEM:  Kicks the player if "SpawnPlayer" is called before "SetSpawnInfo".
  191.  * SOLUTION: Call "SetSpawnInfo" at least once.
  192.  * SEE:      "OnPlayerConnect".
  193.  * AUTHOR:   Y_Less
  194.  *
  195.  * FIX:      SetPlayerSkin
  196.  * PROBLEM:  Breaks sitting on bikes.
  197.  * SOLUTION: Put them back in the vehicle after setting their skin.
  198.  * SEE:      "FIXES_SetPlayerSkin".
  199.  * AUTHOR:   CyNiC
  200.  * POST:     http://forum.sa-mp.com/showpost.php?p=1756094
  201.  *
  202.  * FIX:      HideMenuForPlayer
  203.  * PROBLEM:  Crashes when passed an invalid menu ID.
  204.  * SOLUTION: Don't hide it when passed an invalid menu.
  205.  * SEE:      "FIXES_HideMenuForPlayer".
  206.  * AUTHOR:   Y_Less
  207.  * POST:     http://forum.sa-mp.com/showpost.php?p=1787297
  208.  *
  209.  * FIX:      valstr
  210.  * PROBLEM:  Crashes on large numbers.
  211.  * SOLUTION: Use "format" instead.
  212.  * SEE:      "FIXES_valstr".
  213.  * AUTHOR:   Slice
  214.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  215.  *
  216.  * FIX:      fclose
  217.  * PROBLEM:  Crashes on an invalid handle.
  218.  * SOLUTION: Check for an invalid handle.
  219.  * SEE:      "FIXES_fclose".
  220.  * AUTHOR:   Slice
  221.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  222.  *
  223.  * FIX:      fwrite
  224.  * PROBLEM:  Crashes on an invalid handle.
  225.  * SOLUTION: Check for an invalid handle.
  226.  * SEE:      "FIXES_fwrite".
  227.  * AUTHOR:   Slice
  228.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  229.  *
  230.  * FIX:      fread
  231.  * PROBLEM:  Crashes on an invalid handle.
  232.  * SOLUTION: Check for an invalid handle.
  233.  * SEE:      "FIXES_fread".
  234.  * AUTHOR:   Slice
  235.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  236.  *
  237.  * FIX:      fputchar
  238.  * PROBLEM:  Crashes on an invalid handle.
  239.  * SOLUTION: Check for an invalid handle.
  240.  * SEE:      "FIXES_fputchar".
  241.  * AUTHOR:   Slice
  242.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  243.  *
  244.  * FIX:      fgetchar
  245.  * PROBLEM:  Crashes on an invalid handle.
  246.  * SOLUTION: Check for an invalid handle.
  247.  * SEE:      "FIXES_fgetchar".
  248.  * AUTHOR:   Slice
  249.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  250.  *
  251.  * FIX:      fblockwrite
  252.  * PROBLEM:  Crashes on an invalid handle.
  253.  * SOLUTION: Check for an invalid handle.
  254.  * SEE:      "FIXES_fblockwrite".
  255.  * AUTHOR:   Slice
  256.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  257.  *
  258.  * FIX:      fblockread
  259.  * PROBLEM:  Crashes on an invalid handle.
  260.  * SOLUTION: Check for an invalid handle.
  261.  * SEE:      "FIXES_fblockread".
  262.  * AUTHOR:   Slice
  263.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  264.  *
  265.  * FIX:      fseek
  266.  * PROBLEM:  Crashes on an invalid handle.
  267.  * SOLUTION: Check for an invalid handle.
  268.  * SEE:      "FIXES_fseek".
  269.  * AUTHOR:   Slice
  270.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  271.  *
  272.  * FIX:      flength
  273.  * PROBLEM:  Crashes on an invalid handle.
  274.  * SOLUTION: Check for an invalid handle.
  275.  * SEE:      "FIXES_flength".
  276.  * AUTHOR:   Slice
  277.  * POST:     http://forum.sa-mp.com/showpost.php?p=1790300
  278.  *
  279.  * FIX:      file_inc
  280.  * PROBLEM:  All file.inc fixes are included separately for major overhead.
  281.  * SOLUTION: Optionally group them all under one define.
  282.  * SEE:      "FIX_file_inc".
  283.  * AUTHOR:   Y_Less
  284.  *
  285.  * FIX:      IsPlayerAttachedObjectSlotUsed
  286.  * PROBLEM:  Doesn't work in OnPlayerDisconnect.
  287.  * SOLUTION: Maintain an internal record of slots used.
  288.  * SEE:      "FIXES_SetPlayerAttachedObject",
  289.  *           "FIXES_RemovePlayerAttachedObject",
  290.  *           "FIXES_IsPAttachedObjectSlotUsed", and
  291.  *           "OnPlayerDisconnect".
  292.  * AUTHOR:   Y_Less
  293.  *
  294.  * FIX:      SetPlayerAttachedObject
  295.  * PROBLEM:  Doesn't remove objects when the mode ends.
  296.  * SOLUTION: Remove them.
  297.  * SEE:      "FIXES_SetPlayerAttachedObject",
  298.  *           "FIXES_RemovePlayerAttachedObject", and
  299.  *           "OnPlayerDisconnect".
  300.  * AUTHOR:   Y_Less
  301.  *
  302.  * FIX:      OnPlayerDeath
  303.  * PROBLEM:  Clients get stuck when they die with an animation applied.
  304.  * SOLUTION: Clear their animations.
  305.  * SEE:      "OnPlayerDeath" and "OnPlayerUpdate".
  306.  * AUTHOR:   h02
  307.  * POST:     http://forum.sa-mp.com/showpost.php?p=1641144
  308.  *
  309.  * FIX:      strins
  310.  * PROBLEM:  Ignores the "maxlength" parameter causing possible crashes.
  311.  * SOLUTION: Manually check the length.
  312.  * SEE:      "FIXES_strins".
  313.  * AUTHOR:   Slice/Y_Less
  314.  * POST:     http://forum.sa-mp.com/showpost.php?p=1860495
  315.  * POST:     http://forum.sa-mp.com/showpost.php?p=1864706
  316.  *
  317.  * FIX:      IsPlayerConnected
  318.  * PROBLEM:  Only uses the lower two bytes of a passed ID.
  319.  * SOLUTION: Mask the numbers.
  320.  * SEE:      "FIXES_IsPlayerConnected".
  321.  * AUTHOR:   Slice
  322.  * POST:     http://forum.sa-mp.com/showpost.php?p=1860464
  323.  *
  324.  * FIX:      OnPlayerCommandText
  325.  * PROBLEM:  Can crash ZCMD when passed a null string.
  326.  * SOLUTION: Pass NULL if invalid inputs given.
  327.  * SEE:      "OnPlayerCommandText".
  328.  * AUTHOR:   Y_Less
  329.  * POST:     http://forum.sa-mp.com/showpost.php?p=1909511
  330.  *
  331.  * FIX:      TrainExit
  332.  * PROBLEM:  When getting out of a train entered by "PutPlayerInVehicle", the
  333.  *           camera does not reset properly.
  334.  * SOLUTION: Reset the camera.
  335.  * SEE:      "FIXES_PutPlayerInVehicle", "FIXES_OnPlayerStateChange".
  336.  * AUTHOR:   Terminator3/Y_Less
  337.  * POST:     http://forum.sa-mp.com/showpost.php?p=1980214
  338.  *
  339.  * FIX:      Kick
  340.  * PROBLEM:  Calling "Kick" in "OnPlayerConnect" doesn't work properly.
  341.  * SOLUTION: Defer it.
  342.  * SEE:      "OnPlayerConnect", "FIXES_Kick".
  343.  * AUTHOR:   Y_Less
  344.  * POST:     http://forum.sa-mp.com/showpost.php?p=1989453
  345.  *
  346.  * FIX:      ZeroHP
  347.  * PROBLEM:  Sometimes "OnPlayerDeath" is called but they don't die.
  348.  * SOLUTION: Clear animations and set their health to -1.0.
  349.  * SEE:      "OnPlayerDeath".
  350.  * AUTHOR:   Kar/Y_Less
  351.  * POST:     http://forum.sa-mp.com/showpost.php?p=1993480
  352.  *
  353.  * ==============
  354.  *  STYLE RULES:
  355.  * ==============
  356.  *
  357.  * All globals should be "static stock" whenever possible (so they can only be
  358.  *     accessed from this one file).
  359.  *
  360.  * Statics must start with "FIXES_gs", and all other globals with "FIXES_g".
  361.  *
  362.  * All functions not overriding existing functions must start with "FIXES_".
  363.  *
  364.  * Macros must be upper case, use underscores, and start "FIXES_":
  365.  *     "FIXES_LIKE_THIS".
  366.  *
  367.  * Functions should be upper camel case (as the original functions are)
  368.  *     "FIXES_LikeThis".
  369.  *
  370.  * Globals (after the prefix) should be upper camel case, and locals lower camel
  371.  *     case "likeThis".
  372.  *
  373.  * ALS should be used to hook functions and callbacks.
  374.  *
  375.  * The ALS prefix for chaining is also "FIXES_"
  376.  *
  377.  * Enums start with "E_" or "e_" depending on type, then follow rules for
  378.  *     macros.
  379.  *
  380.  * Use "FIXES_gsCallbackHooks" and "E_FIXES_CALLBACK_HOOKS" for ALS chaining.
  381.  *
  382.  * NO libraries should be included - not even the default SA:MP ones.  Let the
  383.  *     user do it.
  384.  *
  385.  * Due to the above rule, you cannot assume any third party libraries AT ALL, so
  386.  *     do not use them.
  387.  *
  388.  * Certain terms may be shortened when dealing with long callback names to avoid
  389.  *     compile truncation warnings (max symbol length is 31).  Current list:
  390.  *    
  391.  *     "Checkpoint" -> "CP"
  392.  *     "Update"     -> "Upd"
  393.  *     "TextDraw"   -> "TD"
  394.  *     "Object"     -> "Obj"
  395.  *     "Player"     -> "P"
  396.  *
  397.  * Document all fixes at the top of the file, and highlight code.
  398.  *
  399.  * 4 space TABS - do not edit this file in PAWNO unless you know how to correct
  400.  *     the indentation.
  401.  *
  402.  * All rules have exceptions, but they must be justifiable.  For example
  403.  *     "IS_FILTERSCRIPT" is a global variable, but is not called
  404.  *     "FIXES_gIsFilterscript" to better match the "FILTERSCRIPT" macro it
  405.  *     replaces.  Now a macro for "_FIXES_gIsFilterscript".
  406.  *
  407.  * Variables which need to be fully global (i.e. not "static"), but should not
  408.  *     actually be used by other people (e.g. appear inside a macro) should be
  409.  *     prefixed with "_FIXES" instead of "FIXES" to indicate their private use.
  410.  *
  411.  * No comments beyond the end of column 80 (where the line in "PAWNO" is).
  412.  *
  413.  * When redefining a native, add a "BAD_" external name declaration with the
  414.  *     "_ALS_" definition so that others may use the original native if they so
  415.  *     desire (with the caveat that it may break all fixes).  Note the "BAD_"
  416.  *     name is meant to indicate the possibility of breaking the fix, not a
  417.  *     comment on the original native function.
  418.  *
  419.  * If a bug is fixed in some version of the server it can be conditionally
  420.  *     included here.  This is done by checking for the existance of a native
  421.  *     function introduced in the same server version.  For example
  422.  *     "TogglePlayerControllable" was fixed in 0.3eRC6, the same time as the
  423.  *     "SetObjectMaterial" native was introduced, thus the inclusion becomes:
  424.  *    
  425.  *     #if !defined FIX_TogglePlayerControllable
  426.  *         #define FIX_TogglePlayerControllable (!defined SetObjectMaterial)
  427.  *     #endif
  428.  *    
  429.  *     This only includes this fix if that native doesn't exist.
  430.  *
  431.  * Documentation explanation:
  432.  *
  433.  *     FIX:      <Short name>
  434.  *     PROBLEM:  <Description of problem>
  435.  *     SOLUTION: <Description of solution>
  436.  *     SEE:      <List of relevant functions>
  437.  *     AUTHOR:   <Person who wrote the fix>
  438.  *     POST:     <Link to the original post where applicable>
  439.  *     FIXED IN: <Server version of official fix where applicable>
  440.  */
  441.  
  442. // We can add server version compiler code here to only compile fixes that apply
  443. // to the version of the includes for which the user is compiling.
  444. #if !defined FIX_GetPlayerColor
  445.     #if defined FIX_GetPlayerColour
  446.         #define FIX_GetPlayerColor       (FIX_GetPlayerColour)
  447.     #else
  448.         #define FIX_GetPlayerColor       (1)
  449.     #endif
  450. #endif
  451.  
  452. #if !defined FIX_FILTERSCRIPT
  453.     #define FIX_FILTERSCRIPT             (1)
  454. #endif
  455.  
  456. #if !defined FIX_SpawnPlayer
  457.     #define FIX_SpawnPlayer              (1)
  458. #endif
  459.  
  460. #if !defined FIX_SetPlayerName
  461.     #define FIX_SetPlayerName            (1)
  462. #endif
  463.  
  464. #if !defined FIX_GetPlayerSkin
  465.     #define FIX_GetPlayerSkin            (1)
  466. #endif
  467.  
  468. #if !defined FIX_GetWeaponName
  469.     #define FIX_GetWeaponName            (1)
  470. #endif
  471.  
  472. #if !defined FIX_SetPlayerWorldBounds
  473.     #define FIX_SetPlayerWorldBounds     (1)
  474. #endif
  475.  
  476. #if !defined FIX_TogglePlayerControllable
  477.     #define FIX_TogglePlayerControllable (!defined SetObjectMaterial)
  478. #endif
  479.  
  480. #if !defined FIX_HydraSniper
  481.     #define FIX_HydraSniper              (1)
  482. #endif
  483.  
  484. #if !defined FIX_IsPlayerInCheckpoint
  485.     #define FIX_IsPlayerInCheckpoint     (1)
  486. #endif
  487.  
  488. #if !defined FIX_IsPlayerInRaceCheckpoint
  489.     #define FIX_IsPlayerInRaceCheckpoint (1)
  490. #endif
  491.  
  492. #if !defined FIX_GetPlayerWeapon
  493.     #define FIX_GetPlayerWeapon          (1)
  494. #endif
  495.  
  496. #if !defined FIX_PutPlayerInVehicle
  497.     #define FIX_PutPlayerInVehicle       (1)
  498. #endif
  499.  
  500. #if !defined FIX_KEY_AIM
  501.     #define FIX_KEY_AIM                  (!defined KEY_AIM)
  502. #endif
  503.  
  504. #if !defined FIX_SetPlayerCheckpoint
  505.     #define FIX_SetPlayerCheckpoint      (1)
  506. #endif
  507.  
  508. #if !defined FIX_SetPlayerRaceCheckpoint
  509.     #define FIX_SetPlayerRaceCheckpoint  (1)
  510. #endif
  511.  
  512. #if !defined FIX_TextDrawCreate
  513.     #define FIX_TextDrawCreate           (1)
  514. #endif
  515.  
  516. #if !defined FIX_TextDrawSetString
  517.     #define FIX_TextDrawSetString        (1)
  518. #endif
  519.  
  520. #if !defined FIX_AllowInteriorWeapons
  521.     #define FIX_AllowInteriorWeapons     (1)
  522. #endif
  523.  
  524. #if !defined FIX_OnPlayerEnterVehicle
  525.     #define FIX_OnPlayerEnterVehicle     (!defined OnPlayerClickMap)
  526. #endif
  527.  
  528. #if !defined FIX_AllowTeleport
  529.     #define FIX_AllowTeleport            (defined OnPlayerClickMap)
  530. #endif
  531.  
  532. #if !defined FIX_SetPlayerSpecialAction
  533.     #define FIX_SetPlayerSpecialAction   (1)
  534. #endif
  535.  
  536. #if !defined FIX_OnDialogResponse
  537.     #define FIX_OnDialogResponse         (1)
  538. #endif
  539.  
  540. #if !defined FIX_GetPlayerDialog
  541.     #define FIX_GetPlayerDialog          (0)
  542. #endif
  543.  
  544. #if !defined FIX_SetSpawnInfo
  545.     #define FIX_SetSpawnInfo             (!defined GetPlayerVersion)
  546. #endif
  547.  
  548. #if !defined FIX_SetPlayerSkin
  549.     #define FIX_SetPlayerSkin            (1)
  550. #endif
  551.  
  552. #if !defined FIX_HideMenuForPlayer
  553.     #define FIX_HideMenuForPlayer        (1)
  554. #endif
  555.  
  556. #if !defined FIX_valstr
  557.     #define FIX_valstr                   (1)
  558. #endif
  559.  
  560. #if !defined FIX_file_inc
  561.     #define FIX_file_inc                 (1)
  562. #endif
  563.  
  564. #if !defined FIX_fclose
  565.     #define FIX_fclose                   (FIX_file_inc)
  566. #endif
  567.  
  568. #if !defined FIX_fwrite
  569.     #define FIX_fwrite                   (FIX_file_inc)
  570. #endif
  571.  
  572. #if !defined FIX_fread
  573.     #define FIX_fread                    (FIX_file_inc)
  574. #endif
  575.  
  576. #if !defined FIX_fputchar
  577.     #define FIX_fputchar                 (FIX_file_inc)
  578. #endif
  579.  
  580. #if !defined FIX_fgetchar
  581.     #define FIX_fgetchar                 (FIX_file_inc)
  582. #endif
  583.  
  584. #if !defined FIX_fblockwrite
  585.     #define FIX_fblockwrite              (FIX_file_inc)
  586. #endif
  587.  
  588. #if !defined FIX_fblockread
  589.     #define FIX_fblockread               (FIX_file_inc)
  590. #endif
  591.  
  592. #if !defined FIX_fseek
  593.     #define FIX_fseek                    (FIX_file_inc)
  594. #endif
  595.  
  596. #if !defined FIX_flength
  597.     #define FIX_flength                  (FIX_file_inc)
  598. #endif
  599.  
  600. #if !defined FIX_IsPlayerAttachedObjSlotUsed
  601.     #define FIX_IsPlayerAttachedObjSlotUsed (1)
  602. #endif
  603.  
  604. #if !defined FIX_SetPlayerAttachedObject
  605.     #define FIX_SetPlayerAttachedObject  (1)
  606. #endif
  607.  
  608. #if !defined FIX_OnPlayerDeath
  609.     #define FIX_OnPlayerDeath            (1)
  610. #endif
  611.  
  612. #if !defined FIX_strins
  613.     #define FIX_strins                   (1)
  614. #endif
  615.  
  616. #if !defined FIX_IsPlayerConnected
  617.     #define FIX_IsPlayerConnected        (1)
  618. #endif
  619.  
  620. #if !defined FIX_OnPlayerCommandText
  621.     #define FIX_OnPlayerCommandText      (!defined _ALS_OnPlayerCommandText)
  622. #endif
  623.  
  624. #if !defined FIX_TrainExit
  625.     #define FIX_TrainExit                (1)
  626. #endif
  627.  
  628. #if !defined FIX_Kick
  629.     #define FIX_Kick                     (1)
  630. #endif
  631.  
  632. #if !defined FIX_ZeroHP
  633.     #define FIX_ZeroHP                   (1)
  634. #endif
  635.  
  636. /*
  637.  * FIXES_Debug
  638.  *
  639.  * If this define is set to 1, then debug printing is turned on for any
  640.  * functions which may use it.  Otherwise, the compiler entirely removes the
  641.  * code to print anything, leaving 0 run-time overhead.
  642.  */
  643. #if defined FIXES_Debug
  644.     #if FIXES_Debug == 1
  645.         #define FIXES_PRINTF(%0); print(_FIXES_gIsFilterscript ? ("* FIXES_PRINTF (FS):") : ("* FIXES_PRINTF (GM):")),printf("*** " %0);
  646.     #else
  647.         #undef FIXES_Debug
  648.     #endif
  649. #endif
  650. #if !defined FIXES_PRINTF
  651.     #define FIXES_Debug 0
  652.     #define FIXES_PRINTF(%0);
  653. #endif
  654.  
  655. /*
  656.  * FIXES_Single
  657.  *
  658.  * If this define is set to 1, then the old style include is used, with no
  659.  * support for multiple scripts running at the same time on the server (i.e. no
  660.  * gamemodes and filter scripts at the same time).  You can only have one or the
  661.  * other or bugs.
  662.  */
  663. #if defined FIXES_Single
  664.     #undef FIXES_Single
  665.     #define FIXES_Single (1)
  666. #else
  667.     #define FIXES_Single (0)
  668. #endif
  669.  
  670. /*
  671.  * E_FIXES_CALLBACK_HOOKS_1
  672.  * E_FIXES_CALLBACK_HOOKS_2
  673.  *
  674.  * Two enums to define the bits used to efficiently store wether of not the next
  675.  * callback in the ALS chain exists.  Breaks naming convention for elements from
  676.  * "E_FIXES_ON_GAME_MODE_INIT" to "E_FIXES_OnGameModeInit" for compatibility
  677.  * with existing names.  Note that "Checkpoint" and "Update" have been shortened
  678.  * to "CP" and "Upd" in certain symbols to stay below the 31 character limit.
  679.  */
  680. enum E_FIXES_CALLBACK_HOOKS_1 (<<= 1)
  681. {
  682.     E_FIXES_OnGameModeInit = 1,
  683.     E_FIXES_OnGameModeExit,
  684.     E_FIXES_OnFilterScriptInit,
  685.     E_FIXES_OnFilterScriptExit,
  686.     E_FIXES_OnPlayerConnect,
  687.     E_FIXES_OnPlayerDisconnect,
  688.     E_FIXES_OnPlayerSpawn,
  689.     E_FIXES_OnPlayerDeath,
  690.     E_FIXES_OnVehicleSpawn,
  691.     E_FIXES_OnVehicleDeath,
  692.     E_FIXES_OnPlayerText,
  693.     E_FIXES_OnPlayerCommandText,
  694.     E_FIXES_OnPlayerRequestClass,
  695.     E_FIXES_OnPlayerEnterVehicle,
  696.     E_FIXES_OnPlayerExitVehicle,
  697.     E_FIXES_OnPlayerStateChange,
  698.     E_FIXES_OnPlayerEnterCheckpoint,
  699.     E_FIXES_OnPlayerLeaveCheckpoint,
  700.     E_FIXES_OnPlayerEnterRaceCP,
  701.     E_FIXES_OnPlayerLeaveRaceCP,
  702.     E_FIXES_OnRconCommand,
  703.     E_FIXES_OnPlayerRequestSpawn,
  704.     E_FIXES_OnObjectMoved,
  705.     E_FIXES_OnPlayerObjectMoved,
  706.     E_FIXES_OnPlayerPickUpPickup,
  707.     E_FIXES_OnVehicleMod,
  708.     E_FIXES_OnEnterExitModShop,
  709.     E_FIXES_OnVehiclePaintjob,
  710.     E_FIXES_OnVehicleRespray,
  711.     E_FIXES_OnVehicleDamageStatusUp,
  712.     E_FIXES_OnPlayerSelectedMenuRow,
  713.     E_FIXES_OnPlayerExitedMenu
  714. }
  715.  
  716. enum E_FIXES_CALLBACK_HOOKS_2 (<<= 1)
  717. {
  718.     E_FIXES_OnPlayerInteriorChange = 1,
  719.     E_FIXES_OnPlayerKeyStateChange,
  720.     E_FIXES_OnRconLoginAttempt,
  721.     E_FIXES_OnPlayerUpdate,
  722.     E_FIXES_OnPlayerStreamIn,
  723.     E_FIXES_OnPlayerStreamOut,
  724.     E_FIXES_OnVehicleStreamIn,
  725.     E_FIXES_OnVehicleStreamOut,
  726.     E_FIXES_OnDialogResponse,
  727.     E_FIXES_OnPlayerClickPlayer,
  728.     E_FIXES_OnPlayerClickMap,
  729.     E_FIXES_OnPlayerClickTextDraw,
  730.     E_FIXES_OnPlayerClickPlayerTD,
  731.     E_FIXES_OnPlayerEditObject,
  732.     E_FIXES_OnPlayerEditAttachedObj,
  733.     E_FIXES_OnPlayerSelectObject,
  734.     E_FIXES_OnPlayerTakeDamage,
  735.     E_FIXES_OnPlayerGiveDamage
  736. }
  737.  
  738. /*
  739.  * E_FIXES_WORLDBOUND_DATA
  740.  *
  741.  * Store data for each player on their worldbound data.
  742.  */
  743. enum E_FIXES_WORLDBOUND_DATA
  744. {
  745.     // "Previous".
  746.     Float:E_FIXES_WORLDBOUND_DATA_PX,
  747.     Float:E_FIXES_WORLDBOUND_DATA_PY,
  748.     Float:E_FIXES_WORLDBOUND_DATA_PZ,
  749.     // "Lower".
  750.     Float:E_FIXES_WORLDBOUND_DATA_LX,
  751.     Float:E_FIXES_WORLDBOUND_DATA_LY,
  752.     // "Upper".
  753.     Float:E_FIXES_WORLDBOUND_DATA_UX,
  754.     Float:E_FIXES_WORLDBOUND_DATA_UY
  755. }
  756.  
  757. /*
  758.  * e_FIXES_BOOLS
  759.  *
  760.  * Collection of boolean values for players, designed to collect multiple checks
  761.  * in to one variable to reduce memory consumption.
  762.  */
  763. enum e_FIXES_BOOLS (<<= 1)
  764. {
  765.     // Handy definition for nothing set.
  766.     e_FIXES_BOOLS_NONE = 0,
  767.     // Does this player have worldbounds enabled?
  768.     e_FIXES_BOOLS_WORLDBOUNDS = 1,
  769.     e_FIXES_BOOLS_UNCONTROLLABLE,
  770.     e_FIXES_BOOLS_PUT_IN_VEHICLE,
  771.     e_FIXES_BOOLS_BLOCK,
  772.     e_FIXES_BOOLS_TELEPORT,
  773.     e_FIXES_BOOLS_CONNECTED,
  774.     e_FIXES_BOOLS_INTERIOR,
  775.     e_FIXES_BOOLS_PUT_IN_TRAIN,
  776.     e_FIXES_BOOLS_KICKED,
  777.     e_FIXES_BOOLS_ON_PLAYER_CONNECT
  778. }
  779.  
  780. /*
  781.  * e_FIXES_SETTINGS
  782.  *
  783.  * Collection of boolean values for the script as a whole.  Stores a variety of
  784.  * settings that are true/false.
  785.  */
  786. enum e_FIXES_SETTINGS (<<= 1)
  787. {
  788.     // Handy definition for nothing set.
  789.     e_FIXES_SETTINGS_NONE = 0,
  790.     e_FIXES_SETTINGS_INTERIOR = 1,
  791.     e_FIXES_SETTINGS_ADMIN_TELEPORT,
  792.     e_FIXES_SETTINGS_IN_CHARGE,
  793.     e_FIXES_SETTINGS_DROP_ALL_DATA,
  794.     e_FIXES_SETTINGS_ENDING
  795. }
  796.  
  797. /*
  798.  * _FIXES_CEILDIV
  799.  *
  800.  * Do a ceiling division of the first number by the second number.
  801.  */
  802. #define _FIXES_CEILDIV(%0,%1) (((%0) + (%1) - 1) / (%1))
  803.  
  804. /*
  805.  * _FIXES_INFINITY
  806.  *
  807.  * IEEE 754 definition of infinity.
  808.  */
  809. #define _FIXES_INFINITY (Float:0x7F800000)
  810.  
  811. /*
  812.  * _FIXES_N_INFINITY
  813.  *
  814.  * IEEE 754 definition of negative infinity.
  815.  */
  816. #define _FIXES_N_INFINITY (Float:0xFF800000)
  817.  
  818. /*
  819.  * _FIXES_ATTACHMENTS
  820.  *
  821.  * The number of players whose attachment data (10-bits) can be stored in one
  822.  * cell.
  823.  */
  824. #define _FIXES_ATTACHMENTS (cellbits / MAX_PLAYER_ATTACHED_OBJECTS)
  825.  
  826. // These varaibles are NOT pre-processor dependent as they are stock.  It's just
  827. // simpler than trying to figure out when or if a semi-colon is needed.
  828. #if !FIX_FILTERSCRIPT
  829. static
  830. #endif
  831. stock
  832.     /*
  833.      * bool:_FIXES_gIsFilterscript
  834.      *
  835.      * Runtime equivalent of "FILTERSCRIPT" for when it is not set by the user.
  836.      */
  837.     bool:_FIXES_gIsFilterscript;
  838.  
  839. static stock
  840.     /*
  841.      * E_FIXES_CALLBACK_HOOKS_1:FIXES_gsCallbackHooks1
  842.      * E_FIXES_CALLBACK_HOOKS_1:FIXES_gsCallbackHooks2
  843.      *
  844.      * Bit arrays of callbacks.  You can only have 32 callbacks per variable,
  845.      * and there are more than that many, so we need more than one variable.
  846.      * Add new callback detection to "FIXES_ScriptInit" - only actually used
  847.      * callbacks are currently hooked.
  848.      */
  849.     E_FIXES_CALLBACK_HOOKS_1:FIXES_gsCallbackHooks1,
  850.     E_FIXES_CALLBACK_HOOKS_2:FIXES_gsCallbackHooks2,
  851.     /*
  852.      * FIXES_gsPlayerSkin[MAX_PLAYERS]
  853.      *
  854.      * The skin the player is currently using.
  855.      */
  856.     FIXES_gsPlayerSkin[MAX_PLAYERS],
  857.     /*
  858.      * e_FIXES_BOOLEAN_DATA:FIXES_gsPlayerBools[MAX_PLAYERS]
  859.      *
  860.      * Collection of boolean values for players.
  861.      */
  862.     e_FIXES_BOOLS:FIXES_gsPlayerBools[MAX_PLAYERS],
  863.     /*
  864.      * FIXES_gsWorldbounds[MAX_PLAYERS][E_FIXES_WORLDBOUND_DATA]
  865.      *
  866.      * All data for players on where their worldbounds are and where they last
  867.      * were before they went through the bounds by crouching.
  868.      */
  869.     FIXES_gsWorldbounds[MAX_PLAYERS][E_FIXES_WORLDBOUND_DATA],
  870.     /*
  871.      * FIXES_gsPlayerWeapon[MAX_PLAYERS]
  872.      *
  873.      * Stores the weapon set by "SetPlayerArmedWeapon" when in a vehicle.
  874.      */
  875.     FIXES_gsPlayerWeapon[MAX_PLAYERS],
  876.     /*
  877.      * FIXES_gsVehicleSeatData[MAX_PLAYERS]
  878.      *
  879.      * What vehicle the player is due to go in.
  880.      */
  881.     FIXES_gsVehicleSeatData[MAX_PLAYERS],
  882.     /*
  883.      * FIXES_gsVehicleLocked[(MAX_PLAYERS * MAX_VEHICLES + cellbits - 1) / cellbits]
  884.      *
  885.      * Is this vehicle locked for a player.  This is a compressed 2D binary
  886.      * array, made by concatenating many bits together (saves 1kb-3kb)!  Is
  887.      * there a reason this array exists?
  888.      */
  889.     //FIXES_gsVehicleLocked[_FIXES_CEILDIV(MAX_PLAYERS * MAX_VEHICLES, cellbits)],
  890.     /*
  891.      * FIXES_gsDialogID[MAX_PLAYERS]
  892.      *
  893.      * Stores the true ID of the dialog the player is looking at to prevent
  894.      * spoofing.
  895.      */
  896.     FIXES_gsDialogID[MAX_PLAYERS] = {-1, ...},
  897.     /*
  898.      * e_FIXES_SETTINGS:FIXES_gsSettings
  899.      *
  900.      * A collection of 1-bit options, compressed together to save space.
  901.      */
  902.     e_FIXES_SETTINGS:FIXES_gsSettings,
  903.     /*
  904.      * FIXES_gsObjectSlots[_FIXES_CEILDIV(MAX_PLAYERS, _FIXES_ATTACHMENTS)]
  905.      *
  906.      * A record of which attached object slots a player has used.
  907.      */
  908.     FIXES_gsObjectSlots[_FIXES_CEILDIV(MAX_PLAYERS, _FIXES_ATTACHMENTS)],
  909.     /*
  910.      * FIXES_gsLastAnimation[MAX_PLAYERS]
  911.      *
  912.      * The last animation a player used.
  913.      */
  914.     FIXES_gsLastAnimation[MAX_PLAYERS];
  915.  
  916. static stock const
  917.     /*
  918.      * FIXES_gscPlayerColours[100]
  919.      *
  920.      * There are only 100 colours used by default, with SA:MP looping through
  921.      * them repeatedly.
  922.      */
  923.     FIXES_gscPlayerColours[100] =
  924.         {
  925.             0xFF8C13FF, 0xC715FFFF, 0x20B2AAFF, 0xDC143CFF, 0x6495EDFF,
  926.             0xF0E68CFF, 0x778899FF, 0xFF1493FF, 0xF4A460FF, 0xEE82EEFF,
  927.             0xFFD720FF, 0x8B4513FF, 0x4949A0FF, 0x148B8BFF, 0x14FF7FFF,
  928.             0x556B2FFF, 0x0FD9FAFF, 0x10DC29FF, 0x534081FF, 0x0495CDFF,
  929.             0xEF6CE8FF, 0xBD34DAFF, 0x247C1BFF, 0x0C8E5DFF, 0x635B03FF,
  930.             0xCB7ED3FF, 0x65ADEBFF, 0x5C1ACCFF, 0xF2F853FF, 0x11F891FF,
  931.             0x7B39AAFF, 0x53EB10FF, 0x54137DFF, 0x275222FF, 0xF09F5BFF,
  932.             0x3D0A4FFF, 0x22F767FF, 0xD63034FF, 0x9A6980FF, 0xDFB935FF,
  933.             0x3793FAFF, 0x90239DFF, 0xE9AB2FFF, 0xAF2FF3FF, 0x057F94FF,
  934.             0xB98519FF, 0x388EEAFF, 0x028151FF, 0xA55043FF, 0x0DE018FF,
  935.             0x93AB1CFF, 0x95BAF0FF, 0x369976FF, 0x18F71FFF, 0x4B8987FF,
  936.             0x491B9EFF, 0x829DC7FF, 0xBCE635FF, 0xCEA6DFFF, 0x20D4ADFF,
  937.             0x2D74FDFF, 0x3C1C0DFF, 0x12D6D4FF, 0x48C000FF, 0x2A51E2FF,
  938.             0xE3AC12FF, 0xFC42A8FF, 0x2FC827FF, 0x1A30BFFF, 0xB740C2FF,
  939.             0x42ACF5FF, 0x2FD9DEFF, 0xFAFB71FF, 0x05D1CDFF, 0xC471BDFF,
  940.             0x94436EFF, 0xC1F7ECFF, 0xCE79EEFF, 0xBD1EF2FF, 0x93B7E4FF,
  941.             0x3214AAFF, 0x184D3BFF, 0xAE4B99FF, 0x7E49D7FF, 0x4C436EFF,
  942.             0xFA24CCFF, 0xCE76BEFF, 0xA04E0AFF, 0x9F945CFF, 0xDCDE3DFF,
  943.             0x10C9C5FF, 0x70524DFF, 0x0BE472FF, 0x8A2CD7FF, 0x6152C2FF,
  944.             0xCF72A9FF, 0xE59338FF, 0xEEDC2DFF, 0xD8C762FF, 0xD8C762FF
  945.         },
  946.     /*
  947.      * FIXES_gscMaxPassengers[]
  948.      *
  949.      * This is a compressed (4-bit) list of the maximum number of passengers in
  950.      * any vehicle, confirmed by a number of sources. "F" (15) means invalid
  951.      * vehicle.
  952.      */
  953.     FIXES_gscMaxPassengers[] =
  954.         {
  955.             0x10331113, 0x11311131, 0x11331313, 0x80133301, 0x1381F110, 0x10311103, 0x10001F10, 0x11113311, 0x13113311,
  956.             0x31101100, 0x30001301, 0x11031311, 0x11111331, 0x10013111, 0x01131100, 0x11111110, 0x11100031, 0x11130221,
  957.             0x33113311, 0x11111101, 0x33101133, 0x101001F0, 0x03133111, 0xFF11113F, 0x13330111, 0xFF131111, 0x0000FF3F
  958.         },
  959.     /*
  960.      * FIXES_gscNULL[]
  961.      *
  962.      * NULL.  This is stored as a global string to reduce memory usage.
  963.      */
  964.     FIXES_gscNULL[] = "\1\0",
  965.     /*
  966.      * FIXES_gscSpec@[]
  967.      *
  968.      * Specifier "".
  969.      */
  970.     FIXES_gscSpec@[] = "",
  971.     /*
  972.      * FIXES_gscSpec@i[]
  973.      *
  974.      * Specifier "i".
  975.      */
  976.     FIXES_gscSpec@i[] = "i",
  977.     /*
  978.      * FIXES_gscSpec@ii[]
  979.      *
  980.      * Specifier "ii".
  981.      */
  982.     FIXES_gscSpec@ii[] = "ii",
  983.     /*
  984.      * FIXES_gscSpec@iii[]
  985.      *
  986.      * Specifier "iii".
  987.      */
  988.     FIXES_gscSpec@iii[] = "iii",
  989.     /*
  990.      * FIXES_gscSpec@ifff[]
  991.      *
  992.      * Specifier "ifff".
  993.      */
  994.     FIXES_gscSpec@ifff[] = "ifff",
  995.     /*
  996.      * FIXES_gscSpec@iffff[]
  997.      *
  998.      * Specifier "iffff".
  999.      */
  1000.     FIXES_gscSpec@iffff[] = "iffff",
  1001.     /*
  1002.      * FIXES_gscSpec@is[]
  1003.      *
  1004.      * Specifier "is".
  1005.      */
  1006.     FIXES_gscSpec@is[] = "is",
  1007.     /*
  1008.      * FIXES_gscSpec@iiiis[]
  1009.      *
  1010.      * Specifier "iiiis".
  1011.      */
  1012.     FIXES_gscSpec@iiiis[] = "iiiis",
  1013.     /*
  1014.      * FIXES_gscSpec@iiiii[]
  1015.      *
  1016.      * Specifier "iiiii".
  1017.      */
  1018.     FIXES_gscSpec@iiiii[] = "iiiii",
  1019.     /*
  1020.      * FIXES_gscTempName[]
  1021.      *
  1022.      * The temporary name to give when renaming people.
  1023.      */
  1024.     FIXES_gscTempName[] = "FIXES_TEMP_NAME",
  1025.     /*
  1026.      * FIXES_gscOrderProperty[]
  1027.      *
  1028.      * The property to check for script ordering.
  1029.      */
  1030.     FIXES_gscOrderProperty[] = "FIXES_gscOrderProperty",
  1031.     /*
  1032.      * FIXES_gscNoGMProperty[]
  1033.      *
  1034.      * Call "_FIXES_DetermineOrder" in the GM or not?
  1035.      */
  1036.     FIXES_gscNoGMProperty[] = "FIXES_gscNoGMProperty",
  1037.     /*
  1038.      * FIXES_gscDetermineOrder[]
  1039.      *
  1040.      * Name of the ordering callback.
  1041.      */
  1042.     FIXES_gscDetermineOrder[] = "_FIXES_DetermineOrder",
  1043.     /*
  1044.      * FIXES_gscAllowTeleport[]
  1045.      *
  1046.      * Name of the remote allow teleport function.
  1047.      */
  1048.     FIXES_gscAllowTeleport[] = "_FIXES_AllowTeleport",
  1049.     /*
  1050.      * FIXES_gscPutPlayerInVehicle[]
  1051.      *
  1052.      * Name of the remote vehicle entry function.
  1053.      */
  1054.     FIXES_gscPutPlayerInVehicle[] = "_FIXES_PutPlayerInVehicle",
  1055.     /*
  1056.      * FIXES_gscAllowInteriorWeapons[]
  1057.      *
  1058.      * Name of the remote interior weapons function.
  1059.      */
  1060.     FIXES_gscAllowInteriorWeapons[] = "_FIXES_AllowInteriorWeapons",
  1061.     /*
  1062.      * FIXES_gscSetPlayerAttachedObj[]
  1063.      *
  1064.      * Name of the remote attache object function.
  1065.      */
  1066.     FIXES_gscSetPlayerAttachedObj[] = "_FIXES_SetPlayerAttachedObject",
  1067.     /*
  1068.      * FIXES_gscTogglePlayerControl[]
  1069.      *
  1070.      * Name of the remote player toggle function.
  1071.      */
  1072.     FIXES_gscTogglePlayerControl[] = "_FIXES_TogglePlayerControllable",
  1073.     /*
  1074.      * FIXES_gscSetPlayerWorldBounds[]
  1075.      *
  1076.      * Name of the remote world bounds function.
  1077.      */
  1078.     FIXES_gscSetPlayerWorldBounds[] = "_FIXES_SetPlayerWorldBounds",
  1079.     /*
  1080.      * FIXES_gscReturnProperty[]
  1081.      *
  1082.      * The property for accurate returns.
  1083.      */
  1084.     FIXES_gscReturnProperty[] = "FIXES_gscReturnProperty";
  1085.  
  1086. static stock
  1087.     /*
  1088.      * FIXES_pvarNotNewPlayer[]
  1089.      *
  1090.      * This variable records wether or not this player is brand new to the
  1091.      * server, and not just having "OnPlayerConnect" called due to a script
  1092.      * load.  There are certain functions that need applying only the very first
  1093.      * time they connect, then this gets set.
  1094.      */
  1095.     FIXES_pvarNotNewPlayer[] = "FIXES_pvarNotNewPlayer",
  1096.     /*
  1097.      * FIXES_pvarPlayerWeapon[]
  1098.      *
  1099.      * Name of the pvar in which to store the player's current weapon.
  1100.      */
  1101.     FIXES_pvarPlayerWeapon[] = "FIXES_pvarPlayerWeapon",
  1102.     /*
  1103.      * FIXES_pvarPlayerSkin[]
  1104.      *
  1105.      * Name of the pvar in which to store the player's current skin.
  1106.      */
  1107.     FIXES_pvarPlayerSkin[] = "FIXES_pvarPlayerSkin",
  1108.     /*
  1109.      * FIXES_gscKick[]
  1110.      *
  1111.      * Name of the kick timer function.
  1112.      */
  1113.     FIXES_gscKick[] = "_FIXES_Kick",
  1114.     /*
  1115.      * FIXES_pvarKick[]
  1116.      *
  1117.      * Name of the pvar in which to store a player's kick timer.
  1118.      */
  1119.     FIXES_pvarKick[] = "FIXES_pvarKick",
  1120.     /*
  1121.      * FIXES_pvarPlayerDialog[]
  1122.      *
  1123.      * Name of the pvar in which to store the player's current dialogid.
  1124.      */
  1125.     FIXES_pvarPlayerDialog[] = "FIXES_pvarPlayerDialog";
  1126.  
  1127. /*
  1128.  * FIXES_DEFINE_STRING(callback)
  1129.  *
  1130.  * Define strings for every callback name.  This macro creates "static stock
  1131.  * const" strings for every next callback name (i.e. the ones called to continue
  1132.  * the chain after "fixes.inc" is done.  This is done this way to only need to
  1133.  * include every callback name ONCE in the compiled ".amx" file, the old method
  1134.  * had multiple copies of the same string literal in the final code.
  1135.  */
  1136. #define FIXES_DEFINE_STRING(%0On%1) static stock const FIXES_gsc%1[] = "FIXES_On"#%1
  1137.  
  1138. FIXES_DEFINE_STRING(OnGameModeInit);
  1139. FIXES_DEFINE_STRING(OnGameModeExit);
  1140. FIXES_DEFINE_STRING(OnFilterScriptInit);
  1141. FIXES_DEFINE_STRING(OnFilterScriptExit);
  1142. FIXES_DEFINE_STRING(OnPlayerConnect);
  1143. FIXES_DEFINE_STRING(OnPlayerDisconnect);
  1144. FIXES_DEFINE_STRING(OnPlayerSpawn);
  1145. FIXES_DEFINE_STRING(OnPlayerDeath);
  1146. FIXES_DEFINE_STRING(OnVehicleSpawn);
  1147. FIXES_DEFINE_STRING(OnVehicleDeath);
  1148. FIXES_DEFINE_STRING(OnPlayerText);
  1149. FIXES_DEFINE_STRING(OnPlayerCommandText);
  1150. FIXES_DEFINE_STRING(OnPlayerRequestClass);
  1151. FIXES_DEFINE_STRING(OnPlayerEnterVehicle);
  1152. FIXES_DEFINE_STRING(OnPlayerExitVehicle);
  1153. FIXES_DEFINE_STRING(OnPlayerStateChange);
  1154. FIXES_DEFINE_STRING(OnPlayerEnterCheckpoint);
  1155. FIXES_DEFINE_STRING(OnPlayerLeaveCheckpoint);
  1156. FIXES_DEFINE_STRING(OnPlayerEnterRaceCP);
  1157. FIXES_DEFINE_STRING(OnPlayerLeaveRaceCP);
  1158. FIXES_DEFINE_STRING(OnRconCommand);
  1159. FIXES_DEFINE_STRING(OnPlayerRequestSpawn);
  1160. FIXES_DEFINE_STRING(OnObjectMoved);
  1161. FIXES_DEFINE_STRING(OnPlayerObjectMoved);
  1162. FIXES_DEFINE_STRING(OnPlayerPickUpPickup);
  1163. FIXES_DEFINE_STRING(OnVehicleMod);
  1164. FIXES_DEFINE_STRING(OnEnterExitModShop);
  1165. FIXES_DEFINE_STRING(OnVehiclePaintjob);
  1166. FIXES_DEFINE_STRING(OnVehicleRespray);
  1167. FIXES_DEFINE_STRING(OnVehicleDamageStatusUp);
  1168. FIXES_DEFINE_STRING(OnPlayerSelectedMenuRow);
  1169. FIXES_DEFINE_STRING(OnPlayerExitedMenu);
  1170. FIXES_DEFINE_STRING(OnPlayerInteriorChange);
  1171. FIXES_DEFINE_STRING(OnPlayerKeyStateChange);
  1172. FIXES_DEFINE_STRING(OnRconLoginAttempt);
  1173. FIXES_DEFINE_STRING(OnPlayerUpdate);
  1174. FIXES_DEFINE_STRING(OnPlayerStreamIn);
  1175. FIXES_DEFINE_STRING(OnPlayerStreamOut);
  1176. FIXES_DEFINE_STRING(OnVehicleStreamIn);
  1177. FIXES_DEFINE_STRING(OnVehicleStreamOut);
  1178. FIXES_DEFINE_STRING(OnDialogResponse);
  1179. FIXES_DEFINE_STRING(OnPlayerClickPlayer);
  1180. FIXES_DEFINE_STRING(OnPlayerClickMap);
  1181. FIXES_DEFINE_STRING(OnPlayerClickTextDraw);
  1182. FIXES_DEFINE_STRING(OnPlayerClickPlayerTD);
  1183. FIXES_DEFINE_STRING(OnPlayerEditObject);
  1184. FIXES_DEFINE_STRING(OnPlayerEditAttachedObj);
  1185. FIXES_DEFINE_STRING(OnPlayerSelectObject);
  1186. FIXES_DEFINE_STRING(OnPlayerTakeDamage);
  1187. FIXES_DEFINE_STRING(OnPlayerGiveDamage);
  1188.  
  1189. #undef FIXES_DEFINE_STRING
  1190.  
  1191. /*
  1192.  * _FIXES_KEY_AIM
  1193.  * KEY_AIM
  1194.  *
  1195.  * Because the default SA:MP includes missed this one.
  1196.  */
  1197. #define _FIXES_KEY_AIM                   (128)
  1198. #if FIX_KEY_AIM
  1199.     #define KEY_AIM                      _FIXES_KEY_AIM
  1200. #endif
  1201.  
  1202. /*
  1203.  * IS_FILTERSCRIPT
  1204.  *
  1205.  * "FILTERSCRIPT" can't always be relied on to be set.  This is not a pre-
  1206.  * processor macro, but may be better than nothing (also used internally).
  1207.  */
  1208. #if FIX_FILTERSCRIPT
  1209.     #define IS_FILTERSCRIPT _FIXES_gIsFilterscript
  1210. #endif
  1211.  
  1212. /*
  1213.  * FIXES_DETECT_CALLBACK_1(callback)
  1214.  * FIXES_DETECT_CALLBACK_2(callback)
  1215.  *
  1216.  * Macro to make detecting callbacks simpler.  The number relates to which
  1217.  * variable the callback is found it.  This explicity detects the "On" part of
  1218.  * the callback because some scripts redefine the callback names and we need to
  1219.  * always correctly detect them, and always have "FIXES_On"#%0 work without
  1220.  * using the redefined name (e.g. if a prior script uses ALS).
  1221.  */
  1222. #define FIXES_DETECT_CALLBACK_1(%0On%1) (FIXES_gsCallbackHooks1|=E_FIXES_On%1*E_FIXES_CALLBACK_HOOKS_1:(funcidx(FIXES_gsc%1)!=-1))
  1223. #define FIXES_DETECT_CALLBACK_2(%0On%1) (FIXES_gsCallbackHooks2|=E_FIXES_On%1*E_FIXES_CALLBACK_HOOKS_2:(funcidx(FIXES_gsc%1)!=-1))
  1224.  
  1225. /*
  1226.  * FIXES_CALL_CALLBACK_1(callback, default, format[], ...)
  1227.  * FIXES_CALL_CALLBACK_2(callback, default, format[], ...)
  1228.  *
  1229.  * Macro to make calling callbacks simpler.  This takes the name of a callback
  1230.  * to chain - if it exists then it is called, if it doesn't exist the default
  1231.  * is returned.  Note that this DOES NOT end the current function, use in
  1232.  * conjunction with "return", or store the value to call the next element in the
  1233.  * chain before some bits of processing.
  1234.  */
  1235. #define FIXES_CALL_CALLBACK_1(%0On%1,%2,%3) ((FIXES_gsCallbackHooks1&E_FIXES_On%1)?(CallLocalFunction(FIXES_gsc%1,%3)):(%2))
  1236. #define FIXES_CALL_CALLBACK_2(%0On%1,%2,%3) ((FIXES_gsCallbackHooks2&E_FIXES_On%1)?(CallLocalFunction(FIXES_gsc%1,%3)):(%2))
  1237.  
  1238. /*
  1239.  * FIXES_DetermineOrder()
  1240.  *
  1241.  * Figure out which script is called first by callbacks.
  1242.  */
  1243. #if !FIXES_Single
  1244.     forward _FIXES_DetermineOrder();
  1245.    
  1246.     static FIXES_DetermineOrder()
  1247.     {
  1248.         deleteproperty(5, FIXES_gscOrderProperty);
  1249.         // Called in the Game Mode first (thus needs correcting).
  1250.         setproperty(5, FIXES_gscNoGMProperty, 1);
  1251.         CallRemoteFunction(FIXES_gscDetermineOrder, FIXES_gscSpec@);
  1252.         deleteproperty(5, FIXES_gscNoGMProperty);
  1253.         //if (!existproperty(5, FIXES_gscOrderProperty))
  1254.         //{
  1255.         CallRemoteFunction(FIXES_gscDetermineOrder, FIXES_gscSpec@);
  1256.         //}
  1257.     }
  1258. #endif
  1259.  
  1260. /*
  1261.  * FIXES_IsPlayerConnected(playerid)
  1262.  *
  1263.  * FIXES:
  1264.  *     IsPlayerConnected
  1265.  */
  1266. #if FIX_IsPlayerConnected
  1267.     stock FIXES_IsPlayerConnected(playerid)
  1268.     {
  1269.         if (playerid & 0xFFFF0000)
  1270.         {
  1271.             return false;
  1272.         }
  1273.         return IsPlayerConnected(playerid);
  1274.     }
  1275.    
  1276.     #if defined _ALS_IsPlayerConnected
  1277.         #undef IsPlayerConnected
  1278.     #else
  1279.        
  1280.         native BAD_IsPlayerConnected(playerid) = IsPlayerConnected;
  1281.        
  1282.         #define _ALS_IsPlayerConnected
  1283.     #endif
  1284.     #define IsPlayerConnected FIXES_IsPlayerConnected
  1285. #endif
  1286.  
  1287. /*
  1288.  * FIXES_OnScriptInit()
  1289.  *
  1290.  * Do all initialisation code in here.  Is called once when the script starts,
  1291.  * regardless of HOW the script is started (FilterScript or GameMode).  Add
  1292.  * detection of new callbacks here.
  1293.  *
  1294.  * FIXES:
  1295.  */
  1296. static FIXES_OnScriptInit()
  1297. {
  1298.     #if !FIXES_Single
  1299.         FIXES_DetermineOrder();
  1300.     #endif
  1301.     // Called in the Game Mode first.
  1302.     FIXES_DETECT_CALLBACK_1(OnGameModeInit);
  1303.     #if !FIXES_Single
  1304.         FIXES_DETECT_CALLBACK_1(OnGameModeExit);
  1305.     #endif
  1306.     FIXES_DETECT_CALLBACK_1(OnFilterScriptInit);
  1307.     #if !FIXES_Single
  1308.         FIXES_DETECT_CALLBACK_1(OnFilterScriptExit);
  1309.     #endif
  1310.     #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable || FIX_SetPlayerName || FIX_GetPlayerColor || FIX_GetPlayerSkin || FIX_IsPlayerInCheckpoint || FIX_IsPlayerInRaceCheckpoint || FIX_GetPlayerWeapon || FIX_PutPlayerInVehicle || FIX_OnPlayerEnterVehicle || FIX_AllowTeleport || FIX_OnDialogResponse || FIX_SetSpawnInfo || FIX_AllowInteriorWeapons || FIX_TrainExit || FIX_Kick
  1311.         // Not called after "loadfs" or "reloadfs" (useful for us).
  1312.         FIXES_DETECT_CALLBACK_1(OnPlayerConnect);
  1313.     #endif
  1314.     #if FIX_SetPlayerAttachedObject || FIX_IsPlayerAttachedObjSlotUsed || FIX_Kick
  1315.         // Called in the Game Mode first when the mode changes, in Filter
  1316.         // Scripts when the player leaves.
  1317.         FIXES_DETECT_CALLBACK_1(OnPlayerDisconnect);
  1318.     #endif
  1319.     #if FIX_GetPlayerSkin || FIX_TogglePlayerControllable
  1320.         FIXES_DETECT_CALLBACK_1(OnPlayerSpawn);
  1321.     #endif
  1322.     #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable || FIX_AllowInteriorWeapons || FIX_OnPlayerEnterVehicle || FIX_OnPlayerDeath
  1323.         FIXES_DETECT_CALLBACK_2(OnPlayerUpdate);
  1324.     #endif
  1325.     #if FIX_HydraSniper || FIX_GetPlayerWeapon || FIX_PutPlayerInVehicle || FIX_OnPlayerEnterVehicle || FIX_TrainExit
  1326.         FIXES_DETECT_CALLBACK_1(OnPlayerStateChange);
  1327.     #endif
  1328.     #if FIX_AllowTeleport && !defined FILTERSCRIPT
  1329.         // Called in the Game Mode first.
  1330.         FIXES_DETECT_CALLBACK_2(OnPlayerClickMap);
  1331.     #endif
  1332.     #if FIX_OnDialogResponse
  1333.         FIXES_DETECT_CALLBACK_2(OnDialogResponse);
  1334.     #endif
  1335.     #if FIX_OnPlayerDeath
  1336.         FIXES_DETECT_CALLBACK_1(OnPlayerDeath);
  1337.     #endif
  1338.     #if FIX_AllowInteriorWeapons
  1339.         FIXES_DETECT_CALLBACK_2(OnPlayerInteriorChange);
  1340.     #endif
  1341.     #if FIX_OnPlayerCommandText
  1342.         FIXES_DETECT_CALLBACK_1(OnPlayerCommandText);
  1343.     #endif
  1344. }
  1345.  
  1346. /*
  1347.  * OnFilterScriptInit()
  1348.  *
  1349.  * Set "IS_FILTERSCRIPT" to true as this callback is ONLY called if this script
  1350.  * is actually a FilterScript.  Then call "FIXES_OnScriptInit".
  1351.  *
  1352.  * FIXES:
  1353.  *     IS_FILTERSCRIPT
  1354.  */
  1355. public OnFilterScriptInit()
  1356. {
  1357.     _FIXES_gIsFilterscript = true;
  1358.     FIXES_OnScriptInit();
  1359.     #if !FIXES_Single
  1360.         FIXES_gsSettings &= ~e_FIXES_SETTINGS_DROP_ALL_DATA;
  1361.     #endif
  1362.     return FIXES_CALL_CALLBACK_1(OnFilterScriptInit, 1, FIXES_gscSpec@);
  1363. }
  1364.  
  1365. #if defined _ALS_OnFilterScriptInit
  1366.     #undef OnFilterScriptInit
  1367. #else
  1368.     #define _ALS_OnFilterScriptInit
  1369. #endif
  1370. #define OnFilterScriptInit FIXES_OnFilterScriptInit
  1371.  
  1372. forward OnFilterScriptInit();
  1373.  
  1374. /*
  1375.  * OnGameModeInit()
  1376.  *
  1377.  * Call "FIXES_OnScriptInit" if this is not a FilterScript.
  1378.  *
  1379.  * FIXES:
  1380.  *     IS_FILTERSCRIPT
  1381.  *     AllowInteriorWeapons
  1382.  *     AllowTeleport
  1383.  */
  1384. public OnGameModeInit()
  1385. {
  1386.     // =============================
  1387.     //  START: AllowInteriorWeapons
  1388.     // =============================
  1389.     #if FIX_AllowInteriorWeapons
  1390.         FIXES_gsSettings &= ~e_FIXES_SETTINGS_INTERIOR;
  1391.     #endif
  1392.     // ===========================
  1393.     //  END: AllowInteriorWeapons
  1394.     // ===========================
  1395.    
  1396.     // ======================
  1397.     //  START: AllowTeleport
  1398.     // ======================
  1399.     #if FIX_AllowTeleport && !defined FILTERSCRIPT
  1400.         FIXES_gsSettings &= ~e_FIXES_SETTINGS_ADMIN_TELEPORT;
  1401.     #endif
  1402.     // ======================
  1403.     //  END:   AllowTeleport
  1404.     // ======================
  1405.     if (!_FIXES_gIsFilterscript)
  1406.     {
  1407.         FIXES_OnScriptInit();
  1408.     }
  1409.    
  1410.     #if !FIXES_Single
  1411.         FIXES_gsSettings &= ~e_FIXES_SETTINGS_DROP_ALL_DATA;
  1412.     #endif
  1413.    
  1414.     return FIXES_CALL_CALLBACK_1(OnGameModeInit, 1, FIXES_gscSpec@);
  1415. }
  1416.  
  1417. #if defined _ALS_OnGameModeInit
  1418.     #undef OnGameModeInit
  1419. #else
  1420.     #define _ALS_OnGameModeInit
  1421. #endif
  1422. #define OnGameModeInit FIXES_OnGameModeInit
  1423.  
  1424. forward OnGameModeInit();
  1425.  
  1426. /*
  1427.  * OnGameModeExit()
  1428.  *
  1429.  * Fast way of detecting not to retain any data.
  1430.  */
  1431. #if !FIXES_Single
  1432.     public OnGameModeExit()
  1433.     {
  1434.         FIXES_gsSettings |= e_FIXES_SETTINGS_DROP_ALL_DATA;
  1435.         if (!_FIXES_gIsFilterscript && FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  1436.         {
  1437.             FIXES_gsSettings |= e_FIXES_SETTINGS_ENDING;
  1438.             FIXES_DetermineOrder();
  1439.         }
  1440.         return FIXES_CALL_CALLBACK_1(OnGameModeExit, 1, FIXES_gscSpec@);
  1441.     }
  1442.    
  1443.     #if defined _ALS_OnGameModeExit
  1444.         #undef OnGameModeExit
  1445.     #else
  1446.         #define _ALS_OnGameModeExit
  1447.     #endif
  1448.     #define OnGameModeExit FIXES_OnGameModeExit
  1449.    
  1450.     forward OnGameModeExit();
  1451. #endif
  1452.  
  1453. /*
  1454.  * OnFilterScriptExit()
  1455.  *
  1456.  * Fast way of detecting not to retain any data.
  1457.  */
  1458. #if !FIXES_Single
  1459.     public OnFilterScriptExit()
  1460.     {
  1461.         if (_FIXES_gIsFilterscript && FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  1462.         {
  1463.             FIXES_gsSettings |= e_FIXES_SETTINGS_ENDING;
  1464.             FIXES_DetermineOrder();
  1465.         }
  1466.         return FIXES_CALL_CALLBACK_1(OnFilterScriptExit, 1, FIXES_gscSpec@);
  1467.     }
  1468.    
  1469.     #if defined _ALS_OnFilterScriptExit
  1470.         #undef OnFilterScriptExit
  1471.     #else
  1472.         #define _ALS_OnFilterScriptExit
  1473.     #endif
  1474.     #define OnFilterScriptExit FIXES_OnFilterScriptExit
  1475.    
  1476.     forward OnFilterScriptExit();
  1477. #endif
  1478.  
  1479. /*
  1480.  * OnPlayerCommandText(playerid, cmdtext[])
  1481.  *
  1482.  * FIXES:
  1483.  *     OnPlayerCommandText
  1484.  */
  1485. #if FIX_OnPlayerCommandText
  1486.     public OnPlayerCommandText(playerid, cmdtext[])
  1487.     {
  1488.         // ============================
  1489.         //  START: OnPlayerCommandText
  1490.         // ============================
  1491.         #if FIX_OnPlayerCommandText
  1492.             if (cmdtext[0] == '\0' || (cmdtext[0] == '\1' && cmdtext[1] == '\0'))
  1493.             {
  1494.                 return FIXES_CALL_CALLBACK_1(OnPlayerCommandText, 1, FIXES_gscSpec@is, playerid, FIXES_gscNULL);
  1495.             }
  1496.             else
  1497.             {
  1498.                 return FIXES_CALL_CALLBACK_1(OnPlayerCommandText, 1, FIXES_gscSpec@is, playerid, cmdtext);
  1499.             }
  1500.         #endif
  1501.         // ============================
  1502.         //  START: OnPlayerCommandText
  1503.         // ============================
  1504.     }
  1505.    
  1506.     #if defined _ALS_OnPlayerCommandText
  1507.         #undef OnPlayerCommandText
  1508.     #else
  1509.         #define _ALS_OnPlayerCommandText
  1510.     #endif
  1511.     #define OnPlayerCommandText FIXES_OnPlayerCommandText
  1512.    
  1513.     forward OnPlayerCommandText(playerid, cmdtext[]);
  1514. #endif
  1515.  
  1516. /*
  1517.  * OnPlayerConnect(playerid)
  1518.  *
  1519.  * Almost every fix uses this callback for initialisation.  It is only
  1520.  * explicitly referenced for those fixes where this is all the code.
  1521.  *
  1522.  * FIXES:
  1523.  *     TogglePlayerControllable
  1524.  *     SetPlayerWorldBounds
  1525.  *     GetPlayerColor
  1526.  *     SetPlayerName
  1527.  *     GetPlayerSkin
  1528.  *     IsPlayerInCheckpoint
  1529.  *     IsPlayerInRaceCheckpoint
  1530.  *     GetPlayerWeapon
  1531.  *     PutPlayerInVehicle
  1532.  *     OnPlayerEnterVehicle
  1533.  *     AllowTeleport
  1534.  *     OnDialogResponse
  1535.  *     SetSpawnInfo
  1536.  *     AllowInteriorWeapons
  1537.  *     TrainExit
  1538.  *     Kick
  1539.  */
  1540. #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable || FIX_SetPlayerName || FIX_GetPlayerColor || FIX_GetPlayerSkin || FIX_IsPlayerInCheckpoint || FIX_IsPlayerInRaceCheckpoint || FIX_GetPlayerWeapon || FIX_PutPlayerInVehicle || FIX_OnPlayerEnterVehicle || FIX_AllowTeleport || FIX_OnDialogResponse || FIX_SetSpawnInfo || FIX_AllowInteriorWeapons || FIX_TrainExit || FIX_Kick
  1541.     public OnPlayerConnect(playerid)
  1542.     {
  1543.         FIXES_PRINTF("FIXES_OnPlayerConnect: %d", playerid);
  1544.         #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable || FIX_PutPlayerInVehicle || FIX_OnPlayerEnterVehicle || FIX_AllowTeleport || FIX_AllowInteriorWeapons || FIX_TrainExit
  1545.             // This is only reset when the Game Mode changes or when a new
  1546.             // player connects, which is what we want.  The other items are the
  1547.             // same, but must be done only once.  This variable will tend to
  1548.             // hold data relevant only in the master script (the first
  1549.             // filterscript).
  1550.             #if FIX_Kick
  1551.                 FIXES_gsPlayerBools[playerid] = e_FIXES_BOOLS_ON_PLAYER_CONNECT;
  1552.             #else
  1553.                 FIXES_gsPlayerBools[playerid] = e_FIXES_BOOLS_NONE;
  1554.             #endif
  1555.         #endif
  1556.        
  1557.         #if !FIXES_Single
  1558.             if (!GetPVarInt(playerid, FIXES_pvarNotNewPlayer))
  1559.         #endif
  1560.             {
  1561.                 FIXES_PRINTF("FIXES_OnPlayerConnect: First (%d)", FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE);
  1562.                 // ======================
  1563.                 //  START: SetPlayerName
  1564.                 // ======================
  1565.                 #if FIX_SetPlayerName
  1566.                     new
  1567.                         name[MAX_PLAYER_NAME];
  1568.                     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  1569.                     if (strcmp(name, FIXES_gscTempName) == 0)
  1570.                     {
  1571.                         Kick(playerid);
  1572.                     }
  1573.                 #endif
  1574.                 // ======================
  1575.                 //  END:   SetPlayerName
  1576.                 // ======================
  1577.                
  1578.                 // =============================
  1579.                 //  START: SetPlayerWorldBounds
  1580.                 // =============================
  1581.                 #if FIX_SetPlayerWorldBounds && !FIXES_Single
  1582.                     FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LX] =
  1583.                         FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UX] =
  1584.                             FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LY] =
  1585.                                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UY] =
  1586.                                     0.0;
  1587.                 #endif
  1588.                 // =============================
  1589.                 //  END:   SetPlayerWorldBounds
  1590.                 // =============================
  1591.                
  1592.                 // =======================
  1593.                 //  START: SetPlayerColor
  1594.                 // =======================
  1595.                 #if FIX_GetPlayerColor
  1596.                     SetPlayerColor(playerid, FIXES_gscPlayerColours[playerid % 100]);
  1597.                 #endif
  1598.                 // =======================
  1599.                 //  END:   SetPlayerColor
  1600.                 // =======================
  1601.                
  1602.                 // ======================
  1603.                 //  START: GetPlayerSkin
  1604.                 // ======================
  1605.                 #if FIX_GetPlayerSkin
  1606.                     #if FIXES_Single
  1607.                         FIXES_gsPlayerSkin[playerid] = 0;
  1608.                     #else
  1609.                         SetPVarInt(playerid, FIXES_pvarPlayerSkin, 0);
  1610.                     #endif
  1611.                 #endif
  1612.                 // ======================
  1613.                 //  END:   GetPlayerSkin
  1614.                 // ======================
  1615.                
  1616.                 // =============================
  1617.                 //  START: IsPlayerInCheckpoint
  1618.                 // =============================
  1619.                 #if FIX_IsPlayerInCheckpoint
  1620.                     DisablePlayerCheckpoint(playerid);
  1621.                 #endif
  1622.                 // =============================
  1623.                 //  END:   IsPlayerInCheckpoint
  1624.                 // =============================
  1625.                
  1626.                 // =================================
  1627.                 //  START: IsPlayerInRaceCheckpoint
  1628.                 // =================================
  1629.                 #if FIX_IsPlayerInRaceCheckpoint
  1630.                     DisablePlayerRaceCheckpoint(playerid);
  1631.                 #endif
  1632.                 // =================================
  1633.                 //  END:   IsPlayerInRaceCheckpoint
  1634.                 // =================================
  1635.                
  1636.                 // ========================
  1637.                 //  START: GetPlayerWeapon
  1638.                 // ========================
  1639.                 #if FIX_GetPlayerWeapon
  1640.                     #if FIXES_Single
  1641.                         FIXES_gsPlayerWeapon[playerid] = -1;
  1642.                     #else
  1643.                         SetPVarInt(playerid, FIXES_pvarPlayerWeapon, -1);
  1644.                     #endif
  1645.                 #endif
  1646.                 // ========================
  1647.                 //  END:   GetPlayerWeapon
  1648.                 // ========================
  1649.                
  1650.                 // =========================
  1651.                 //  START: OnDialogResponse
  1652.                 // =========================
  1653.                 #if FIX_OnDialogResponse
  1654.                     #if FIXES_Single
  1655.                         FIXES_gsDialogID[playerid] = -1;
  1656.                     #else
  1657.                         SetPVarInt(playerid, FIXES_pvarPlayerDialog, -1);
  1658.                     #endif
  1659.                 #endif
  1660.                 // =========================
  1661.                 //  END:   OnDialogResponse
  1662.                 // =========================
  1663.                
  1664.                 // =====================
  1665.                 //  START: SetSpawnInfo
  1666.                 // =====================
  1667.                 #if FIX_SetSpawnInfo
  1668.                     SetSpawnInfo(playerid, NO_TEAM, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
  1669.                 #endif
  1670.                 // =====================
  1671.                 //  END:   SetSpawnInfo
  1672.                 // =====================
  1673.                
  1674.                 #if !FIXES_Single
  1675.                     // No longer their first time.
  1676.                     SetPVarInt(playerid, FIXES_pvarNotNewPlayer, 1);
  1677.                 #endif
  1678.             }
  1679.         // =============
  1680.         //  START: Kick
  1681.         // =============
  1682.         #if FIX_Kick
  1683.             new
  1684.                 ret = FIXES_CALL_CALLBACK_1(OnPlayerConnect, 1, FIXES_gscSpec@i, playerid);
  1685.             FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_ON_PLAYER_CONNECT;
  1686.             return ret;
  1687.         #else
  1688.             return FIXES_CALL_CALLBACK_1(OnPlayerConnect, 1, FIXES_gscSpec@i, playerid);
  1689.         #endif
  1690.         // =============
  1691.         //  END:   Kick
  1692.         // =============
  1693.     }
  1694.    
  1695.     #if defined _ALS_OnPlayerConnect
  1696.         #undef OnPlayerConnect
  1697.     #else
  1698.         #define _ALS_OnPlayerConnect
  1699.     #endif
  1700.     #define OnPlayerConnect FIXES_OnPlayerConnect
  1701.    
  1702.     forward OnPlayerConnect(playerid);
  1703. #endif
  1704.  
  1705. /*
  1706.  * OnPlayerDisonnect(playerid, reason)
  1707.  *
  1708.  * FIXES:
  1709.  *     SetPlayerAttachedObject
  1710.  *     IsPlayerAttachedObjectSlotUsed
  1711.  *     Kick
  1712.  */
  1713. #if FIX_SetPlayerAttachedObject || FIX_IsPlayerAttachedObjSlotUsed || FIX_Kick
  1714.     public OnPlayerDisconnect(playerid, reason)
  1715.     {
  1716.         new
  1717.             ret = FIXES_CALL_CALLBACK_1(OnPlayerDisconnect, 1, FIXES_gscSpec@ii, playerid, reason);
  1718.        
  1719.         // ================================
  1720.         //  START: SetPlayerAttachedObject
  1721.         // ================================
  1722.         #if FIX_SetPlayerAttachedObject
  1723.             new
  1724.                 slot = playerid / _FIXES_ATTACHMENTS,
  1725.                 shift = playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS;
  1726.             if (!_FIXES_gIsFilterscript)
  1727.             {
  1728.                 for (new i = 0; i != MAX_PLAYER_ATTACHED_OBJECTS; ++i)
  1729.                 {
  1730.                     if (FIXES_gsObjectSlots[slot] & 1 << shift + i)
  1731.                     {
  1732.                         RemovePlayerAttachedObject(playerid, i);
  1733.                     }
  1734.                 }
  1735.             }
  1736.             FIXES_gsObjectSlots[slot] &= ~((1 << MAX_PLAYER_ATTACHED_OBJECTS) - 1 << shift);
  1737.         #endif
  1738.         // ================================
  1739.         //  END:   SetPlayerAttachedObject
  1740.         // ================================
  1741.        
  1742.         // =======================================
  1743.         //  START: IsPlayerAttachedObjectSlotUsed
  1744.         // =======================================
  1745.         #if FIX_IsPlayerAttachedObjSlotUsed && !FIX_SetPlayerAttachedObject
  1746.             FIXES_gsObjectSlots[playerid / _FIXES_ATTACHMENTS] &= ~((1 << MAX_PLAYER_ATTACHED_OBJECTS) - 1 << playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS);
  1747.         #endif
  1748.         // =======================================
  1749.         //  END:   IsPlayerAttachedObjectSlotUsed
  1750.         // =======================================
  1751.        
  1752.         // =============
  1753.         //  START: Kick
  1754.         // =============
  1755.         #if FIX_Kick
  1756.             if (FIXES_gsPlayerBools[playerid] & e_FIXES_BOOLS_KICKED)
  1757.             {
  1758.                 // Stop the timer if it is still running.
  1759.                 KillTimer(GetPVarInt(playerid, FIXES_pvarKick));
  1760.             }
  1761.         #endif
  1762.         // =============
  1763.         //  END:   Kick
  1764.         // =============
  1765.        
  1766.         return ret;
  1767.     }
  1768.    
  1769.     #if defined _ALS_OnPlayerDisconnect
  1770.         #undef OnPlayerDisconnect
  1771.     #else
  1772.         #define _ALS_OnPlayerDisconnect
  1773.     #endif
  1774.     #define OnPlayerDisconnect FIXES_OnPlayerDisconnect
  1775.    
  1776.     forward OnPlayerDisconnect(playerid, reason);
  1777. #endif
  1778.  
  1779. /*
  1780.  * OnPlayerDeath(playerid, killerid, reason)
  1781.  *
  1782.  * FIXES:
  1783.  *     OnPlayerDeath
  1784.  *     ZeroHP
  1785.  */
  1786. #if FIX_OnPlayerDeath || FIX_ZeroHP
  1787.     public OnPlayerDeath(playerid, killerid, reason)
  1788.     {
  1789.         #if !FIXES_Single
  1790.             if (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  1791.         #endif
  1792.             {
  1793.                 // ======================
  1794.                 //  START: OnPlayerDeath
  1795.                 // ======================
  1796.                 #if FIX_OnPlayerDeath && !FIX_ZeroHP
  1797.                     static
  1798.                         sAnimlib[32],
  1799.                         sAnimname[32];
  1800.                     GetAnimationName(FIXES_gsLastAnimation[playerid], sAnimlib, sizeof (sAnimlib), sAnimname, sizeof (sAnimname));
  1801.                     if (!strcmp(sAnimlib, "PED", true))
  1802.                     {
  1803.                 #endif
  1804.                 // ===============
  1805.                 //  START: ZeroHP
  1806.                 // ===============
  1807.                 #if FIX_OnPlayerDeath || FIX_ZeroHP
  1808.                         ClearAnimations(playerid);
  1809.                 #endif
  1810.                 #if FIX_OnPlayerDeath && !FIX_ZeroHP
  1811.                     }
  1812.                 #endif
  1813.                 // ======================
  1814.                 //  END:   OnPlayerDeath
  1815.                 // ======================
  1816.                
  1817.                 #if FIX_ZeroHP
  1818.                     SetPlayerHealth(playerid, -1.0);
  1819.                 #endif
  1820.                 // ===============
  1821.                 //  END:   ZeroHP
  1822.                 // ===============
  1823.             }
  1824.         return FIXES_CALL_CALLBACK_1(OnPlayerDeath, 1, FIXES_gscSpec@iii, playerid, killerid, reason);
  1825.     }
  1826.    
  1827.     #if defined _ALS_OnPlayerDeath
  1828.         #undef OnPlayerDeath
  1829.     #else
  1830.         #define _ALS_OnPlayerDeath
  1831.     #endif
  1832.     #define OnPlayerDeath FIXES_OnPlayerDeath
  1833.    
  1834.     forward OnPlayerDeath(playerid, killerid, reason);
  1835. #endif
  1836.  
  1837. /*
  1838.  * FIXES_SpawnPlayer(playerid)
  1839.  *
  1840.  * FIXES:
  1841.  *     SpawnPlayer
  1842.  */
  1843. #if FIX_SpawnPlayer
  1844.     stock FIXES_SpawnPlayer(playerid)
  1845.     {
  1846.         // Valid "playerid" check inside "GetPlayerVehicleID".
  1847.         new
  1848.             vid = GetPlayerVehicleID(playerid);
  1849.         if (vid)
  1850.         {
  1851.             new
  1852.                 Float:x,
  1853.                 Float:y,
  1854.                 Float:z;
  1855.             // Remove them without the animation.
  1856.             GetVehiclePos(vid, x, y, z);
  1857.             SetPlayerPos(playerid, x, y, z);
  1858.         }
  1859.         return SpawnPlayer(playerid);
  1860.     }
  1861.    
  1862.     #if defined _ALS_SpawnPlayer
  1863.         #undef SpawnPlayer
  1864.     #else
  1865.        
  1866.         native BAD_SpawnPlayer(playerid) = SpawnPlayer;
  1867.        
  1868.         #define _ALS_SpawnPlayer
  1869.     #endif
  1870.     #define SpawnPlayer FIXES_SpawnPlayer
  1871. #endif
  1872.  
  1873. /*
  1874.  * FIXES_SetPlayerName(playerid, name[])
  1875.  *
  1876.  * FIXES:
  1877.  *     SetPlayerName
  1878.  */
  1879. #if FIX_SetPlayerName
  1880.     stock FIXES_SetPlayerName(playerid, name[])
  1881.     {
  1882.         if (strcmp(name, FIXES_gscTempName) == 0)
  1883.         {
  1884.             return 0;
  1885.         }
  1886.         static
  1887.             sOldName[MAX_PLAYER_NAME];
  1888.         GetPlayerName(playerid, sOldName, sizeof (sOldName));
  1889.         if (strcmp(name, sOldName, true) == 0)
  1890.         {
  1891.             return 0;
  1892.         }
  1893.         SetPlayerName(playerid, FIXES_gscTempName);
  1894.         new
  1895.             retval = SetPlayerName(playerid, name);
  1896.         if (retval != 1)
  1897.         {
  1898.             SetPlayerName(playerid, sOldName);
  1899.         }
  1900.         return retval;
  1901.     }
  1902.     #if defined _ALS_SetPlayerName
  1903.         #undef SetPlayerName
  1904.     #else
  1905.        
  1906.         native BAD_SetPlayerName(playerid, const name[]) = SetPlayerName;
  1907.        
  1908.         #define _ALS_SetPlayerName
  1909.     #endif
  1910.     #define SetPlayerName FIXES_SetPlayerName
  1911. #endif
  1912.  
  1913. /*
  1914.  * OnPlayerSpawn(playerid)
  1915.  *
  1916.  * FIXES:
  1917.  *     GetPlayerSkin
  1918.  *     TogglePlayerControllable
  1919.  */
  1920. #if FIX_GetPlayerSkin || FIX_TogglePlayerControllable
  1921.     public OnPlayerSpawn(playerid)
  1922.     {
  1923.         // ======================
  1924.         //  START: GetPlayerSkin
  1925.         // ======================
  1926.         #if FIX_GetPlayerSkin
  1927.             #if FIXES_Single
  1928.                 FIXES_gsPlayerSkin[playerid] = GetPlayerSkin(playerid);
  1929.             #else
  1930.                 SetPVarInt(playerid, FIXES_pvarPlayerSkin, GetPlayerSkin(playerid));
  1931.             #endif
  1932.         #endif
  1933.         // ======================
  1934.         //  END:   GetPlayerSkin
  1935.         // ======================
  1936.        
  1937.         // =================================
  1938.         //  START: TogglePlayerControllable
  1939.         // =================================
  1940.         #if FIX_TogglePlayerControllable
  1941.             FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_UNCONTROLLABLE;
  1942.         #endif
  1943.         // =================================
  1944.         //  END:   TogglePlayerControllable
  1945.         // =================================
  1946.        
  1947.         return FIXES_CALL_CALLBACK_1(OnPlayerSpawn, 1, FIXES_gscSpec@i, playerid);
  1948.     }
  1949.    
  1950.     #if defined _ALS_OnPlayerSpawn
  1951.         #undef OnPlayerSpawn
  1952.     #else
  1953.         #define _ALS_OnPlayerSpawn
  1954.     #endif
  1955.     #define OnPlayerSpawn FIXES_OnPlayerSpawn
  1956.    
  1957.     forward OnPlayerSpawn(playerid);
  1958. #endif
  1959.  
  1960. /*
  1961.  * FIXES_SetPlayerSkin(playerid, skinid)
  1962.  *
  1963.  * FIXES:
  1964.  *     GetPlayerSkin
  1965.  *     SetPlayerSkin
  1966.  */
  1967. #if FIX_GetPlayerSkin || FIX_SetPlayerSkin
  1968.     stock FIXES_SetPlayerSkin(playerid, skinid)
  1969.     {
  1970.         // ======================
  1971.         //  START: SetPlayerSkin
  1972.         // ======================
  1973.         #if FIX_SetPlayerSkin
  1974.             new
  1975.                 vehicleid = GetPlayerVehicleID(playerid);
  1976.             if (vehicleid)
  1977.             {
  1978.                 new
  1979.                     seat = GetPlayerVehicleSeat(playerid);
  1980.                 ClearAnimations(playerid);
  1981.                 new
  1982.                     ret = SetPlayerSkin(playerid, skinid);
  1983.                 PutPlayerInVehicle(playerid, vehicleid, seat);
  1984.                
  1985.                 // ======================
  1986.                 //  START: GetPlayerSkin
  1987.                 // ======================
  1988.                 #if FIX_GetPlayerSkin
  1989.                     #if FIXES_Single
  1990.                         FIXES_gsPlayerSkin[playerid] = skinid;
  1991.                     #else
  1992.                         SetPVarInt(playerid, FIXES_pvarPlayerSkin, skinid);
  1993.                     #endif
  1994.                 #endif
  1995.                 // ======================
  1996.                 //  END:   GetPlayerSkin
  1997.                 // ======================
  1998.                
  1999.                 return ret;
  2000.             }
  2001.            
  2002.             // ======================
  2003.             //  START: GetPlayerSkin
  2004.             // ======================
  2005.             #if FIX_GetPlayerSkin
  2006.                 else
  2007.             #endif
  2008.             // ======================
  2009.             //  END:   GetPlayerSkin
  2010.             // ======================
  2011.         #endif
  2012.         // ======================
  2013.         //  END:   SetPlayerSkin
  2014.         // ======================
  2015.        
  2016.         // ======================
  2017.         //  START: GetPlayerSkin
  2018.         // ======================
  2019.         #if FIX_GetPlayerSkin
  2020.             #if FIXES_Single
  2021.                 FIXES_gsPlayerSkin[playerid] = skinid;
  2022.             #else
  2023.                 SetPVarInt(playerid, FIXES_pvarPlayerSkin, skinid);
  2024.             #endif
  2025.         #endif
  2026.         // ======================
  2027.         //  END:   GetPlayerSkin
  2028.         // ======================
  2029.        
  2030.         return SetPlayerSkin(playerid, skinid);
  2031.     }
  2032.    
  2033.     #if defined _ALS_SetPlayerSkin
  2034.         #undef SetPlayerSkin
  2035.     #else
  2036.        
  2037.         native BAD_SetPlayerSkin(playerid, skinid) = SetPlayerSkin;
  2038.        
  2039.         #define _ALS_SetPlayerSkin
  2040.     #endif
  2041.     #define SetPlayerSkin FIXES_SetPlayerSkin
  2042. #endif
  2043.  
  2044. /*
  2045.  * FIXES_GetPlayerSkin(playerid, skinid)
  2046.  *
  2047.  * FIXES:
  2048.  *     GetPlayerSkin
  2049.  */
  2050. #if FIX_GetPlayerSkin
  2051.     stock FIXES_GetPlayerSkin(playerid)
  2052.     {
  2053.         #if FIXES_Single
  2054.             return FIXES_gsPlayerSkin[playerid];
  2055.         #else
  2056.             return GetPVarInt(playerid, FIXES_pvarPlayerSkin);
  2057.         #endif
  2058.     }
  2059.    
  2060.     #if defined _ALS_GetPlayerSkin
  2061.         #undef GetPlayerSkin
  2062.     #else
  2063.        
  2064.         native BAD_GetPlayerSkin(playerid) = GetPlayerSkin;
  2065.        
  2066.         #define _ALS_GetPlayerSkin
  2067.     #endif
  2068.     #define GetPlayerSkin FIXES_GetPlayerSkin
  2069. #endif
  2070.  
  2071. /*
  2072.  * FIXES_GetWeaponName(weaponid, weapon[], len)
  2073.  *
  2074.  * FIXES:
  2075.  *     GetWeaponName
  2076.  */
  2077. #if FIX_GetWeaponName
  2078.     stock FIXES_GetWeaponName(weaponid, weapon[], len)
  2079.     {
  2080.         switch (weaponid)
  2081.         {
  2082.             case 18:
  2083.             {
  2084.                 weapon[0] = 0;
  2085.                 strcat(weapon, "Molotov Cocktail", len);
  2086.                 return 1;
  2087.             }
  2088.             case 44:
  2089.             {
  2090.                 weapon[0] = 0;
  2091.                 strcat(weapon, "Thermal Goggles", len);
  2092.                 return 1;
  2093.             }
  2094.             case 45:
  2095.             {
  2096.                 weapon[0] = 0;
  2097.                 strcat(weapon, "Night Vision Goggles", len);
  2098.                 return 1;
  2099.             }
  2100.             default:
  2101.             {
  2102.                 return GetWeaponName(weaponid, weapon, len);
  2103.             }
  2104.         }
  2105.         return 0;
  2106.     }
  2107.    
  2108.     #if defined _ALS_GetWeaponName
  2109.         #undef GetWeaponName
  2110.     #else
  2111.        
  2112.         native BAD_GetWeaponName(weaponid, weapon[], len) = GetWeaponName;
  2113.        
  2114.         #define _ALS_GetWeaponName
  2115.     #endif
  2116.     #define GetWeaponName FIXES_GetWeaponName
  2117. #endif
  2118.  
  2119. /*
  2120.  * OnPlayerUpdate(playerid)
  2121.  *
  2122.  * FIXES:
  2123.  *     SetPlayerWorldBounds
  2124.  *     TogglePlayerControllable
  2125.  *     AllowInteriorWeapons
  2126.  *     OnPlayerDeath
  2127.  *     Kick
  2128.  */
  2129. #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable || FIX_AllowInteriorWeapons || FIX_OnPlayerEnterVehicle || FIX_OnPlayerDeath || FIX_Kick
  2130.     public OnPlayerUpdate(playerid)
  2131.     {
  2132.         #if !FIXES_Single
  2133.             if (!(FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE))
  2134.             {
  2135.                 return FIXES_CALL_CALLBACK_2(OnPlayerUpdate, 1, FIXES_gscSpec@i, playerid);
  2136.             }
  2137.         #endif
  2138.        
  2139.         #if FIX_OnPlayerEnterVehicle || FIX_AllowInteriorWeapons || FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable
  2140.             new
  2141.                 e_FIXES_BOOLS:pbools = FIXES_gsPlayerBools[playerid];
  2142.         #endif
  2143.        
  2144.         // =============================
  2145.         //  BEGIN: OnPlayerEnterVehicle
  2146.         // =============================
  2147.         #if FIX_OnPlayerEnterVehicle || FIX_Kick
  2148.             if (pbools & e_FIXES_BOOLS_BLOCK)
  2149.             {
  2150.                 return 0;
  2151.             }
  2152.         #endif
  2153.         // =============================
  2154.         //  END:   OnPlayerEnterVehicle
  2155.         // =============================
  2156.        
  2157.         // =============================
  2158.         //  START: AllowInteriorWeapons
  2159.         // =============================
  2160.         #if FIX_AllowInteriorWeapons
  2161.             //if (FIXES_gsSettings & e_FIXES_SETTINGS_INTERIOR && GetPlayerInterior(playerid) && GetPlayerWeapon(playerid))
  2162.             if (pbools & e_FIXES_BOOLS_INTERIOR)
  2163.             {
  2164.                 // DONE: May need integration with "FIX_GetPlayerWeapon".
  2165.                 SetPlayerArmedWeapon(playerid, 0);
  2166.             }
  2167.         #endif
  2168.         // ============================
  2169.         //  END: AllowInteriorWeapons
  2170.         // ============================
  2171.        
  2172.         #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable
  2173.             new
  2174.                 ud,
  2175.                 lr,
  2176.                 keys;
  2177.             GetPlayerKeys(playerid, keys, ud, lr);
  2178.         #endif
  2179.        
  2180.         #if FIX_SetPlayerWorldBounds && !FIX_TogglePlayerControllable
  2181.             #pragma unused ud, lr
  2182.         #endif
  2183.        
  2184.         // =============================
  2185.         //  START: SetPlayerWorldBounds
  2186.         // =============================
  2187.         #if FIX_SetPlayerWorldBounds
  2188.             if (pbools & e_FIXES_BOOLS_WORLDBOUNDS && keys & _FIXES_KEY_AIM)
  2189.             {
  2190.                 new
  2191.                     Float:x,
  2192.                     Float:y,
  2193.                     Float:z;
  2194.                 GetPlayerPos(playerid, x, y, z);
  2195.                 if (FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LX] < x < FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UX] && FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LY] < y < FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UY])
  2196.                 {
  2197.                     FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PX] = x;
  2198.                     FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PY] = y;
  2199.                     FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PZ] = z;
  2200.                 }
  2201.                 else
  2202.                 {
  2203.                     SetPlayerPos(playerid, FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PX], FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PY], FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PZ]);
  2204.                 }
  2205.             }
  2206.         #endif
  2207.         // =============================
  2208.         //  END:   SetPlayerWorldBounds
  2209.         // =============================
  2210.        
  2211.         // ======================
  2212.         //  START: OnPlayerDeath
  2213.         // ======================
  2214.         #if FIX_OnPlayerDeath
  2215.             FIXES_gsLastAnimation[playerid] = GetPlayerAnimationIndex(playerid);
  2216.         #endif
  2217.         // ======================
  2218.         //  END:   OnPlayerDeath
  2219.         // ======================
  2220.        
  2221.         // =================================
  2222.         //  START: TogglePlayerControllable
  2223.         // =================================
  2224.         #if FIX_TogglePlayerControllable
  2225.             // MUST come last.
  2226.             if (pbools & e_FIXES_BOOLS_UNCONTROLLABLE)
  2227.             {
  2228.                 // Keys based sync blocking, modified based on a post by Slice:
  2229.                 // http://forum.sa-mp.com/showpost.php?p=876854&postcount=1
  2230.                 // Use "playerid" here as it's a variable that already exists,
  2231.                 // but note that after this point, you CANNOT use "playerid" as
  2232.                 // it has been "clobbered" (and yes, that's the technical term).
  2233.                 // This is just to avoid "statement has no effect" warnings.
  2234.                 // ALWAYS return 0 in this case, regardless of what other
  2235.                 // callbacks return.
  2236.                 playerid = FIXES_CALL_CALLBACK_2(OnPlayerUpdate, 1, FIXES_gscSpec@i, playerid);
  2237.                 if (keys || ud || lr)
  2238.                 {
  2239.                     return 0;
  2240.                 }
  2241.                 else
  2242.                 {
  2243.                     return playerid;
  2244.                 }
  2245.             }
  2246.         #endif
  2247.         // =================================
  2248.         //  END:   TogglePlayerControllable
  2249.         // =================================
  2250.        
  2251.         return FIXES_CALL_CALLBACK_2(OnPlayerUpdate, 1, FIXES_gscSpec@i, playerid);
  2252.     }
  2253.    
  2254.     #if defined _ALS_OnPlayerUpdate
  2255.         #undef OnPlayerUpdate
  2256.     #else
  2257.         #define _ALS_OnPlayerUpdate
  2258.     #endif
  2259.     #define OnPlayerUpdate FIXES_OnPlayerUpdate
  2260.    
  2261.     forward OnPlayerUpdate(playerid);
  2262. #endif
  2263.  
  2264. /*
  2265.  * FIXES_SetPlayerWorldBounds(playerid, Float:x_max, Float:x_min, Float:y_max, Float:y_min)
  2266.  *
  2267.  * TODO: Modify this to remove aim animations when they get to the boundaries.
  2268.  *
  2269.  * FIXES:
  2270.  *     SetPlayerWorldBounds
  2271.  */
  2272. #if FIX_SetPlayerWorldBounds
  2273.     #if FIXES_Single
  2274.         stock FIXES_SetPlayerWorldBounds(playerid, Float:x_max, Float:x_min, Float:y_max, Float:y_min)
  2275.         {
  2276.             if (0 <= playerid < MAX_PLAYERS)
  2277.             {
  2278.                 FIXES_PRINTF("Call SetPlayerWorldBounds");
  2279.                 if (x_max == x_min || y_max == y_min)
  2280.                 {
  2281.                     // Impossibly small area, disable checks entirely.
  2282.                     FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_WORLDBOUNDS;
  2283.                     return SetPlayerWorldBounds(playerid, _FIXES_INFINITY, _FIXES_N_INFINITY, _FIXES_INFINITY, _FIXES_N_INFINITY);
  2284.                 }
  2285.                 // This code could do with a way to mostly remove the checks.  Maybe
  2286.                 // when setting everything to FIXES_INFINITY (with default
  2287.                 // parameters).
  2288.                 FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_WORLDBOUNDS;
  2289.                 new
  2290.                     Float:tmp;
  2291.                 if (x_max < x_min)
  2292.                 {
  2293.                     tmp = x_min;
  2294.                     x_min = x_max;
  2295.                     x_max = tmp;
  2296.                 }
  2297.                 if (y_max < y_min)
  2298.                 {
  2299.                     tmp = y_min;
  2300.                     y_min = y_max;
  2301.                     y_max = tmp;
  2302.                 }
  2303.                 // Give a little leway so this fix isn't noticed if you're not
  2304.                 // trying to break through the world bounds.  Leway removed in
  2305.                 // favour of keys.
  2306.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LX] = x_min;
  2307.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UX] = x_max;
  2308.                
  2309.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LY] = y_min;
  2310.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UY] = y_max;
  2311.                
  2312.                 GetPlayerPos(playerid, tmp, tmp, tmp);
  2313.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PX] = (x_max - x_min) / 2 + x_min;
  2314.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PY] = (y_max - y_min) / 2 + y_min;
  2315.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PZ] = tmp;
  2316.                
  2317.                 return SetPlayerWorldBounds(playerid, x_max, x_min, y_max, y_min);
  2318.             }
  2319.             return 0;
  2320.         }
  2321.     #else
  2322.         forward _FIXES_SetPlayerWorldBounds(playerid, Float:x_max, Float:x_min, Float:y_max, Float:y_min);
  2323.        
  2324.         stock FIXES_SetPlayerWorldBounds(playerid, Float:x_max, Float:x_min, Float:y_max, Float:y_min)
  2325.         {
  2326.             if (0 <= playerid < MAX_PLAYERS)
  2327.             {
  2328.                 FIXES_PRINTF("Call SetPlayerWorldBounds");
  2329.                 CallRemoteFunction(FIXES_gscSetPlayerWorldBounds, FIXES_gscSpec@iffff, playerid, x_max, x_min, y_max, y_min);
  2330.                 return getproperty(5, FIXES_gscReturnProperty);
  2331.             }
  2332.             return 0;
  2333.         }
  2334.        
  2335.         public _FIXES_SetPlayerWorldBounds(playerid, Float:x_max, Float:x_min, Float:y_max, Float:y_min)
  2336.         {
  2337.             FIXES_PRINTF("_FIXES_SetPlayerWorldBounds: %d %.2f %.2f %.2f %.2f", playerid, x_max, x_min, y_max, y_min);
  2338.             if (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  2339.             {
  2340.                 FIXES_PRINTF("SetPlayerWorldBounds");
  2341.                 //if (x_max == _FIXES_INFINITY && x_min == _FIXES_INFINITY && y_max == _FIXES_INFINITY && y_min == _FIXES_INFINITY)
  2342.                 if (x_max == x_min || y_max == y_min)
  2343.                 {
  2344.                     // Impossibly small area, disable checks entirely.
  2345.                     FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_WORLDBOUNDS;
  2346.                     FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LX] =
  2347.                         FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UX] =
  2348.                             FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LY] =
  2349.                                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UY] =
  2350.                                     0.0;
  2351.                     setproperty(5, FIXES_gscReturnProperty, SetPlayerWorldBounds(playerid, _FIXES_INFINITY, _FIXES_N_INFINITY, _FIXES_INFINITY, _FIXES_N_INFINITY));
  2352.                     return -1;
  2353.                 }
  2354.                 // This code could do with a way to mostly remove the checks.  Maybe
  2355.                 // when setting everything to FIXES_INFINITY (with default
  2356.                 // parameters).
  2357.                 FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_WORLDBOUNDS;
  2358.                 new
  2359.                     Float:tmp;
  2360.                 if (x_max < x_min)
  2361.                 {
  2362.                     tmp = x_min;
  2363.                     x_min = x_max;
  2364.                     x_max = tmp;
  2365.                 }
  2366.                 if (y_max < y_min)
  2367.                 {
  2368.                     tmp = y_min;
  2369.                     y_min = y_max;
  2370.                     y_max = tmp;
  2371.                 }
  2372.                 // Give a little leway so this fix isn't noticed if you're not
  2373.                 // trying to break through the world bounds.  Leway removed in
  2374.                 // favour of keys.
  2375.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LX] = x_min;
  2376.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UX] = x_max;
  2377.                
  2378.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_LY] = y_min;
  2379.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_UY] = y_max;
  2380.                
  2381.                 GetPlayerPos(playerid, tmp, tmp, tmp);
  2382.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PX] = (x_max - x_min) / 2 + x_min;
  2383.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PY] = (y_max - y_min) / 2 + y_min;
  2384.                 FIXES_gsWorldbounds[playerid][E_FIXES_WORLDBOUND_DATA_PZ] = tmp;
  2385.                
  2386.                 setproperty(5, FIXES_gscReturnProperty, SetPlayerWorldBounds(playerid, x_max, x_min, y_max, y_min));
  2387.             }
  2388.             return 0;
  2389.         }
  2390.     #endif
  2391.    
  2392.     #if defined _ALS_SetPlayerWorldBounds
  2393.         #undef SetPlayerWorldBounds
  2394.     #else
  2395.        
  2396.         native BAD_SetPlayerWorldBounds(playerid, Float:x_max, Float:x_min, Float:y_max, Float:y_min) = SetPlayerWorldBounds;
  2397.        
  2398.         #define _ALS_SetPlayerWorldBounds
  2399.     #endif
  2400.     #define SetPlayerWorldBounds FIXES_SetPlayerWorldBounds
  2401. #endif
  2402.  
  2403. /*
  2404.  * FIXES_TogglePlayerControllable(playerid, toggle)
  2405.  *
  2406.  * FIXES:
  2407.  *     TogglePlayerControllable
  2408.  */
  2409. #if FIX_TogglePlayerControllable
  2410.     #if FIXES_Single
  2411.         stock FIXES_TogglePlayerControllable(playerid, toggle)
  2412.         {
  2413.             if (TogglePlayerControllable(playerid, toggle))
  2414.             {
  2415.                 if (toggle)
  2416.                 {
  2417.                     FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_UNCONTROLLABLE;
  2418.                 }
  2419.                 else
  2420.                 {
  2421.                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_UNCONTROLLABLE;
  2422.                 }
  2423.                 return 1;
  2424.             }
  2425.             return 0;
  2426.         }
  2427.     #else
  2428.         forward _FIXES_TogglePlayerControllable(playerid, toggle);
  2429.        
  2430.         stock FIXES_TogglePlayerControllable(playerid, toggle)
  2431.         {
  2432.             if (0 <= playerid < MAX_PLAYERS)
  2433.             {
  2434.                 CallRemoteFunction(FIXES_gscTogglePlayerControl, FIXES_gscSpec@ii, playerid, toggle);
  2435.                 return getproperty(5, FIXES_gscReturnProperty);
  2436.             }
  2437.             return 0;
  2438.         }
  2439.        
  2440.         public _FIXES_TogglePlayerControllable(playerid, toggle)
  2441.         {
  2442.             if (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  2443.             {
  2444.                 if (toggle)
  2445.                 {
  2446.                     FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_UNCONTROLLABLE;
  2447.                 }
  2448.                 else
  2449.                 {
  2450.                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_UNCONTROLLABLE;
  2451.                 }
  2452.                 setproperty(5, FIXES_gscReturnProperty, TogglePlayerControllable(playerid, toggle));
  2453.             }
  2454.         }
  2455.     #endif
  2456.    
  2457.     #if defined _ALS_TogglePlayerControllable
  2458.         #undef TogglePlayerControllable
  2459.     #else
  2460.        
  2461.         native BAD_TogglePlayerControllable(playerid, toggle) = TogglePlayerControllable;
  2462.        
  2463.         #define _ALS_TogglePlayerControllable
  2464.     #endif
  2465.     #define TogglePlayerControllable FIXES_TogglePlayerControllable
  2466. #endif
  2467.  
  2468. #if FIX_AllowInteriorWeapons
  2469.     public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  2470.     {
  2471.         // =============================
  2472.         //  BEGIN: AllowInteriorWeapons
  2473.         // =============================
  2474.         #if FIX_AllowInteriorWeapons
  2475.             if (newinteriorid)
  2476.             {
  2477.                 if (FIXES_gsSettings & e_FIXES_SETTINGS_INTERIOR)
  2478.                 {
  2479.                     // This only needs doing here if "GetPlayerWeapon" is set.
  2480.                     // If it isn't, even though "AllowInteriorWeapons" can use
  2481.                     // this code on its own, it doesn't as "OnPlayerUpdate"
  2482.                     // takes care of it all.
  2483.                     // TODO: Rewrite this code to use a single bit to indicate
  2484.                     // if a player can have a weapon or not, and just use the in
  2485.                     // the "OnPlayerUpdate" callback, instead of several checks.
  2486.                     // DONE!
  2487.                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_INTERIOR;
  2488.                     #if !FIXES_Single
  2489.                         if (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  2490.                     #endif
  2491.                         {
  2492.                             SetPlayerArmedWeapon(playerid, 0);
  2493.                             #if FIX_GetPlayerWeapon
  2494.                                 if (IsPlayerInAnyVehicle(playerid))
  2495.                                 {
  2496.                                     #if FIXES_Single
  2497.                                         FIXES_gsPlayerWeapon[playerid] = 0;
  2498.                                     #else
  2499.                                         SetPVarInt(playerid, FIXES_pvarPlayerWeapon, 0);
  2500.                                     #endif
  2501.                                 }
  2502.                             #endif
  2503.                         }
  2504.                 }
  2505.             }
  2506.             else
  2507.             {
  2508.                 FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_INTERIOR;
  2509.             }
  2510.         #endif
  2511.         // ===========================
  2512.         //  END: AllowInteriorWeapons
  2513.         // ===========================
  2514.         return FIXES_CALL_CALLBACK_2(OnPlayerInteriorChange, 1, FIXES_gscSpec@iii, playerid, newinteriorid, oldinteriorid);
  2515.     }
  2516.    
  2517.     #if defined _ALS_OnPlayerInteriorChange
  2518.         #undef OnPlayerInteriorChange
  2519.     #else
  2520.         #define _ALS_OnPlayerInteriorChange
  2521.     #endif
  2522.     #define OnPlayerInteriorChange FIXES_OnPlayerInteriorChange
  2523.    
  2524.     forward OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid);
  2525. #endif
  2526.  
  2527. /*
  2528.  * FIXES_BlockUpdate(playerid, bool:block)
  2529.  *
  2530.  * Block a player from using OnPlayerUpdate at all.
  2531.  */
  2532. #if FIX_OnPlayerEnterVehicle || FIX_Kick
  2533.     static stock FIXES_BlockUpdate(playerid, bool:block)
  2534.     {
  2535.         if (block)
  2536.         {
  2537.             FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_BLOCK;
  2538.             return 0;
  2539.         }
  2540.         else
  2541.         {
  2542.             FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_BLOCK;
  2543.             return 1;
  2544.         }
  2545.     }
  2546. #endif
  2547.  
  2548. /*
  2549.  * OnPlayerStateChange(playerid, newstate, oldstate)
  2550.  *
  2551.  * FIXES:
  2552.  *     HydraSniper
  2553.  *     GetPlayerWeapon
  2554.  *     PutPlayerInVehicle
  2555.  *     TrainExit
  2556.  */
  2557. #if FIX_HydraSniper || FIX_GetPlayerWeapon || FIX_PutPlayerInVehicle || FIX_OnPlayerEnterVehicle || FIX_TrainExit
  2558.     public OnPlayerStateChange(playerid, newstate, oldstate)
  2559.     {
  2560.         #if !FIXES_Single
  2561.             if (!(FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE))
  2562.             {
  2563.                 return FIXES_CALL_CALLBACK_1(OnPlayerStateChange, 1, FIXES_gscSpec@iii, playerid, newstate, oldstate);
  2564.             }
  2565.         #endif
  2566.        
  2567.         // =============================
  2568.         //  BEGIN: OnPlayerEnterVehicle
  2569.         // =============================
  2570.         #if FIX_OnPlayerEnterVehicle
  2571.                 if (newstate == PLAYER_STATE_PASSENGER)
  2572.                 {
  2573.                     new
  2574.                         model = GetVehicleModel(GetPlayerVehicleID(playerid)) - 400;
  2575.                     if (0 <= model <= 211)
  2576.                     {
  2577.                         new
  2578.                             seat = GetPlayerVehicleSeat(playerid);
  2579.                         if (seat != 128)
  2580.                         {
  2581.                             model = (FIXES_gscMaxPassengers[model >>> 3] >>> ((model & 7) << 2)) & 0xF;
  2582.                             if (model == 0 || model == 15)
  2583.                             {
  2584.                                 // Shouldn't be in this vehicle at all.
  2585.                                 FIXES_BlockUpdate(playerid, true);
  2586.                                 Kick(playerid);
  2587.                             }
  2588.                             else if (!(0 < seat <= model))
  2589.                             {
  2590.                                 // In an out of range seat.
  2591.                                 FIXES_BlockUpdate(playerid, true);
  2592.                                 Kick(playerid);
  2593.                             }
  2594.                         }
  2595.                     }
  2596.                     else
  2597.                     {
  2598.                         FIXES_BlockUpdate(playerid, true);
  2599.                         Kick(playerid);
  2600.                     }
  2601.                 }
  2602.                 else if (newstate == PLAYER_STATE_DRIVER)
  2603.                 {
  2604.                         new
  2605.                             model = GetPlayerVehicleSeat(playerid);
  2606.                         if (model != 128)
  2607.                         {
  2608.                             if (model == 0)
  2609.                             {
  2610.                                 model = GetVehicleModel(GetPlayerVehicleID(playerid)) - 400;
  2611.                                 if (!(0 <= model <= 211) || FIXES_gscMaxPassengers[model >>> 3] >>> ((model & 7) << 2) & 0xF == 15)
  2612.                                 {
  2613.                                     // In an invalid vehicle (one you can't drive).
  2614.                                     FIXES_BlockUpdate(playerid, true);
  2615.                                     Kick(playerid);
  2616.                                 }
  2617.                             }
  2618.                             else
  2619.                             {
  2620.                                 // They are a driver, but not in the driver's seat.
  2621.                                 FIXES_BlockUpdate(playerid, true);
  2622.                                 Kick(playerid);
  2623.                             }
  2624.                         }
  2625.                     #if FIX_HydraSniper
  2626.                         else
  2627.                         {
  2628.                             model = GetVehicleModel(GetPlayerVehicleID(playerid));
  2629.                         }
  2630.                     #endif
  2631.             #if !FIX_HydraSniper
  2632.                 }
  2633.             #endif
  2634.         #endif
  2635.         // =============================
  2636.         //  END:   OnPlayerEnterVehicle
  2637.         // =============================
  2638.        
  2639.         // ====================
  2640.         //  BEGIN: HydraSniper
  2641.         // ====================
  2642.         #if FIX_HydraSniper
  2643.             #if !FIX_OnPlayerEnterVehicle
  2644.                 // Only called if the same check above isn't called.
  2645.                 if (newstate == PLAYER_STATE_DRIVER)
  2646.                 {
  2647.                     new
  2648.                         model = GetVehicleModel(GetPlayerVehicleID(playerid));
  2649.             #endif
  2650.                     if (GetPlayerWeapon(playerid) == 34 && (model == 520 || model == 425))
  2651.                     {
  2652.                         SetPlayerArmedWeapon(playerid, 0);
  2653.                         #if FIX_GetPlayerWeapon
  2654.                             // This is the first cross-dependednt fix.
  2655.                             #if FIXES_Single
  2656.                                 FIXES_gsPlayerWeapon[playerid] = 0;
  2657.                             #else
  2658.                                 SetPVarInt(playerid, FIXES_pvarPlayerWeapon, 0);
  2659.                             #endif
  2660.                         #endif
  2661.                     }
  2662.                 }
  2663.         #endif
  2664.         // ====================
  2665.         //  END:   HydraSniper
  2666.         // ====================
  2667.        
  2668.         #if FIX_GetPlayerWeapon || FIX_PutPlayerInVehicle || FIX_TrainExit
  2669.             #if PLAYER_STATE_PASSENGER != PLAYER_STATE_DRIVER + 1
  2670.                 #error FIX_GetPlayerWeapon/FIX_PutPlayerInVehicle state assertation failed.
  2671.             #endif
  2672.             if (PLAYER_STATE_DRIVER <= oldstate <= PLAYER_STATE_PASSENGER)
  2673.             //if (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
  2674.             {
  2675.                 #if FIX_PutPlayerInVehicle || FIX_TrainExit
  2676.                     new
  2677.                         e_FIXES_BOOLS:bools = FIXES_gsPlayerBools[playerid];
  2678.                 #endif
  2679.                
  2680.                 // ========================
  2681.                 //  BEGIN: GetPlayerWeapon
  2682.                 // ========================
  2683.                 #if FIX_GetPlayerWeapon
  2684.                     #if FIXES_Single
  2685.                         FIXES_gsPlayerWeapon[playerid] = -1;
  2686.                     #else
  2687.                         SetPVarInt(playerid, FIXES_pvarPlayerWeapon, -1);
  2688.                     #endif
  2689.                 #endif
  2690.                 // ========================
  2691.                 //  END:   GetPlayerWeapon
  2692.                 // ========================
  2693.                
  2694.                 // ==================
  2695.                 //  BEGIN: TrainExit
  2696.                 // ==================
  2697.                 #if FIX_TrainExit
  2698.                     FIXES_PRINTF("train exit");
  2699.                     if (bools & e_FIXES_BOOLS_PUT_IN_TRAIN)
  2700.                     {
  2701.                         FIXES_PRINTF("OK");
  2702.                         SetCameraBehindPlayer(playerid);
  2703.                         bools &= ~e_FIXES_BOOLS_PUT_IN_TRAIN;
  2704.                     }
  2705.                 #endif
  2706.                 // ==================
  2707.                 //  END:   TrainExit
  2708.                 // ==================
  2709.                
  2710.                 // ===========================
  2711.                 //  START: PutPlayerInVehicle
  2712.                 // ===========================
  2713.                 #if FIX_PutPlayerInVehicle
  2714.                     // Update their vehicle once we KNOW the client has done the
  2715.                     // removal from the vehicle.
  2716.                     if (bools & e_FIXES_BOOLS_PUT_IN_VEHICLE)
  2717.                     {
  2718.                         new
  2719.                             vid = FIXES_gsVehicleSeatData[playerid] & 0x00FFFFFF;
  2720.                         // Limited to "only" 16777216 vehicles and 256 seats.
  2721.                         PutPlayerInVehicle(playerid, vid, FIXES_gsVehicleSeatData[playerid] >>> 24);
  2722.                         bools &= ~e_FIXES_BOOLS_PUT_IN_VEHICLE;
  2723.                         #if FIX_TrainExit
  2724.                             switch (GetVehicleModel(vid))
  2725.                             {
  2726.                                 case 449, 537, 538:
  2727.                                 {
  2728.                                     bools |= e_FIXES_BOOLS_PUT_IN_TRAIN;
  2729.                                 }
  2730.                             }
  2731.                         #endif
  2732.                     }
  2733.                 #endif
  2734.                 // ===========================
  2735.                 //  END:   PutPlayerInVehicle
  2736.                 // ===========================
  2737.                
  2738.                 #if FIX_PutPlayerInVehicle || FIX_TrainExit
  2739.                     FIXES_gsPlayerBools[playerid] = bools;
  2740.                 #endif
  2741.             }
  2742.         #endif
  2743.        
  2744.         return FIXES_CALL_CALLBACK_1(OnPlayerStateChange, 1, FIXES_gscSpec@iii, playerid, newstate, oldstate);
  2745.     }
  2746.    
  2747.     #if defined _ALS_OnPlayerStateChange
  2748.         #undef OnPlayerStateChange
  2749.     #else
  2750.         #define _ALS_OnPlayerStateChange
  2751.     #endif
  2752.     #define OnPlayerStateChange FIXES_OnPlayerStateChange
  2753.    
  2754.     forward OnPlayerStateChange(playerid, newstate, oldstate);
  2755. #endif
  2756.  
  2757. /*
  2758.  * FIXES_GivePlayerWeapon(playerid, weaponid, ammo)
  2759.  *
  2760.  * FIXES:
  2761.  *     HydraSniper
  2762.  */
  2763. #if FIX_HydraSniper
  2764.     stock FIXES_GivePlayerWeapon(playerid, weaponid, ammo)
  2765.     {
  2766.         new
  2767.             vid = GetPlayerVehicleID(playerid);
  2768.         if (vid)
  2769.         {
  2770.             vid = GetVehicleModel(vid);
  2771.             if (weaponid == 34 && (vid == 520 || vid == 425))
  2772.             {
  2773.                 vid = GivePlayerWeapon(playerid, weaponid, ammo);
  2774.                 SetPlayerArmedWeapon(playerid, 0);
  2775.                 #if FIX_GetPlayerWeapon
  2776.                     #if FIXES_Single
  2777.                         FIXES_gsPlayerWeapon[playerid] = 0;
  2778.                     #else
  2779.                         SetPVarInt(playerid, FIXES_pvarPlayerWeapon, 0);
  2780.                     #endif
  2781.                 #endif
  2782.                 return vid;
  2783.             }
  2784.         }
  2785.         return GivePlayerWeapon(playerid, weaponid, ammo);
  2786.     }
  2787.    
  2788.     #if defined _ALS_GivePlayerWeapon
  2789.         #undef GivePlayerWeapon
  2790.     #else
  2791.        
  2792.         native BAD_GivePlayerWeapon(playerid, weaponid, ammo) = GivePlayerWeapon;
  2793.        
  2794.         #define _ALS_GivePlayerWeapon
  2795.     #endif
  2796.     #define GivePlayerWeapon FIXES_GivePlayerWeapon
  2797. #endif
  2798.  
  2799. /*
  2800.  * FIXES_SetPlayerArmedWeapon(playerid, weaponid)
  2801.  *
  2802.  * FIXES:
  2803.  *     GetPlayerWeapon
  2804.  */
  2805. #if FIX_GetPlayerWeapon
  2806.     stock FIXES_SetPlayerArmedWeapon(playerid, weaponid)
  2807.     {
  2808.         #if FIX_AllowInteriorWeapons
  2809.             if (FIXES_gsSettings & e_FIXES_SETTINGS_INTERIOR && GetPlayerInterior(playerid))
  2810.             {
  2811.                 // Not allowed weapons.
  2812.                 return 0;
  2813.             }
  2814.         #endif
  2815.         new
  2816.             vid = GetPlayerVehicleID(playerid);
  2817.         if (vid)
  2818.         {
  2819.             #if FIX_HydraSniper
  2820.                 vid = GetVehicleModel(vid);
  2821.                 if (weaponid == 34 && (vid == 520 || vid == 425))
  2822.                 {
  2823.                     return 0;
  2824.                 }
  2825.             #endif
  2826.             //FIXES_gsPlayerWeapon[playerid] = weaponid;
  2827.             #if FIXES_Single
  2828.                 FIXES_gsPlayerWeapon[playerid] = weaponid;
  2829.             #else
  2830.                 SetPVarInt(playerid, FIXES_pvarPlayerWeapon, weaponid);
  2831.             #endif
  2832.         }
  2833.         return SetPlayerArmedWeapon(playerid, weaponid);
  2834.     }
  2835.    
  2836.     #if defined _ALS_SetPlayerArmedWeapon
  2837.         #undef SetPlayerArmedWeapon
  2838.     #else
  2839.        
  2840.         native BAD_SetPlayerArmedWeapon(playerid, weaponid) = SetPlayerArmedWeapon;
  2841.        
  2842.         #define _ALS_SetPlayerArmedWeapon
  2843.     #endif
  2844.     #define SetPlayerArmedWeapon FIXES_SetPlayerArmedWeapon
  2845. #endif
  2846.  
  2847. /*
  2848.  * FIXES_GetPlayerWeapon(playerid)
  2849.  *
  2850.  * FIXES:
  2851.  *     GetPlayerWeapon
  2852.  */
  2853. #if FIX_GetPlayerWeapon
  2854.     stock FIXES_GetPlayerWeapon(playerid)
  2855.     {
  2856.         #if FIXES_Single
  2857.             new
  2858.                 ret = FIXES_gsPlayerWeapon[playerid];
  2859.         #else
  2860.             new
  2861.                 ret = GetPVarInt(playerid, FIXES_pvarPlayerWeapon);
  2862.         #endif
  2863.         if (ret == -1)
  2864.         {
  2865.             return GetPlayerWeapon(playerid);
  2866.         }
  2867.         return ret;
  2868.     }
  2869.    
  2870.     #if defined _ALS_GetPlayerWeapon
  2871.         #undef GetPlayerWeapon
  2872.     #else
  2873.        
  2874.         native BAD_GetPlayerWeapon(playerid) = GetPlayerWeapon;
  2875.        
  2876.         #define _ALS_GetPlayerWeapon
  2877.     #endif
  2878.     #define GetPlayerWeapon FIXES_GetPlayerWeapon
  2879. #endif
  2880.  
  2881. /*
  2882.  * FIXES_PutPlayerInVehicle(playerid, vehicleid, seatid)
  2883.  *
  2884.  * FIXES:
  2885.  *     PutPlayerInVehicle
  2886.  */
  2887. #if FIX_PutPlayerInVehicle || FIX_TrainExit
  2888.     #if FIXES_Single
  2889.         stock FIXES_PutPlayerInVehicle(playerid, vehicleid, seatid)
  2890.         {
  2891.             // ==================
  2892.             //  BEGIN: TrainExit
  2893.             // ==================
  2894.             #if FIX_TrainExit
  2895.                 FIXES_PRINTF("TrainExit %d", GetVehicleModel(vehicleid));
  2896.                 switch (GetVehicleModel(vehicleid))
  2897.                 {
  2898.                     case 449, 537, 538:
  2899.                     {
  2900.                         FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_PUT_IN_TRAIN;
  2901.                     }
  2902.                 }
  2903.             #endif
  2904.             // ==================
  2905.             //  END:   TrainExit
  2906.             // ==================
  2907.            
  2908.             // ===========================
  2909.             //  BEGIN: PutPlayerInVehicle
  2910.             // ===========================
  2911.             #if FIX_PutPlayerInVehicle
  2912.                 new
  2913.                     vid = GetPlayerVehicleID(playerid);
  2914.                 if (vid)
  2915.                 {
  2916.                     new
  2917.                         Float:x,
  2918.                         Float:y,
  2919.                         Float:z;
  2920.                     // Remove them without the animation.
  2921.                     GetVehiclePos(vid, x, y, z);
  2922.                     SetPlayerPos(playerid, x, y, z);
  2923.                     FIXES_gsVehicleSeatData[playerid] = seatid << 24 | vehicleid;
  2924.                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_PUT_IN_VEHICLE;
  2925.                     return 1;
  2926.                 }
  2927.             #endif
  2928.             // ===========================
  2929.             //  END:   PutPlayerInVehicle
  2930.             // ===========================
  2931.             return PutPlayerInVehicle(playerid, vehicleid, seatid);
  2932.         }
  2933.     #else
  2934.         forward _FIXES_PutPlayerInVehicle(playerid, vehicleid, seatid, from, data);
  2935.        
  2936.         stock FIXES_PutPlayerInVehicle(playerid, vehicleid, seatid)
  2937.         {
  2938.             FIXES_PRINTF("NOT SINGLE");
  2939.             // ===========================
  2940.             //  BEGIN: PutPlayerInVehicle
  2941.             // ===========================
  2942.             #if FIX_PutPlayerInVehicle
  2943.                 new
  2944.                     vid = GetPlayerVehicleID(playerid);
  2945.                 if (vid)
  2946.                 {
  2947.                     new
  2948.                         Float:x,
  2949.                         Float:y,
  2950.                         Float:z;
  2951.                     // Remove them without the animation.
  2952.                     GetVehiclePos(vid, x, y, z);
  2953.                     SetPlayerPos(playerid, x, y, z);
  2954.                     CallRemoteFunction(FIXES_gscPutPlayerInVehicle, FIXES_gscSpec@iiiii, playerid, vehicleid, seatid, 1, vid);
  2955.                     return 1;
  2956.                 }
  2957.             // ===========================
  2958.             //  END:   PutPlayerInVehicle
  2959.             // ===========================
  2960.            
  2961.             // ==================
  2962.             //  BEGIN: TrainExit
  2963.             // ==================
  2964.             #if FIX_TrainExit
  2965.                 new
  2966.                     model = GetVehicleModel(vehicleid);
  2967.                 switch (model)
  2968.                 {
  2969.                     case 449, 537, 538:
  2970.                     {
  2971.                         CallRemoteFunction(FIXES_gscPutPlayerInVehicle, FIXES_gscSpec@iiiii, playerid, vehicleid, seatid, 0, model);
  2972.                         //FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_PUT_IN_TRAIN;
  2973.                     }
  2974.                 }
  2975.             #endif
  2976.             // ==================
  2977.             //  END:   TrainExit
  2978.             // ==================
  2979.             return PutPlayerInVehicle(playerid, vehicleid, seatid);
  2980.         }
  2981.        
  2982.         public _FIXES_PutPlayerInVehicle(playerid, vehicleid, seatid, from, data)
  2983.         {
  2984.             FIXES_PRINTF("IN CHARGE: %d", (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE));
  2985.             if (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  2986.             {
  2987.                 // ===========================
  2988.                 //  BEGIN: PutPlayerInVehicle
  2989.                 // ===========================
  2990.                 #if FIX_PutPlayerInVehicle
  2991.                     if (from)
  2992.                     {
  2993.                         FIXES_gsVehicleSeatData[playerid] = seatid << 24 | vehicleid;
  2994.                         FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_PUT_IN_VEHICLE;
  2995.                     }
  2996.                 #endif
  2997.                 // ===========================
  2998.                 //  END:   PutPlayerInVehicle
  2999.                 // ===========================
  3000.                
  3001.                 // ==================
  3002.                 //  BEGIN: TrainExit
  3003.                 // ==================
  3004.                 #if FIX_TrainExit
  3005.                     #if FIX_PutPlayerInVehicle
  3006.                         else
  3007.                     #else
  3008.                         if (!from)
  3009.                     #endif
  3010.                         {
  3011.                             switch (data)
  3012.                             {
  3013.                                 case 449, 537, 538:
  3014.                                 {
  3015.                                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_PUT_IN_TRAIN;
  3016.                                 }
  3017.                             }
  3018.                         }
  3019.                 #endif
  3020.                 // ==================
  3021.                 //  END:   TrainExit
  3022.                 // ==================
  3023.             }
  3024.             return 1;
  3025.         }
  3026.     #endif
  3027.    
  3028.     #if defined _ALS_PutPlayerInVehicle
  3029.         #undef PutPlayerInVehicle
  3030.     #else
  3031.        
  3032.         native BAD_PutPlayerInVehicle(playerid, vehicleid, seatid) = PutPlayerInVehicle;
  3033.        
  3034.         #define _ALS_PutPlayerInVehicle
  3035.     #endif
  3036.     #define PutPlayerInVehicle FIXES_PutPlayerInVehicle
  3037. #endif
  3038.  
  3039. /*
  3040.  * FIXES_SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size)
  3041.  *
  3042.  * FIXES:
  3043.  *     SetPlayerCheckpoint
  3044.  */
  3045. #if FIX_SetPlayerCheckpoint
  3046.     stock FIXES_SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size)
  3047.     {
  3048.         DisablePlayerCheckpoint(playerid);
  3049.         return SetPlayerCheckpoint(playerid, x, y, z, size);
  3050.     }
  3051.    
  3052.     #if defined _ALS_SetPlayerCheckpoint
  3053.         #undef SetPlayerCheckpoint
  3054.     #else
  3055.        
  3056.         native BAD_SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size) = SetPlayerCheckpoint;
  3057.        
  3058.         #define _ALS_SetPlayerCheckpoint
  3059.     #endif
  3060.     #define SetPlayerCheckpoint FIXES_SetPlayerCheckpoint
  3061. #endif
  3062.  
  3063. /*
  3064.  * FIXES_SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size)
  3065.  *
  3066.  * FIXES:
  3067.  *     SetPlayerRaceCheckpoint
  3068.  */
  3069. #if FIX_SetPlayerRaceCheckpoint
  3070.     stock FIXES_SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size)
  3071.     {
  3072.         DisablePlayerRaceCheckpoint(playerid);
  3073.         return SetPlayerRaceCheckpoint(playerid, type, x, y, z, nextx, nexty, nextz, size);
  3074.     }
  3075.    
  3076.     #if defined _ALS_SetPlayerRaceCheckpoint
  3077.         #undef SetPlayerRaceCheckpoint
  3078.     #else
  3079.        
  3080.         native BAD_SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size) = SetPlayerRaceCheckpoint;
  3081.        
  3082.         #define _ALS_SetPlayerRaceCheckpoint
  3083.     #endif
  3084.     #define SetPlayerRaceCheckpoint FIXES_SetPlayerRaceCheckpoint
  3085. #endif
  3086.  
  3087. /*
  3088.  * Text:FIXES_TextDrawCreate(Float:x, Float:y, text[])
  3089.  *
  3090.  * FIXES:
  3091.  *     TextDrawCreate
  3092.  */
  3093. #if FIX_TextDrawCreate
  3094.     stock Text:FIXES_TextDrawCreate(Float:x, Float:y, text[])
  3095.     {
  3096.         if (text[0] == '\0' || text[0] == '\1' && text[1] == '\0')
  3097.         {
  3098.             return TextDrawCreate(x, y, " ");
  3099.         }
  3100.         else
  3101.         {
  3102.             return TextDrawCreate(x, y, text);
  3103.         }
  3104.     }
  3105.    
  3106.     #if defined _ALS_TextDrawCreate
  3107.         #undef TextDrawCreate
  3108.     #else
  3109.        
  3110.         native Text:BAD_TextDrawCreate(Float:x, Float:y, text[]) = TextDrawCreate;
  3111.        
  3112.         #define _ALS_TextDrawCreate
  3113.     #endif
  3114.     #define TextDrawCreate FIXES_TextDrawCreate
  3115. #endif
  3116.  
  3117. /*
  3118.  * FIXES_TextDrawSetString(Text:text, string[])
  3119.  *
  3120.  * FIXES:
  3121.  *     TextDrawSetString
  3122.  */
  3123. #if FIX_TextDrawSetString
  3124.     stock FIXES_TextDrawSetString(Text:text, string[])
  3125.     {
  3126.         if (string[0] == '\0' || string[0] == '\1' && string[1] == '\0')
  3127.         {
  3128.             return TextDrawSetString(text, " ");
  3129.         }
  3130.         else
  3131.         {
  3132.             return TextDrawSetString(text, string);
  3133.         }
  3134.     }
  3135.    
  3136.     #if defined _ALS_TextDrawSetString
  3137.         #undef TextDrawSetString
  3138.     #else
  3139.        
  3140.         native BAD_TextDrawSetString(Text:text, string[]) = TextDrawSetString;
  3141.        
  3142.         #define _ALS_TextDrawSetString
  3143.     #endif
  3144.     #define TextDrawSetString FIXES_TextDrawSetString
  3145. #endif
  3146.  
  3147. /*
  3148.  * FIXES_AllowInteriorWeapons(allow)
  3149.  *
  3150.  * FIXES:
  3151.  *     AllowInteriorWeapons
  3152.  */
  3153. #if FIX_AllowInteriorWeapons
  3154.     #if FIXES_Single
  3155.         stock FIXES_AllowInteriorWeapons(allow)
  3156.         {
  3157.             if (allow)
  3158.             {
  3159.                 FIXES_gsSettings &= ~e_FIXES_SETTINGS_INTERIOR;
  3160.                 for (new i = 0; i != MAX_PLAYERS; ++i)
  3161.                 {
  3162.                     FIXES_gsPlayerBools[i] &= ~e_FIXES_BOOLS_INTERIOR;
  3163.                 }
  3164.             }
  3165.             else
  3166.             {
  3167.                 FIXES_gsSettings |= e_FIXES_SETTINGS_INTERIOR;
  3168.                 for (new i = 0; i != MAX_PLAYERS; ++i)
  3169.                 {
  3170.                     if (GetPlayerInterior(i))
  3171.                     {
  3172.                         FIXES_gsPlayerBools[i] |= e_FIXES_BOOLS_INTERIOR;
  3173.                     }
  3174.                 }
  3175.             }
  3176.             return allow;
  3177.         }
  3178.     #else
  3179.         forward _FIXES_AllowInteriorWeapons(allow);
  3180.        
  3181.         stock FIXES_AllowInteriorWeapons(allow)
  3182.         {
  3183.             CallRemoteFunction(FIXES_gscAllowInteriorWeapons, FIXES_gscSpec@i, allow);
  3184.             return allow;
  3185.         }
  3186.        
  3187.         public _FIXES_AllowInteriorWeapons(allow)
  3188.         {
  3189.             if (allow)
  3190.             {
  3191.                 FIXES_gsSettings &= ~e_FIXES_SETTINGS_INTERIOR;
  3192.                 for (new i = 0; i != MAX_PLAYERS; ++i)
  3193.                 {
  3194.                     FIXES_gsPlayerBools[i] &= ~e_FIXES_BOOLS_INTERIOR;
  3195.                 }
  3196.             }
  3197.             else
  3198.             {
  3199.                 FIXES_gsSettings |= e_FIXES_SETTINGS_INTERIOR;
  3200.                 for (new i = 0; i != MAX_PLAYERS; ++i)
  3201.                 {
  3202.                     if (GetPlayerInterior(i))
  3203.                     {
  3204.                         FIXES_gsPlayerBools[i] |= e_FIXES_BOOLS_INTERIOR;
  3205.                     }
  3206.                 }
  3207.             }
  3208.             return allow;
  3209.         }
  3210.     #endif
  3211.    
  3212.     #if defined _ALS_AllowInteriorWeapons
  3213.         #undef AllowInteriorWeapons
  3214.     #else
  3215.        
  3216.         native BAD_AllowInteriorWeapons(allow) = AllowInteriorWeapons;
  3217.        
  3218.         #define _ALS_AllowInteriorWeapons
  3219.     #endif
  3220.     #define AllowInteriorWeapons FIXES_AllowInteriorWeapons
  3221. #endif
  3222.  
  3223. /*
  3224.  * OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  3225.  *
  3226.  * FIXES:
  3227.  *     AllowTeleport
  3228.  */
  3229. #if FIX_AllowTeleport && !defined FILTERSCRIPT
  3230.     forward _FIXES_AllowTeleport(playerid, allow);
  3231.    
  3232.     public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  3233.     {
  3234.         // ======================
  3235.         //  BEGIN: AllowTeleport
  3236.         // ======================
  3237.         #if FIX_AllowTeleport
  3238.             if (!_FIXES_gIsFilterscript)
  3239.             {
  3240.                 // Unusually, the call order here is always Game Mode first -
  3241.                 // most callbacks are Filter Script first.
  3242.                 if ((FIXES_gsPlayerBools[playerid] & e_FIXES_BOOLS_TELEPORT) || ((FIXES_gsSettings & e_FIXES_SETTINGS_ADMIN_TELEPORT) && (IsPlayerAdmin(playerid))))
  3243.                 {
  3244.                     SetPlayerPosFindZ(playerid, fX, fY, fZ);
  3245.                 }
  3246.             }
  3247.         #endif
  3248.         // ======================
  3249.         //  END:   AllowTeleport
  3250.         // ======================
  3251.         return FIXES_CALL_CALLBACK_2(OnPlayerClickMap, 1, FIXES_gscSpec@ifff, playerid, fX, fY, fZ);
  3252.     }
  3253.    
  3254.     #if defined _ALS_OnPlayerClickMap
  3255.         #undef OnPlayerClickMap
  3256.     #else
  3257.         #define _ALS_OnPlayerClickMap
  3258.     #endif
  3259.     #define OnPlayerClickMap FIXES_OnPlayerClickMap
  3260.    
  3261.     forward OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ);
  3262. #endif
  3263.  
  3264. /*
  3265.  * FIXES_AllowPlayerTeleport(playerid, allow)
  3266.  *
  3267.  * FIXES:
  3268.  *     AllowTeleport
  3269.  */
  3270. #if FIX_AllowTeleport
  3271.     #if FIXES_Single
  3272.         stock FIXES_AllowPlayerTeleport(playerid, allow)
  3273.         {
  3274.             if (0 <= playerid < MAX_PLAYERS)
  3275.             {
  3276.                 if (allow)
  3277.                 {
  3278.                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_TELEPORT;
  3279.                 }
  3280.                 else
  3281.                 {
  3282.                     FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_TELEPORT;
  3283.                 }
  3284.             }
  3285.             return 0;
  3286.         }
  3287.     #else
  3288.         stock FIXES_AllowPlayerTeleport(playerid, allow)
  3289.         {
  3290.             if (0 <= playerid < MAX_PLAYERS)
  3291.             {
  3292.                 CallRemoteFunction(FIXES_gscAllowTeleport, FIXES_gscSpec@ii, playerid, allow)
  3293.             }
  3294.             return 0;
  3295.         }
  3296.     #endif
  3297.    
  3298.     #if defined _ALS_AllowPlayerTeleport
  3299.         #undef AllowPlayerTeleport
  3300.     #else
  3301.        
  3302.         native BAD_AllowPlayerTeleport(playerid, allow) = AllowPlayerTeleport;
  3303.        
  3304.         #define _ALS_AllowPlayerTeleport
  3305.     #endif
  3306.     #define AllowPlayerTeleport FIXES_AllowPlayerTeleport
  3307. #endif
  3308.  
  3309. /*
  3310.  * FIXES_AllowAdminTeleport(allow)
  3311.  *
  3312.  * FIXES:
  3313.  *     AllowTeleport
  3314.  */
  3315. #if FIX_AllowTeleport
  3316.     #if FIXES_Single
  3317.         stock FIXES_AllowAdminTeleport(allow)
  3318.         {
  3319.             if (allow)
  3320.             {
  3321.                 FIXES_gsSettings |= e_FIXES_SETTINGS_ADMIN_TELEPORT;
  3322.             }
  3323.             else
  3324.             {
  3325.                 FIXES_gsSettings &= ~e_FIXES_SETTINGS_ADMIN_TELEPORT;
  3326.             }
  3327.             return allow;
  3328.         }
  3329.     #else
  3330.         stock FIXES_AllowAdminTeleport(allow)
  3331.         {
  3332.             CallRemoteFunction(FIXES_gscAllowTeleport, FIXES_gscSpec@ii, INVALID_PLAYER_ID, allow)
  3333.             return allow;
  3334.         }
  3335.     #endif
  3336.    
  3337.     #if defined _ALS_AllowAdminTeleport
  3338.         #undef AllowAdminTeleport
  3339.     #else
  3340.        
  3341.         native BAD_AllowAdminTeleport(allow) = AllowAdminTeleport;
  3342.        
  3343.         #define _ALS_AllowAdminTeleport
  3344.     #endif
  3345.     #define AllowAdminTeleport FIXES_AllowAdminTeleport
  3346. #endif
  3347.  
  3348. /*
  3349.  * FIXES_AllowAdminTeleport(allow)
  3350.  *
  3351.  * FIXES:
  3352.  *     AllowTeleport
  3353.  */
  3354. #if FIX_AllowTeleport && !defined FILTERSCRIPT && !FIXES_Single
  3355.     public _FIXES_AllowTeleport(playerid, allow)
  3356.     {
  3357.         if (!_FIXES_gIsFilterscript)
  3358.         {
  3359.             if (playerid == INVALID_PLAYER_ID)
  3360.             {
  3361.                 if (allow)
  3362.                 {
  3363.                     FIXES_gsSettings |= e_FIXES_SETTINGS_ADMIN_TELEPORT;
  3364.                 }
  3365.                 else
  3366.                 {
  3367.                     FIXES_gsSettings &= ~e_FIXES_SETTINGS_ADMIN_TELEPORT;
  3368.                 }
  3369.             }
  3370.             else
  3371.             {
  3372.                 if (allow)
  3373.                 {
  3374.                     FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_TELEPORT;
  3375.                 }
  3376.                 else
  3377.                 {
  3378.                     FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_TELEPORT;
  3379.                 }
  3380.             }
  3381.         }
  3382.     }
  3383. #endif
  3384.  
  3385. /*
  3386.  * FIXES_SetPlayerSpecialAction(playerid, actionid)
  3387.  *
  3388.  * FIXES:
  3389.  *     SetPlayerSpecialAction
  3390.  */
  3391. #if FIX_SetPlayerSpecialAction
  3392.     stock FIXES_SetPlayerSpecialAction(playerid, actionid)
  3393.     {
  3394.         if (GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
  3395.         {
  3396.             ClearAnimations(playerid);
  3397.         }
  3398.         SetPlayerSpecialAction(playerid, actionid);
  3399.         return 1;
  3400.     }
  3401.    
  3402.     #if defined _ALS_SetPlayerSpecialAction
  3403.         #undef SetPlayerSpecialAction
  3404.     #else
  3405.        
  3406.         native BAD_SetPlayerSpecialAction(playerid, actionid) = SetPlayerSpecialAction;
  3407.        
  3408.         #define _ALS_SetPlayerSpecialAction
  3409.     #endif
  3410.     #define SetPlayerSpecialAction FIXES_SetPlayerSpecialAction
  3411. #endif
  3412.  
  3413. /*
  3414.  * FIXES_ShowPlayerDialog(playerid, dialog, style, title[], caption[], button1[], button2[])
  3415.  *
  3416.  * FIXES:
  3417.  *     OnDialogResponse
  3418.  */
  3419. #if FIX_OnDialogResponse
  3420.     stock FIXES_ShowPlayerDialog(playerid, dialog, style, title[], caption[], button1[], button2[])
  3421.     {
  3422.         if (0 <= playerid < MAX_PLAYERS)
  3423.         {
  3424.             #if FIXES_Single
  3425.                 FIXES_gsDialogID[playerid] = dialog;
  3426.             #else
  3427.                 SetPVarInt(playerid, FIXES_pvarPlayerDialog, dialog);
  3428.             #endif
  3429.             return ShowPlayerDialog(playerid, dialog, style, title, caption, button1, button2);
  3430.         }
  3431.         return 0;
  3432.     }
  3433.    
  3434.     #if defined _ALS_ShowPlayerDialog
  3435.         #undef ShowPlayerDialog
  3436.     #else
  3437.        
  3438.         native BAD_ShowPlayerDialog(playerid, dialog, style, title[], caption[], button1[], button2[]) = ShowPlayerDialog;
  3439.        
  3440.         #define _ALS_ShowPlayerDialog
  3441.     #endif
  3442.     #define ShowPlayerDialog FIXES_ShowPlayerDialog
  3443. #endif
  3444.  
  3445. /*
  3446.  * OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  3447.  *
  3448.  * FIXES:
  3449.  *     OnDialogResponse
  3450.  */
  3451. #if FIX_OnDialogResponse
  3452.     public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  3453.     {
  3454.         // =========================
  3455.         //  BEGIN: OnDialogResponse
  3456.         // =========================
  3457.         #if FIX_OnDialogResponse
  3458.             if (inputtext[0])
  3459.             {
  3460.                 #if FIXES_Single
  3461.                     return FIXES_CALL_CALLBACK_2(OnDialogResponse, 1, FIXES_gscSpec@iiiis, playerid, FIXES_gsDialogID[playerid], response, listitem, inputtext);
  3462.                 #else
  3463.                     return FIXES_CALL_CALLBACK_2(OnDialogResponse, 1, FIXES_gscSpec@iiiis, playerid, GetPVarInt(playerid, FIXES_pvarPlayerDialog), response, listitem, inputtext);
  3464.                 #endif
  3465.             }
  3466.             else
  3467.             {
  3468.                 #if FIXES_Single
  3469.                     return FIXES_CALL_CALLBACK_2(OnDialogResponse, 1, FIXES_gscSpec@iiiis, playerid, FIXES_gsDialogID[playerid], response, listitem, FIXES_gscNULL);
  3470.                 #else
  3471.                     return FIXES_CALL_CALLBACK_2(OnDialogResponse, 1, FIXES_gscSpec@iiiis, playerid, GetPVarInt(playerid, FIXES_pvarPlayerDialog), response, listitem, FIXES_gscNULL);
  3472.                 #endif
  3473.             }
  3474.         #endif
  3475.         // =========================
  3476.         //  END:   OnDialogResponse
  3477.         // =========================
  3478.     }
  3479.    
  3480.     #if defined _ALS_OnDialogResponse
  3481.         #undef OnDialogResponse
  3482.     #else
  3483.         #define _ALS_OnDialogResponse
  3484.     #endif
  3485.     #define OnDialogResponse FIXES_OnDialogResponse
  3486.    
  3487.     forward OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
  3488. #endif
  3489.  
  3490. /*
  3491.  * FIXES_GetPlayerDialog(playerid)
  3492.  *
  3493.  * FIXES:
  3494.  *     GetPlayerDialog
  3495.  */
  3496. #if FIX_GetPlayerDialog
  3497.     #if FIX_OnDialogResponse
  3498.         stock FIXES_GetPlayerDialog(playerid)
  3499.         {
  3500.             if (0 <= playerid < MAX_PLAYERS)
  3501.             {
  3502.                 #if FIXES_Single
  3503.                     return FIXES_gsDialogID[playerid];
  3504.                 #else
  3505.                     return GetPVarInt(playerid, FIXES_pvarPlayerDialog);
  3506.                 #endif
  3507.             }
  3508.             return -1;
  3509.         }
  3510.        
  3511.         #if defined _ALS_GetPlayerDialog
  3512.             #undef GetPlayerDialog
  3513.         #else
  3514.             #define _ALS_GetPlayerDialog
  3515.         #endif
  3516.         #define GetPlayerDialog FIXES_GetPlayerDialog
  3517.     #else
  3518.         #error FIX_GetPlayerDialog requires FIX_OnDialogResponse.
  3519.     #endif
  3520. #endif
  3521.  
  3522. /*
  3523.  * FIXES_HideMenuForPlayer(Menu:menuid, playerid
  3524.  *
  3525.  * FIXES:
  3526.  *     HideMenuForPlayer
  3527.  */
  3528. #if FIX_HideMenuForPlayer
  3529.     stock FIXES_HideMenuForPlayer(Menu:menuid, playerid)
  3530.     {
  3531.         if (IsValidMenu(menuid))
  3532.         {
  3533.             return HideMenuForPlayer(menuid, playerid);
  3534.         }
  3535.         return 0;
  3536.     }
  3537.    
  3538.     #if defined _ALS_HideMenuForPlayer
  3539.         #undef HideMenuForPlayer
  3540.     #else
  3541.        
  3542.         native BAD_HideMenuForPlayer(Menu:menuid, playerid) = HideMenuForPlayer;
  3543.        
  3544.         #define _ALS_HideMenuForPlayer
  3545.     #endif
  3546.     #define HideMenuForPlayer FIXES_HideMenuForPlayer
  3547. #endif
  3548.  
  3549. /*
  3550.  * FIXES_valstr(dest[], value, bool:pack = false)
  3551.  *
  3552.  * FIXES:
  3553.  *     valstr
  3554.  */
  3555. #if FIX_valstr
  3556.     stock FIXES_valstr(dest[], value, bool:pack = false)
  3557.     {
  3558.         // "format" can't handle cellmin properly.
  3559.         static const
  3560.             sc_szCellmin[] = !"-2147483648";
  3561.         if (value == cellmin)
  3562.         {
  3563.             pack && strpack(dest, sc_szCellmin, 12) || strunpack(dest, sc_szCellmin, 12);
  3564.         }
  3565.         else
  3566.         {
  3567.             format(dest, 12, "%d", value);
  3568.             pack && strpack(dest, dest, 12);
  3569.         }
  3570.         return 0;
  3571.     }
  3572.    
  3573.     #if defined _ALS_valstr
  3574.         #undef valstr
  3575.     #else
  3576.        
  3577.         native BAD_valstr(dest[], value, bool:pack = false) = valstr;
  3578.        
  3579.         #define _ALS_valstr
  3580.     #endif
  3581.     #define valstr FIXES_valstr
  3582. #endif
  3583.  
  3584. /*
  3585.  * FIXES_fclose(File:handle)
  3586.  *
  3587.  * FIXES:
  3588.  *     fclose
  3589.  */
  3590. #if FIX_fclose
  3591.     stock bool:FIXES_fclose(File:handle)
  3592.     {
  3593.         if (handle)
  3594.         {
  3595.             return fclose(handle);
  3596.         }
  3597.         return false;
  3598.     }
  3599.    
  3600.     #if defined _ALS_fclose
  3601.         #undef fclose
  3602.     #else
  3603.        
  3604.         native BAD_fclose(File:handle) = fclose;
  3605.        
  3606.         #define _ALS_fclose
  3607.     #endif
  3608.     #define fclose FIXES_fclose
  3609. #endif
  3610.  
  3611. /*
  3612.  * FIXES_fwrite(File:handle, const string[])
  3613.  *
  3614.  * FIXES:
  3615.  *     fwrite
  3616.  */
  3617. #if FIX_fwrite
  3618.     stock FIXES_fwrite(File:handle, const string[])
  3619.     {
  3620.         if (handle)
  3621.         {
  3622.             return fwrite(handle, string);
  3623.         }
  3624.         return 0;
  3625.     }
  3626.    
  3627.     #if defined _ALS_fwrite
  3628.         #undef fwrite
  3629.     #else
  3630.        
  3631.         native BAD_fwrite(File:handle, const string[]) = fwrite;
  3632.        
  3633.         #define _ALS_fwrite
  3634.     #endif
  3635.     #define fwrite FIXES_fwrite
  3636. #endif
  3637.  
  3638. /*
  3639.  * FIXES_fread(File:handle, string[], size = sizeof (string), bool:pack = false)
  3640.  *
  3641.  * FIXES:
  3642.  *     fread
  3643.  */
  3644. #if FIX_fread
  3645.     stock FIXES_fread(File:handle, string[], size = sizeof (string), bool:pack = false)
  3646.     {
  3647.         if (handle)
  3648.         {
  3649.             return fread(handle, string, size, pack);
  3650.         }
  3651.         return 0;
  3652.     }
  3653.    
  3654.     #if defined _ALS_fread
  3655.         #undef fread
  3656.     #else
  3657.        
  3658.         native BAD_fread(File:handle, string[], size = sizeof (string), bool:pack = false) = fread;
  3659.        
  3660.         #define _ALS_fread
  3661.     #endif
  3662.     #define fread FIXES_fread
  3663. #endif
  3664.  
  3665. /*
  3666.  * FIXES_fputchar(File:handle, value, bool:utf8 = true)
  3667.  *
  3668.  * FIXES:
  3669.  *     fputchar
  3670.  */
  3671. #if FIX_fputchar
  3672.     stock bool:FIXES_fputchar(File:handle, value, bool:utf8 = true)
  3673.     {
  3674.         if (handle)
  3675.         {
  3676.             return fputchar(handle, value, utf8);
  3677.         }
  3678.        return false;
  3679.     }
  3680.    
  3681.     #if defined _ALS_fputchar
  3682.         #undef fputchar
  3683.     #else
  3684.        
  3685.         native BAD_fputchar(File:handle, value, bool:utf8 = true) = fputchar;
  3686.        
  3687.         #define _ALS_fputchar
  3688.     #endif
  3689.     #define fputchar FIXES_fputchar
  3690. #endif
  3691.  
  3692. /*
  3693.  * FIXES_fgetchar(File:handle, value, bool:utf8 = true)
  3694.  *
  3695.  * FIXES:
  3696.  *     fgetchar
  3697.  */
  3698. #if FIX_fgetchar
  3699.     stock FIXES_fgetchar(File:handle, value, bool:utf8 = true)
  3700.     {
  3701.         if (handle)
  3702.         {
  3703.             return fgetchar(handle, value, utf8);
  3704.         }
  3705.         return 0;
  3706.     }
  3707.    
  3708.     #if defined _ALS_fgetchar
  3709.         #undef fgetchar
  3710.     #else
  3711.        
  3712.         native BAD_fgetchar(File:handle, value, bool:utf8 = true) = fgetchar;
  3713.        
  3714.         #define _ALS_fgetchar
  3715.     #endif
  3716.     #define fgetchar FIXES_fgetchar
  3717. #endif
  3718.  
  3719. /*
  3720.  * FIXES_fblockwrite(File:handle, const buffer[], size = sizeof (buffer))
  3721.  *
  3722.  * FIXES:
  3723.  *     fblockwrite
  3724.  */
  3725. #if FIX_fblockwrite
  3726.     stock FIXES_fblockwrite(File:handle, const buffer[], size = sizeof (buffer))
  3727.     {
  3728.         if (handle)
  3729.         {
  3730.             return fblockwrite(handle, buffer, size);
  3731.         }
  3732.         return 0;
  3733.     }
  3734.    
  3735.     #if defined _ALS_fblockwrite
  3736.         #undef fblockwrite
  3737.     #else
  3738.        
  3739.         native BAD_fblockwrite(File:handle, const buffer[], size = sizeof (buffer)) = fblockwrite;
  3740.        
  3741.         #define _ALS_fblockwrite
  3742.     #endif
  3743.     #define fblockwrite FIXES_fblockwrite
  3744. #endif
  3745.  
  3746. /*
  3747.  * FIXES_fblockread(File:handle, buffer[], size = sizeof (buffer))
  3748.  *
  3749.  * FIXES:
  3750.  *     fblockread
  3751.  */
  3752. #if FIX_fblockread
  3753.     stock FIXES_fblockread(File:handle, buffer[], size = sizeof (buffer))
  3754.     {
  3755.         if (handle)
  3756.         {
  3757.             return fblockread(handle, buffer, size);
  3758.         }
  3759.         return 0;
  3760.     }
  3761.    
  3762.     #if defined _ALS_fblockread
  3763.         #undef fblockread
  3764.     #else
  3765.        
  3766.         native BAD_fblockread(File:handle, buffer[], size = sizeof (buffer)) = fblockread;
  3767.        
  3768.         #define _ALS_fblockread
  3769.     #endif
  3770.     #define fblockread FIXES_fblockread
  3771. #endif
  3772.  
  3773. /*
  3774.  * FIXES_fseek(File:handle, position = 0, seek_whence:whence = seek_start)
  3775.  *
  3776.  * FIXES:
  3777.  *     fseek
  3778.  */
  3779. #if FIX_fseek
  3780.     stock FIXES_fseek(File:handle, position = 0, seek_whence:whence = seek_start)
  3781.     {
  3782.         if (handle)
  3783.         {
  3784.             return fseek(handle, position, whence);
  3785.         }
  3786.         return 0;
  3787.     }
  3788.    
  3789.     #if defined _ALS_fseek
  3790.         #undef fseek
  3791.     #else
  3792.        
  3793.         native BAD_fseek(File:handle, position = 0, seek_whence:whence = seek_start) = fseek;
  3794.        
  3795.         #define _ALS_fseek
  3796.     #endif
  3797.     #define fseek FIXES_fseek
  3798. #endif
  3799.  
  3800. /*
  3801.  * FIXES_flength(File:handle)
  3802.  *
  3803.  * FIXES:
  3804.  *     flength
  3805.  */
  3806. #if FIX_flength
  3807.     stock FIXES_flength(File:handle)
  3808.     {
  3809.         if (handle)
  3810.         {
  3811.             return flength(handle);
  3812.         }
  3813.         return 0;
  3814.     }
  3815.    
  3816.     #if defined _ALS_flength
  3817.         #undef flength
  3818.     #else
  3819.        
  3820.         native BAD_flength(File:handle) = flength;
  3821.        
  3822.         #define _ALS_flength
  3823.     #endif
  3824.     #define flength FIXES_flength
  3825. #endif
  3826.  
  3827. /*
  3828.  * FIXES_Kick(playerid)
  3829.  *
  3830.  * FIXES:
  3831.  *     Kick
  3832.  */
  3833. #if FIX_Kick
  3834.     forward _FIXES_Kick(playerid);
  3835.    
  3836.     public _FIXES_Kick(playerid)
  3837.     {
  3838.         FIXES_gsPlayerBools[playerid] &= ~e_FIXES_BOOLS_KICKED;
  3839.         Kick(playerid);
  3840.     }
  3841.    
  3842.     stock FIXES_Kick(playerid)
  3843.     {
  3844.         if (FIXES_gsPlayerBools[playerid] & e_FIXES_BOOLS_ON_PLAYER_CONNECT)
  3845.         {
  3846.             // Disable as much of the server as possible quickly.
  3847.             FIXES_BlockUpdate(playerid, true);
  3848.             TogglePlayerSpectating(playerid, true);
  3849.             TogglePlayerControllable(playerid, false);
  3850.             SetPVarInt(playerid, FIXES_pvarKick, SetTimerEx(FIXES_gscKick, 1000, 0, FIXES_gscSpec@i, playerid));
  3851.             FIXES_gsPlayerBools[playerid] |= e_FIXES_BOOLS_KICKED;
  3852.             return 1;
  3853.         }
  3854.         else
  3855.         {
  3856.             return Kick(playerid);
  3857.         }
  3858.     }
  3859.    
  3860.     #if defined _ALS_Kick
  3861.         #undef Kick
  3862.     #else
  3863.        
  3864.         native BAD_Kick(playerid) = Kick;
  3865.        
  3866.         #define _ALS_Kick
  3867.     #endif
  3868.     #define Kick FIXES_Kick
  3869. #endif
  3870.  
  3871. /*
  3872.  * FIXES_IsPAttachedObjectSlotUsed(playerid, index)
  3873.  *
  3874.  * FIXES:
  3875.  *     IsPlayerAttachedObjectSlotUsed
  3876.  */
  3877. #if FIX_IsPlayerAttachedObjSlotUsed
  3878.     stock FIXES_IsPAttachedObjectSlotUsed(playerid, index)
  3879.     {
  3880.         if (IsPlayerConnected(playerid))
  3881.         {
  3882.             return FIXES_gsObjectSlots[playerid / _FIXES_ATTACHMENTS] & 1 << playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS + index;
  3883.         }
  3884.         return 0;
  3885.     }
  3886.    
  3887.     #if defined _ALS_IsPAttachedObjSlotUsed
  3888.         #undef IsPlayerAttachedObjectSlotUsed
  3889.     #else
  3890.        
  3891.         native BAD_IsPlayerAttachedObjSlotUsed(playerid, index) = IsPlayerAttachedObjectSlotUsed;
  3892.        
  3893.         #define _ALS_IsPAttachedObjSlotUsed
  3894.     #endif
  3895.     #define IsPlayerAttachedObjectSlotUsed FIXES_IsPAttachedObjectSlotUsed
  3896. #endif
  3897.  
  3898. /*
  3899.  * _FIXES_SetPlayerAttachedObject(slot, to)
  3900.  *
  3901.  * FIXES:
  3902.  *     IsPlayerAttachedObjectSlotUsed
  3903.  */
  3904. #if (FIX_IsPlayerAttachedObjSlotUsed || FIX_SetPlayerAttachedObject) && !FIXES_Single
  3905.     forward _FIXES_SetPlayerAttachedObject(slot, to);
  3906.    
  3907.     public _FIXES_SetPlayerAttachedObject(slot, to)
  3908.     {
  3909.         FIXES_gsObjectSlots[slot] = to;
  3910.     }
  3911. #endif
  3912.  
  3913. /*
  3914.  * FIXES_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0)
  3915.  *
  3916.  * FIXES:
  3917.  *     IsPlayerAttachedObjectSlotUsed
  3918.  *     SetPlayerAttachedObject
  3919.  */
  3920. #if FIX_IsPlayerAttachedObjSlotUsed || FIX_SetPlayerAttachedObject
  3921.     stock FIXES_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0)
  3922.     {
  3923.         if (SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ))
  3924.         {
  3925.             #if FIXES_Single
  3926.                 FIXES_gsObjectSlots[playerid / _FIXES_ATTACHMENTS] |= (1 << playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS + index);
  3927.             #else
  3928.                 new
  3929.                     slot = playerid / _FIXES_ATTACHMENTS;
  3930.                 CallRemoteFunction(FIXES_gscSetPlayerAttachedObj, FIXES_gscSpec@ii, slot, FIXES_gsObjectSlots[slot] | (1 << playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS + index));
  3931.             #endif
  3932.             return 1;
  3933.         }
  3934.         return 0;
  3935.     }
  3936.    
  3937.     #if defined _ALS_SetPlayerAttachedObject
  3938.         #undef SetPlayerAttachedObject
  3939.     #else
  3940.        
  3941.         native BAD_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0) = SetPlayerAttachedObject;
  3942.        
  3943.         #define _ALS_SetPlayerAttachedObject
  3944.     #endif
  3945.     #define SetPlayerAttachedObject FIXES_SetPlayerAttachedObject
  3946. #endif
  3947.  
  3948. /*
  3949.  * FIXES_RemovePlayerAttachedObj(playerid, index)
  3950.  *
  3951.  * FIXES:
  3952.  *     IsPlayerAttachedObjectSlotUsed
  3953.  */
  3954. #if FIX_IsPlayerAttachedObjSlotUsed || FIX_SetPlayerAttachedObject
  3955.     stock FIXES_RemovePlayerAttachedObj(playerid, index)
  3956.     {
  3957.         if (RemovePlayerAttachedObject(playerid, index))
  3958.         {
  3959.             #if FIXES_Single
  3960.                 FIXES_gsObjectSlots[playerid / _FIXES_ATTACHMENTS] &= ~(1 << playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS + index);
  3961.             #else
  3962.                 new
  3963.                     slot = playerid / _FIXES_ATTACHMENTS;
  3964.                 CallRemoteFunction(FIXES_gscSetPlayerAttachedObj, FIXES_gscSpec@ii, slot, FIXES_gsObjectSlots[slot] & ~(1 << playerid % _FIXES_ATTACHMENTS * MAX_PLAYER_ATTACHED_OBJECTS + index));
  3965.             #endif
  3966.             return 1;
  3967.         }
  3968.         return 0;
  3969.     }
  3970.    
  3971.     #if defined _ALS_RemovePlayerAttachedObject
  3972.         #undef RemovePlayerAttachedObject
  3973.     #else
  3974.        
  3975.         native BAD_RemovePlayerAttachedObject(playerid, index) = RemovePlayerAttachedObject;
  3976.        
  3977.         #define _ALS_RemovePlayerAttachedObject
  3978.     #endif
  3979.     #define RemovePlayerAttachedObject FIXES_RemovePlayerAttachedObj
  3980. #endif
  3981.  
  3982. /*
  3983.  * FIXES_%%%!!!
  3984.  *
  3985.  * FIXES:
  3986.  *     %%%
  3987.  */
  3988. /*#if FIX_%%%
  3989.     stock FIXES_%%%!!!
  3990.     {
  3991.         return 0;
  3992.     }
  3993.    
  3994.     #if defined _ALS_%%%
  3995.         #undef %%%
  3996.     #else
  3997.        
  3998.         native BAD_%%%!!! = %%%;
  3999.        
  4000.         #define _ALS_%%%
  4001.     #endif
  4002.     #define %%% FIXES_%%%
  4003. #endif
  4004. */
  4005.  
  4006. /*
  4007.  * _FIXES_DetermineOrder()
  4008.  *
  4009.  * Figure out which the first filterscript to be called is so that it can do the
  4010.  * majority of the work.  More detail:  Serveral pieces of code for some fixes
  4011.  * rely on things like blocking "OnPlayerUpdate".  This should be done in the
  4012.  * first script in which "OnPlayerUpdate" is called only, so we need to find out
  4013.  * in advance which script will be called first (at least out of all the fixed
  4014.  * scripts).
  4015.  */
  4016. #if !FIXES_Single
  4017.     public _FIXES_DetermineOrder()
  4018.     {
  4019.         // TODO: Graceful handoff.  I thought I was past all this rubbish!
  4020.         if (!_FIXES_gIsFilterscript)
  4021.         {
  4022.             /*if (!existproperty(5, FIXES_gscNoGMProperty))
  4023.             {
  4024.                 // Either this is a Filter Script (1) and we don't want Game
  4025.                 // Modes (1) or this isn't a filterscript (0) and we do want
  4026.                 // Game Modes (0).  All other cases return here due to a logic
  4027.                 // mismatch.  This is to rectify the difference in call orders
  4028.                 // between "CallRemoteFunction" and normal callbacks.
  4029.                 return 0;
  4030.             }
  4031.         }
  4032.         else
  4033.         {*/
  4034.             if (existproperty(5, FIXES_gscNoGMProperty))
  4035.             {
  4036.                 // Either this is a Filter Script (1) and we don't want Game
  4037.                 // Modes (1) or this isn't a filterscript (0) and we do want
  4038.                 // Game Modes (0).  All other cases return here due to a logic
  4039.                 // mismatch.  This is to rectify the difference in call orders
  4040.                 // between "CallRemoteFunction" and normal callbacks.
  4041.                 // Now DOESN'T end on the second time round for filterscripts to
  4042.                 // correctly pass on the data to GameModes.
  4043.                 return 0;
  4044.             }
  4045.             // Make sure certain data is synced with what the GM thinks it is.
  4046.             // =============================
  4047.             //  START: AllowInteriorWeapons
  4048.             // =============================
  4049.             #if FIX_AllowInteriorWeapons
  4050.                 CallRemoteFunction(FIXES_gscAllowInteriorWeapons, FIXES_gscSpec@i, !(FIXES_gsSettings & e_FIXES_SETTINGS_INTERIOR));
  4051.             #endif
  4052.             // =============================
  4053.             //  START: AllowInteriorWeapons
  4054.             // =============================
  4055.            
  4056.             // ================================
  4057.             //  START: SetPlayerAttachedObject
  4058.             // ================================
  4059.             #if FIX_IsPlayerAttachedObjSlotUsed || FIX_SetPlayerAttachedObject
  4060.                 for (new i = 0; i != _FIXES_ATTACHMENTS; ++i)
  4061.                 {
  4062.                     CallRemoteFunction(FIXES_gscSetPlayerAttachedObj, FIXES_gscSpec@ii, i, FIXES_gsObjectSlots[i]);
  4063.                 }
  4064.             #endif
  4065.             // ==============================
  4066.             //  END: SetPlayerAttachedObject
  4067.             // ==============================
  4068.         }
  4069.         if (existproperty(5, FIXES_gscOrderProperty))
  4070.         {
  4071.             if (!existproperty(5, FIXES_gscNoGMProperty) && _FIXES_gIsFilterscript == bool:getproperty(5, FIXES_gscOrderProperty))
  4072.             {
  4073.                 // The game mode is not in charge, which means we are checking
  4074.                 // the filterscripts a second time and shouldn't be.
  4075.                 return 0;
  4076.             }
  4077.             // If this script was previously the owner, and we are not ending
  4078.             // the game mode (in which case discard all data), and if we are
  4079.             // only dealing with filterscripts or the gamemode is now the
  4080.             // master.
  4081.             if (FIXES_gsSettings & (e_FIXES_SETTINGS_IN_CHARGE | e_FIXES_SETTINGS_DROP_ALL_DATA) == e_FIXES_SETTINGS_IN_CHARGE)
  4082.             {
  4083.                 FIXES_PRINTF("_FIXES_DetermineOrder: Was in charge");
  4084.                 // This script is currently in charge, but a new script has
  4085.                 // usurped it!  Pass all relevant data over to the new script.
  4086.                 // Also, this wasn't triggered by a game mode change (where we
  4087.                 // just want to dump and reset all data).  There is no need to
  4088.                 // reset the admin teleport data as that is always handled by
  4089.                 // the Game Mode, so it will either be correct, or it will be
  4090.                 // blank.
  4091.                 FIXES_gsSettings &= ~e_FIXES_SETTINGS_IN_CHARGE;
  4092.                 #if FIX_SetPlayerWorldBounds || FIX_TogglePlayerControllable
  4093.                     for (new i = 0; i != MAX_PLAYERS; ++i)
  4094.                     {
  4095.                         if (IsPlayerConnected(i))
  4096.                         {
  4097.                             // =============================
  4098.                             //  START: SetPlayerWorldBounds
  4099.                             // =============================
  4100.                             #if FIX_SetPlayerWorldBounds
  4101.                                 //if (FIXES_gsPlayerBools[i] & e_FIXES_BOOLS_WORLDBOUNDS)
  4102.                                 //{
  4103.                                 // I realised that you could have the GM in
  4104.                                 // charge, set their bounds, load an FS, remove
  4105.                                 // their bounds then unload the FS again and it
  4106.                                 // would result in the old GM setting of them
  4107.                                 // HAVING bounds being re-applied, so the check
  4108.                                 // was removed and.
  4109.                                 CallRemoteFunction(FIXES_gscSetPlayerWorldBounds, FIXES_gscSpec@iffff, i, FIXES_gsWorldbounds[i][E_FIXES_WORLDBOUND_DATA_UX], FIXES_gsWorldbounds[i][E_FIXES_WORLDBOUND_DATA_LX], FIXES_gsWorldbounds[i][E_FIXES_WORLDBOUND_DATA_UY], FIXES_gsWorldbounds[i][E_FIXES_WORLDBOUND_DATA_LY]);
  4110.                                 //}
  4111.                             #endif
  4112.                             // =============================
  4113.                             //  END:   SetPlayerWorldBounds
  4114.                             // =============================
  4115.                            
  4116.                             // =================================
  4117.                             //  START: TogglePlayerControllable
  4118.                             // =================================
  4119.                             #if FIX_TogglePlayerControllable
  4120.                                 CallRemoteFunction(FIXES_gscTogglePlayerControl, FIXES_gscSpec@ii, i, !(FIXES_gsPlayerBools[i] & e_FIXES_BOOLS_UNCONTROLLABLE));
  4121.                             #endif
  4122.                             // =================================
  4123.                             //  END:   TogglePlayerControllable
  4124.                             // =================================
  4125.                            
  4126.                             // ===========================
  4127.                             //  START: PutPlayerInVehicle
  4128.                             // ===========================
  4129.                             #if FIX_PutPlayerInVehicle
  4130.                                 if (FIXES_gsPlayerBools[i] & e_FIXES_BOOLS_PUT_IN_VEHICLE)
  4131.                                 {
  4132.                                     CallRemoteFunction(FIXES_gscPutPlayerInVehicle, FIXES_gscSpec@iii, i, FIXES_gsVehicleSeatData[i] & 0x00FFFFFF, FIXES_gsVehicleSeatData[i] >>> 24);
  4133.                                 }
  4134.                             #endif
  4135.                             // ===========================
  4136.                             //  END:   PutPlayerInVehicle
  4137.                             // ===========================
  4138.                         }
  4139.                     }
  4140.                 #endif
  4141.                 FIXES_PRINTF("_FIXES_DetermineOrder: Not in charge");
  4142.                 return 0;
  4143.             }
  4144.             else
  4145.             {
  4146.                 FIXES_gsSettings &= ~e_FIXES_SETTINGS_IN_CHARGE;
  4147.                 FIXES_PRINTF("_FIXES_DetermineOrder: Not in charge");
  4148.                 return 0;
  4149.             }
  4150.         }
  4151.         else if (!(FIXES_gsSettings & e_FIXES_SETTINGS_ENDING))
  4152.         {
  4153.             setproperty(5, FIXES_gscOrderProperty, _FIXES_gIsFilterscript);
  4154.             #if FIXES_Debug
  4155.                 if (FIXES_gsSettings & e_FIXES_SETTINGS_IN_CHARGE)
  4156.                 {
  4157.                     FIXES_PRINTF("_FIXES_DetermineOrder: Already in charge");
  4158.                 }
  4159.             #endif
  4160.             FIXES_gsSettings |= e_FIXES_SETTINGS_IN_CHARGE;
  4161.             FIXES_PRINTF("_FIXES_DetermineOrder: Now in charge");
  4162.             return 1;
  4163.         }
  4164.         #if FIXES_Debug
  4165.             else
  4166.             {
  4167.                 FIXES_PRINTF("_FIXES_DetermineOrder: Ending");
  4168.             }
  4169.         #endif
  4170.         return 0;
  4171.     }
  4172. #endif
  4173.  
  4174. /*
  4175.  * FIXES_strins(string[], const substr[], pos, maxlength = sizeof string)
  4176.  *
  4177.  * FIXES:
  4178.  *     strins
  4179.  */
  4180. #if FIX_strins
  4181.     stock FIXES_strins(string[], const substr[], pos, maxlength = sizeof string)
  4182.     {
  4183.         if (string[0] > 255)
  4184.         {
  4185.             new
  4186.                 strlength = strlen(string),
  4187.                 sublength = strlen(substr),
  4188.                 m4 = maxlength * 4;
  4189.             // Packed - format doesn't like these strings.
  4190.             if (strlength + sublength >= m4)
  4191.             {
  4192.                 if (pos + sublength >= m4)
  4193.                 {
  4194.                     string{pos} = '\0';
  4195.                     // Hopefully this doesn't ignore maxlength and does packed.
  4196.                     return strcat(string, substr, maxlength);
  4197.                 }
  4198.                 else
  4199.                 {
  4200.                     // pos + sublength is less than maxlength, so this sum MUST
  4201.                     // be positive and gte than "pos", so there's no need for
  4202.                     // additional checks.
  4203.                     string{maxlength - sublength - 1} = '\0';
  4204.                 }
  4205.             }
  4206.             return strins(string, substr, pos, maxlength);
  4207.         }
  4208.         else if (substr[0] > 255)
  4209.         {
  4210.             new
  4211.                 strlength = strlen(string),
  4212.                 sublength = strlen(substr);
  4213.             // Packed - format doesn't like these strings.
  4214.             if (strlength + sublength >= maxlength)
  4215.             {
  4216.                 if (pos + sublength >= maxlength)
  4217.                 {
  4218.                     string[pos] = '\0';
  4219.                     // Hopefully this doesn't ignore maxlength and does packed.
  4220.                     return strcat(string, substr, maxlength);
  4221.                 }
  4222.                 else
  4223.                 {
  4224.                     // pos + sublength is less than maxlength, so this sum MUST
  4225.                     // be positive and gte than "pos", so there's no need for
  4226.                     // additional checks.
  4227.                     string[maxlength - sublength - 1] = '\0';
  4228.                 }
  4229.             }
  4230.             return strins(string, substr, pos, maxlength);
  4231.         }
  4232.         else
  4233.         {
  4234.             return format(string, maxlength, "%.*s%s%s", pos, string, substr, string[pos]);
  4235.         }
  4236.     }
  4237.    
  4238.     #if defined _ALS_strins
  4239.         #undef strins
  4240.     #else
  4241.        
  4242.         native BAD_strins(string[], const substr[], pos, maxlength = sizeof string) = strins;
  4243.        
  4244.         #define _ALS_strins
  4245.     #endif
  4246.     #define strins FIXES_strins
  4247. #endif
  4248.  
  4249. #undef _FIXES_CEILDIV
  4250. #undef _FIXES_INFINITY
  4251. #undef _FIXES_N_INFINITY
  4252. #undef _FIXES_ATTACHMENTS
  4253. #undef FIXES_DETECT_CALLBACK_1
  4254. #undef FIXES_DETECT_CALLBACK_2
  4255. #undef FIXES_CALL_CALLBACK_1
  4256. #undef FIXES_CALL_CALLBACK_2
  4257. #undef FIXES_PRINTF
Add Comment
Please, Sign In to add comment