Skip to content

Instantly share code, notes, and snippets.

@nathan130200
Last active June 6, 2021 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathan130200/cd3266e2b8ecc22e56c0a25c324ff34c to your computer and use it in GitHub Desktop.
Save nathan130200/cd3266e2b8ecc22e56c0a25c324ff34c to your computer and use it in GitHub Desktop.
GTA: San Andreas - Impossible Mod to Play in History Mode
local cfg = require 'inicfg'
local config = {}
function main()
initConfig()
while not isPlayerPlaying(playerChar) do
wait(500)
end
requestModel(config.weapon.model)
loadAllModelsNow()
while not hasModelLoaded(config.weapon.model) do
wait(500)
loadAllModelsNow()
end
if config.health_restore.enabled then
lua_thread.create(restoreHealth)
end
while true do
if (not config.filters.skip_interiors and getActiveInterior() ~= 0) or getActiveInterior() == 0 then
lua_thread.create(function()
local ped = -1
while true do
local x, y, z = getCharCoordinates(playerPed)
ped = findPedInSphere(x, y, z, config.query.distance, function(x)
if isMissionPed(x) and config.filters.skip_mission_peds then
return false
end
if isCharInAnyCar(x) and config.filters.skip_incar_peds then
return false
end
return true
end)
if doesCharExist(ped) then
break
end
wait(250)
end
pcall(function()
giveWeaponToChar(ped, config.weapon.id, 10)
setCharWeaponSkill(ped, config.weapon.skill)
wait(250)
taskKillCharOnFoot(ped, playerPed)
end)
wait(250)
end)
end
wait(config.query.interval)
end
end
function restoreHealth()
while true do
setCharHealth(playerPed, getCharHealth(playerPed) + config.health_restore.amount)
wait(config.health_restore.interval)
end
end
function initConfig()
local obj = {
weapon = {skill = 1, model = 345, id = 36},
health_restore = {enabled = true, interval = 750, amount = 2},
query = {distance = 250, interval = 1500},
filters = {skip_mission_peds = true, skip_incar_peds = true, skip_interiors = true}
}
local impl = cfg.load(obj, 'crazy_peds')
union(obj, impl)
cfg.save(obj, 'crazy_peds')
config = obj
end
---Merge two tables.
---@param a table
---@param b table
---@return table
function union(a, b)
local result = {}
for k, v in pairs(a) do
table.insert(result, v)
end
for k, v in pairs(b) do
table.insert(result, v)
end
return result
end
function findPedInSphere(x, y, z, r, filter)
local res, ped = findAllRandomCharsInSphere(x, y, z, r, true, true)
if res and filter(ped) then
return ped
end
return nil
end
function isMissionPed(ped, special)
if ped == nil or not doesCharExist(ped) then
return false
end
local type = getPedType(ped)
for i = 24, 31, 1 do
if type == i then
return true
end
end
if (special or false) and type == 22 then
return true
end
return false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment