Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Byg fixes + optimizations
Browse files Browse the repository at this point in the history
1.Updates to 'keep stuff','gang wars','fast reload' & 'no reload' checkbox
2.Changes some namings
3.Fixed an issue with money changer not allowing negative value
4.Fixed an issue where the overlay would appear in menu
5.Fixed issue with 'clear entries' not working in memory menu
6.Fixed an issue with teleport to interior.
7.Fixed an issue with CheckforUpdates function which caused the menu to crash when offline
8.Fixed an issue with money format geting bugged
9.Fixed an imgui issue which broke elements with same names
  • Loading branch information
inanahammad committed Oct 1, 2019
1 parent 63d7a4a commit f3dabd0
Show file tree
Hide file tree
Showing 18 changed files with 656 additions and 873 deletions.
79 changes: 47 additions & 32 deletions cheat-menu.lua
Expand Up @@ -21,7 +21,7 @@ script_url("https://forum.mixmods.com.br/f5-scripts-codigos/t1777-lua-cheat-menu
script_dependencies("ffi","mimgui","memory","MoonAdditions")
script_properties('work-in-pause')
script_version("1.7-staging")
script_version_number(28092019) -- DDMMYYYY
script_version_number(27092019) -- DDMMYYYY

-- All the command keys used throughout the Cheat-Menu
tkeys =
Expand All @@ -45,7 +45,6 @@ tkeys =

resX,resY = getScreenResolution()

-- Script Dependencies
ffi = require "ffi"
imgui = require 'mimgui'
memory = require 'memory'
Expand Down Expand Up @@ -84,6 +83,7 @@ if fmenu.tmenu.disable_in_samp[0] and isSampLoaded() then
script.this:unload()
end


tcheatmenu =
{
dir = Dir,
Expand All @@ -97,19 +97,15 @@ tcheatmenu =
show = imgui.new.bool(false),
title = string.format("%s v%s by %s",script.this.name,script.this.version,script.this.authors[1]),
},
menubuttons =
{
current = fconfig.get('tcheatmenu.menubuttons.current',1),
},
current_menu = fconfig.get('tcheatmenu.current_menu',1),

update =
{
available = false,
version_number = 0
},
}

