Y_Less

fixes.inc

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