Y_Less

fixes.inc

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