fmenu.tmenu.overlay.position_array = imgui.new['const char*'][#fmenu.tmenu.overlay.position](fmenu.tmenu.overlay.position)

imgui.OnInitialize(function() -- Called once
-- Styles
imgui.PushStyleVarFloat(imgui.StyleVar.WindowBorderSize,0)
Expand Down Expand Up @@ -143,7 +139,7 @@ function(self) -- render frame
imgui.Spacing()
end

fcommon.UiCreateButtons({"Teleport","Memory","Player","Animation","Vehicle","Weapon","Peds","Mission","Game","Visual","Menu",
fcommon.CreateMenus({"Teleport","Memory","Player","Animation","Vehicle","Weapon","Peds","Mission","Game","Visual","Menu",
"About"},{fteleport.TeleportMain,fmemory.MemoryMain,fplayer.PlayerMain,fanimation.AnimationMain,fvehicle.VehicleMain,
fweapon.WeaponMain,fped.PedMain,fmission.MissionMain,fgame.GameMain,fvisual.VisualMain,fmenu.MenuMain,
fabout.AboutMain})
Expand All @@ -153,8 +149,8 @@ end)


imgui.OnFrame(function()
return fmenu.tmenu.overlay.show[0] and fmenu.tmenu.overlay.fps[0] and fmenu.tmenu.overlay.coordinates[0] and not isGamePaused()
or ((fmenu.tmenu.overlay.speed[0] or fmenu.tmenu.overlay.health[0]) and isCharInAnyCar(PLAYER_PED))
return not isGamePaused() and (fmenu.tmenu.overlay.show[0] and fmenu.tmenu.overlay.fps[0] and fmenu.tmenu.overlay.coordinates[0]
or ((fmenu.tmenu.overlay.speed[0] or fmenu.tmenu.overlay.health[0]) and isCharInAnyCar(PLAYER_PED)))
end,
function()
local io = imgui.GetIO()
Expand All @@ -179,7 +175,6 @@ function()
if fmenu.tmenu.overlay.fps[0] then
imgui.Text("Frames :" .. tostring(math.floor(imgui.GetIO().Framerate)))
end

if isCharInAnyCar(PLAYER_PED) then
car = getCarCharIsUsing(PLAYER_PED)
if fmenu.tmenu.overlay.speed[0] then
Expand Down Expand Up @@ -220,8 +215,8 @@ function()
end
if imgui.MenuItemBool("Close") then
fgame.tgame.fps.bool[0] = false
fvehicle.tvehicles.show.speed[0] = false
fvehicle.tvehicles.show.health[0] = false
fvehicle.tvehicle.show.speed[0] = false
fvehicle.tvehicle.show.health[0] = false
fvisual.tvisuals.show_coordinates[0] = false
end
imgui.EndPopup()
Expand Down Expand Up @@ -249,7 +244,28 @@ function main()
writeMemory(0x004384D1 ,4,0x000000D0 ,false)
writeMemory(0x004384D5 ,4,0x90909090 ,false)
end


switchArrestPenalties(fgame.tgame.keep_stuff[0])
switchDeathPenalties(fgame.tgame.keep_stuff[0])
setGangWarsActive(fped.tped.gang_wars[0])
setPlayerFastReload(PLAYER_HANDLE,fweapon.tweapon.fast_reload[0])

if fweapon.tweapon.no_reload[0] then
writeMemory( 7600773,1,144,1)
writeMemory( 7600815,1,144,1)
writeMemory( 7600816,2,37008,1)
writeMemory( 7612591,1,144,1)
writeMemory( 7612646,1,144,1)
writeMemory( 7612647,2,37008,1)
else
writeMemory( 7600773,1,72,1)
writeMemory( 7600815,1,255,1)
writeMemory( 7600816,2,3150,1)
writeMemory( 7612591,1,72,1)
writeMemory( 7612646,1,255,1)
writeMemory( 7612647,2,3150,1)
end

while true do

if fanimation.tanimation.ped[0] == true or fweapon.tweapon.ped[0] == true then
Expand Down Expand Up @@ -281,7 +297,7 @@ function main()
fcommon.KeyWait(tkeys.teleport_key1,tkeys.teleport_key2)
fteleport.Teleport()
end

setCharProofs(PLAYER_PED,fplayer.tplayer.god[0],fplayer.tplayer.god[0],fplayer.tplayer.god[0],fplayer.tplayer.god[0],fplayer.tplayer.god[0])

if fplayer.tplayer.aimSkinChanger[0] and isKeyDown(tkeys.asc_key) then
Expand All @@ -294,7 +310,7 @@ function main()
end

if isKeyDown(tkeys.control_key) and isKeyDown(tkeys.quickspawner_key) then
if (fvehicle.tvehicles.quick_spawn[0] or fweapon.tweapons.quick_spawn[0]) then
if (fvehicle.tvehicle.quick_spawn[0] or fweapon.tweapon.quick_spawn[0]) then
fcommon.QuickSpawner()
end
end
Expand All @@ -304,41 +320,40 @@ function main()
lua_thread.create(fvehicle.AircraftCamera)
end

-- Vehicle related stuff which is required to run every frame
if isCharInAnyCar(PLAYER_PED) then
car = getCarCharIsUsing(PLAYER_PED)

if fvehicle.tvehicles.color.default ~= -1 then
if fvehicle.tvehicle.color.default ~= -1 then
local color_id = getCarColours(car)
if fvehicle.tvehicles.color.default ~= color_id then
if fvehicle.tvehicle.color.default ~= color_id then
fvehicle.ForEachCarComponent(function(mat)
mat:reset_color()
end)
end
end

setCarCanBeDamaged(car,not(fvehicle.tvehicles.no_damage[0]))
setCharCanBeKnockedOffBike(PLAYER_PED,fvehicle.tvehicles.stay_on_bike[0])
setCarHeavy(car,fvehicle.tvehicles.heavy[0])
setCarCanBeDamaged(car,not(fvehicle.tvehicle.no_damage[0]))
setCharCanBeKnockedOffBike(PLAYER_PED,fvehicle.tvehicle.stay_on_bike[0])
setCarHeavy(car,fvehicle.tvehicle.heavy[0])

if fvehicle.tvehicles.lock_speed[0] then
if fvehicle.tvehicles.speed[0] > 500 then
fvehicle.tvehicles.speed[0] = 500
if fvehicle.tvehicle.lock_speed[0] then
if fvehicle.tvehicle.speed[0] > 500 then
fvehicle.tvehicle.speed[0] = 500
end
setCarForwardSpeed(car,fvehicle.tvehicles.speed[0])
setCarForwardSpeed(car,fvehicle.tvehicle.speed[0])
end

setCarCanBeVisiblyDamaged(car,not(fvehicle.tvehicles.visual_damage[0]))
setCarCanBeVisiblyDamaged(car,not(fvehicle.tvehicle.visual_damage[0]))


if getCarDoorLockStatus(car) == 4 then
fvehicle.tvehicles.lock_doors[0] = true
fvehicle.tvehicle.lock_doors[0] = true
else
fvehicle.tvehicles.lock_doors[0] = false
fvehicle.tvehicle.lock_doors[0] = false
end
else
fvehicle.tvehicles.lock_doors[0] = false
fvehicle.tvehicles.lights.all[0] = false
fvehicle.tvehicle.lock_doors[0] = false
fvehicle.tvehicle.lights[0] = false
end

wait(0)
Expand Down
2 changes: 1 addition & 1 deletion lib/cheat-menu/modules/about.lua
Expand Up @@ -23,7 +23,7 @@ function module.AboutMain()
imgui.BulletText(string.format("Version number : %d",script.this.version_num))
imgui.SameLine()
if imgui.Button("Check for update",imgui.ImVec2(120,20)) then
fupdate.CheckUpdates()
lua_thread.create(fupdate.CheckUpdates)
end
imgui.BulletText(string.format("Author : %s",script.this.authors[1]))
imgui.BulletText(string.format("Imgui : v%s",imgui._VERSION))
Expand Down
79 changes: 39 additions & 40 deletions lib/cheat-menu/modules/animation.lua
Expand Up @@ -16,31 +16,30 @@

local module = {}

local tanimation =
module.tanimation =
{
loop = imgui.new.bool(fconfig.get('tanimation.loop',false)),
secondary = imgui.new.bool(fconfig.get('tanimation.secondary',false)),
search_text = imgui.new.char[20](),
name = imgui.new.char[20](),
ifp_name = imgui.new.char[20](),
fighting =
fighting =
{
selected = imgui.new.int(fconfig.get('tanimation.fighting.selected',0)),
names = {"Default","Boxing","Kung fu","Kick Boxing","Punch Kick"},
list = {},
selected = imgui.new.int(fconfig.get('tanimation.fighting.selected',0)),
names = {"Default","Boxing","Kung fu","Kick Boxing","Punch Kick"},
array = {},
},
ifp_name = imgui.new.char[20](),
loop = imgui.new.bool(fconfig.get('tanimation.loop',false)),
name = imgui.new.char[20](),
ped = imgui.new.bool(fconfig.get('tanimation.ped',false)),
secondary = imgui.new.bool(fconfig.get('tanimation.secondary',false)),
search_text = imgui.new.char[20](),
walking =
{
selected = imgui.new.int(fconfig.get('tanimation.walking.selected',0)),
names = {"man","shuffle","oldman","gang1","gang2","oldfatman","fatman","jogger","drunkman","blindman","swat","woman","shopping","busywoman","sexywoman","pro","oldwoman","fatwoman","jogwoman","oldfatwoman","skate"},
array = {},
},
walking =
{
selected = imgui.new.int(fconfig.get('tanimation.walking.selected',0)),
names = {"man","shuffle","oldman","gang1","gang2","oldfatman","fatman","jogger","drunkman","blindman","swat","woman","shopping","busywoman","sexywoman","pro","oldwoman","fatwoman","jogwoman","oldfatwoman","skate"},
list = {},
},
ped = imgui.new.bool(fconfig.get('tanimation.ped',false)),
}
module.tanimation = tanimation

tanimation.fighting.list = imgui.new['const char*'][#tanimation.fighting.names](tanimation.fighting.names)
tanimation.walking.list = imgui.new['const char*'][#tanimation.walking.names](tanimation.walking.names)
module.tanimation.fighting.array = imgui.new['const char*'][#module.tanimation.fighting.names](module.tanimation.fighting.names)
module.tanimation.walking.array = imgui.new['const char*'][#module.tanimation.walking.names](module.tanimation.walking.names)


function AnimationEntry(file,animation)
Expand All @@ -55,7 +54,7 @@ function AnimationEntry(file,animation)
end

function PlayAnimation(file,animation)
if fanimation.tanimation.ped[0] == true then
if module.tanimation.ped[0] == true then
if fped.tped.selected ~= nil then
char = fped.tped.selected
else
Expand All @@ -66,10 +65,10 @@ function PlayAnimation(file,animation)
char = PLAYER_PED
end

if tanimation.secondary[0] == true then
taskPlayAnimSecondary(char,animation,file,4.0,tanimation.loop[0],0,0,0,-1)
if module.tanimation.secondary[0] == true then
taskPlayAnimSecondary(char,animation,file,4.0,module.tanimation.loop[0],0,0,0,-1)
else
taskPlayAnim(char,animation,file,4.0,tanimation.loop[0],0,0,0,-1)
taskPlayAnim(char,animation,file,4.0,module.tanimation.loop[0],0,0,0,-1)
end
fcommon.CheatActivated()
if file ~= "ped" then
Expand All @@ -82,7 +81,7 @@ function module.AnimationMain()
imgui.Spacing()
if imgui.Button("Stop animation",imgui.ImVec2(fcommon.GetSize(1))) then
local char = nil
if fanimation.tanimation.ped[0] == true then
if module.tanimation.ped[0] == true then
if fped.tped.selected ~= nil then
char = fped.tped.selected
else
Expand All @@ -97,10 +96,10 @@ function module.AnimationMain()
end
imgui.Spacing()
imgui.Columns(2,nil,false)
fcommon.CheckBox({name = "Loop",var = tanimation.loop})
fcommon.CheckBox({name = "Ped",var = tanimation.ped,help_text = "Play animation on ped.Aim with a gun to select."})
fcommon.CheckBox({name = "Loop",var = module.tanimation.loop})
fcommon.CheckBox({name = "Ped",var = module.tanimation.ped,help_text = "Play animation on ped.Aim with a gun to select."})
imgui.NextColumn()
fcommon.CheckBox({name = "Secondary",var = tanimation.secondary})
fcommon.CheckBox({name = "Secondary",var = module.tanimation.secondary})
imgui.Columns(1)
imgui.Spacing()
if imgui.BeginTabBar("Animation") then
Expand Down Expand Up @@ -135,17 +134,17 @@ function module.AnimationMain()

imgui.Spacing()
imgui.Columns(1)
if imgui.InputText("Search",tanimation.search_text,ffi.sizeof(tanimation.search_text)) then end
if imgui.InputText("Search",module.tanimation.search_text,ffi.sizeof(module.tanimation.search_text)) then end
imgui.SameLine()

imgui.Spacing()
imgui.Text("Found entries :(" .. ffi.string(tanimation.search_text) .. ")")
imgui.Text("Found entries :(" .. ffi.string(module.tanimation.search_text) .. ")")
imgui.Separator()
imgui.Spacing()
if imgui.BeginChild("Stat Entries") then
for key,value in pairs(ftable.animation.table) do
file, animation = value:match("([^$]+)$([^$]+)")
if (string.upper(animation):find(string.upper(ffi.string(tanimation.search_text)))) then
if (string.upper(animation):find(string.upper(ffi.string(module.tanimation.search_text)))) then
AnimationEntry(file,animation)
end
end
Expand All @@ -158,28 +157,28 @@ function module.AnimationMain()


if imgui.BeginTabItem("Misc") then
if imgui.Combo("Fighting", tanimation.fighting.selected,tanimation.fighting.list,#tanimation.fighting.names) then
giveMeleeAttackToChar(PLAYER_PED,tanimation.fighting.selected[0]+4,6)
if imgui.Combo("Fighting", module.tanimation.fighting.selected,module.tanimation.fighting.array,#module.tanimation.fighting.names) then
giveMeleeAttackToChar(PLAYER_PED,module.tanimation.fighting.selected[0]+4,6)
fcommon.CheatActivated()
end
if imgui.Combo("Walking", tanimation.walking.selected,tanimation.walking.list,#tanimation.walking.names) then
if imgui.Combo("Walking", module.tanimation.walking.selected,module.tanimation.walking.array,#module.tanimation.walking.names) then
writeMemory(0x609A4E,4,-1869574000,true)
writeMemory(0x609A52,2,37008,true)
requestAnimation(tanimation.walking.names[tanimation.walking.selected[0]+1])
requestAnimation(module.tanimation.walking.names[module.tanimation.walking.selected[0]+1])
loadAllModelsNow()
setAnimGroupForChar(PLAYER_PED,tanimation.walking.names[tanimation.walking.selected[0]+1])
removeAnimation(tanimation.walking.names[tanimationwalking.selected[0]+1])
setAnimGroupForChar(PLAYER_PED,module.tanimation.walking.names[module.tanimation.walking.selected[0]+1])
removeAnimation(module.tanimation.walking.names[module.tanimation.walking.selected[0]+1])
fcommon.CheatActivated()
end
imgui.EndTabItem()
end

if imgui.BeginTabItem("Custom") then
if imgui.InputText("IFP name",tanimation.ifp_name,ffi.sizeof(tanimation.ifp_name)) then end
if imgui.InputText("Animation name",tanimation.name,ffi.sizeof(tanimation.name)) then end
if imgui.InputText("IFP name",module.tanimation.ifp_name,ffi.sizeof(module.tanimation.ifp_name)) then end
if imgui.InputText("Animation name",module.tanimation.name,ffi.sizeof(module.tanimation.name)) then end
imgui.Spacing()
if imgui.Button("Play animation",imgui.ImVec2(fcommon.GetSize(1))) then
PlayAnimation(ffi.string(tanimation.ifp_name),ffi.string(tanimation.name))
PlayAnimation(ffi.string(module.tanimation.ifp_name),ffi.string(module.tanimation.name))
end
imgui.EndTabItem()
end
Expand Down

0 comments on commit f3dabd0

Please sign in to comment.