Created
April 23, 2019 03:54
-
-
Save SunShineSilver-mdA/5075d233147b403cdd75107492cb0a98 to your computer and use it in GitHub Desktop.
CE Lua Example Global Handle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[--->--->--->--->--->--->--->--->--->--->--->--->--->--->-->--> | |
############################################################## | |
####### How To Get/Set the Global Handle with CE in Lua ###### | |
############################################################## | |
--->]] | |
local Tick=0;function __GetGTA5Process() | |
if openProcess('GTA5.exe') | |
then sleep(100);if getOpenedProcessID()==0 | |
then getAutoAttachList().add('GTA5.exe');sleep(100); | |
if getOpenedProcessID()==0 and Tick>5 | |
then Tick=Tick+1;__GetGTA5Process();end | |
end | |
end | |
end | |
function __GetAddressPointer(Mode) | |
__GetGTA5Process() | |
if Mode=='SA' --[[<-only SC..you need to replace with Steam version]] | |
then--[[-> via'Static (Address Pointer)']] | |
GlobalPTR=getAddress('GTA5.exe+0x02D09D10'); | |
elseif Mode=='AOB' | |
then--[[-> ' via AS[AOB] (Address Pointer)' ]] | |
autoAssemble([[ | |
aobscanmodule(GlobalPTR,GTA5.exe,4C 8D 05 ? ? ? ? 4D 8B 08 4D 85 C9 74 11) | |
registerSymbol(GlobalPTR)]]) | |
GlobalPTR=getAddress('GlobalPTR');GlobalPTR=GlobalPTR+readInteger(GlobalPTR+0x03)+0x07; | |
unregisterSymbol('GlobalPTR');registerSymbol('GlobalPTR',GlobalPTR,true); | |
else ShowPopUpMessage(_Title,'Failed to find Address..',_ShowTime); return end | |
ShowPopUpMessage(_Title,string.format('Found: %s 0x%0X (via %s)','GlobalPTR',GlobalPTR,Mode),_ShowTime); | |
end | |
--[[############################################################## | |
-->load at the beginning(once) -> __GetAddressPointer('SA'); ]] | |
--[[############################################################## | |
--->...no switch case in lua??? | |
a lie..! If you are smart enough, | |
then you can create your own 'switch case function'! | |
--]] | |
function switch(s,...) for _,v in ipairs {...} do if v[1]==s or v[1]==nil then return v[2]();end end end | |
function case(s,fc) return {s,fc};end | |
function default(fc) return {nil,fc};end | |
function Get_Global_Address(AtIndex)return readQword(GlobalPTR+(8*(AtIndex>>0x12&0x3F)))+(8*(AtIndex&0x3FFFF));end | |
function _GetGlobal(AsType,AtIndex)__='FALSE' | |
--[[############################################################## | |
------------------------------------------------------------->]] | |
switch(AsType, | |
case("Qword", function()__res=readQword(Get_Global_Address(AtIndex))end), | |
case("Integer", function()__res=readInteger(Get_Global_Address(AtIndex))end), | |
case("Word", function()__res=readSmallInteger(Get_Global_Address(AtIndex))end), | |
case("Byte", function()__res=readBytes(Get_Global_Address(AtIndex))end), | |
case("Float", function()__res=string.format("%.2f",readFloat(Get_Global_Address(AtIndex)))end), | |
case("String", function()__res=readString(Get_Global_Address(AtIndex))end), | |
default( function()__res=Get_Global_Address(AtIndex)end) | |
);return __res;end | |
--[[############################################################## | |
------------------------------------------------------------->]] | |
function _SetGlobal(AsType,AtIndex,Value)__='TRUE' | |
switch(AsType, | |
case("Qword", function()writeQword(Get_Global_Address(AtIndex),Value)end), | |
case("Integer", function()writeInteger(Get_Global_Address(AtIndex),Value)end), | |
case("Word", function()writeSmallInteger(Get_Global_Address(AtIndex),Value)end), | |
case("Byte", function()writeBytes(Get_Global_Address(AtIndex),Value)end), | |
case("Float", function()writeFloat(Get_Global_Address(AtIndex),Value)end), | |
case("String", function()writeString(Get_Global_Address(AtIndex),Value)end), | |
default(function()__='FALSE';end) | |
);return __;end | |
--> if _SetGlobal('Word',262145+4721,1)=='TRUE' then | |
-- ShowPopUpMessage(_Title,string.format('Result: %s ','TRUE'),_ShowTime); | |
-- else ShowPopUpMessage(_Title,string.format('Result: %s ','FALSE'),_ShowTime);end | |
--> ShowPopUpMessage(_Title,string.format('Result: %i ',_GetGlobal('Word',262145+4721)),_ShowTime); -- return the result | |
--> ShowPopUpMessage(_Title,string.format('Result: %s ',_SetGlobal('Word',262145+4721,0)),_ShowTime); -- return 'TRUE' or 'FALSE' | |
--[[############################################################## | |
------------------------------------------------------------->]] | |
--#CHandle *Example of a small Class Object for the Globals-> | |
function CHandle() | |
local _this = | |
{ | |
--[[Tuneables: Unlocks, etc. in -> 'tuneables_processing.ysc' ]] | |
Tuneables=262145,Snow=4721, | |
--[[Protections: Kicks,Invites, etc. in 'freemode.ysc' ]] | |
ScriptEvents=1382674,CellPhoneInv=33,TpToApartment=499,CeoKick=536,CeoBan=558, | |
RemoteKickA=609,SendToMission=677, | |
--[[Player Stats: Money,Rank, etc. in 'freemode.ysc' ]] | |
OnlineStats=1589747,f_790=790,f_211=211,XP=1,WalletMoney=3,Rank=6,Shoots=24,Hits=25, | |
--[[...and many more in 'freemode.ysc',(...)! ]] | |
} | |
return _this | |
end | |
-- ShowPopUpMessage(_Title,string.format('Result: %i ',_GetGlobal('Word',CHandle().ScriptEvents+CHandle().RemoteKickA)),_ShowTime); | |
-- ShowPopUpMessage(_Title,string.format('Result: %s ',_SetGlobal('Word',CHandle().ScriptEvents+CHandle().RemoteKickA,1)),_ShowTime); | |
-- ShowPopUpMessage(_Title,string.format('Result: %i ',_GetGlobal('Word',CHandle().Tuneables+CHandle().Snow)),_ShowTime); | |
-- ShowPopUpMessage(_Title,string.format('Result: %s ',_SetGlobal('Word',CHandle().Tuneables+CHandle().Snow,0)),_ShowTime); | |
--[[############################################################## | |
------------------------------------------------------------->]] | |
--#TCOMP *Table Compare Function-> | |
function TCOMP(T,C,...) for K,V in pairs(C) do T[K]=V end if select('#',...)>0 then return TCOMP(T,...) else return T end end | |
function ShowPopUpMessage(TitleText,InfoText,Time) | |
--#Form-> | |
local PopUpForm=createForm(false); | |
TCOMP(PopUpForm,{AutoSize=true,Position='poScreenCenter', --[[Width=180,Height=115,]] | |
BorderStyle='bsNone',FormStyle='fsStayOnTop',Color='clBlack',OnClick=PopUpForm.hide}); | |
--#Label_Title-> | |
local Label_Title=createLabel(PopUpForm); | |
TCOMP(Label_Title,{Top=0,Left=10,Caption=TitleText,Color='clNone',Transparent=true}); | |
-->#Font-> | |
local PF1=Label_Title.Font;Label_Title.BorderSpacing.Around=20; | |
TCOMP(PF1,{Color=0xE63C98,Size=13,Height=-18,Anchors='[akTop]',Name='Cambria',Style='[fsBold,fsUnderline]',Pitch='fpFixed'}); | |
--#Label_Info-> | |
local Label_Info=createLabel(PopUpForm); | |
TCOMP(Label_Info,{Top=Label_Title.Top+40,Left=Label_Title.Left+20,Caption=InfoText..'\n',Color='clNone',Transparent=true}); | |
-->#Font-> | |
local PF2=Label_Info.Font;Label_Info.BorderSpacing.Around=20; | |
TCOMP(PF2,{Color=0x00ff50,Size=10,Height=-14,Name='Tahoma',Style='[fsBold]',Pitch='fpFixed'}); | |
--#Timer-> | |
local PopUp=createTimer(PopUpForm); | |
TCOMP(PopUp,{Interval=Time,OnTimer=PopUpForm.destroy}); | |
PopUpForm.show() | |
end | |
_ShowTime=3000; | |
_Title='SunShineSilver.mdA ShowPopUpMessage:\n\n\n'; | |
--[[############################################################## | |
------------------------------------------------------------->]] | |
--[[ Clean Code in Lua Engine Console ]]local LuaCon=GetLuaEngine(); | |
LuaCon.cbShowOnPrint.Checked=true;LuaCon.centerScreen(); | |
LuaCon.mOutput.Lines.Clear();LuaCon.show(); | |
--[[############################################################## | |
------------------------------------------------------------->]] | |
--[[--> FIRST LOAD -->]]__GetAddressPointer('AOB'); | |
--[[MIA @SunShineSilver.mdA 2019-04-23]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment