0% found this document useful (0 votes)
8 views4 pages

CLEO5 Script for GTA SA Pool Info

Uploaded by

mbedeyyacine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

CLEO5 Script for GTA SA Pool Info

Uploaded by

mbedeyyacine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// CLEO5 example script

// Sanny Builder 4
// mode: GTA SA (v1.0 - SBL)
{$CLEO .cs}

script_name {name} "lim_info"

// In case the limits adjuster is used, pools can have really big sizes.
// Iterating through all elements can really create a performance hit.
// The proper solution would be to draw stats on every frame from stats saved in
variables,
// and update these stats by processing pools only once every few seconds.
const Pool_Size_Cap = 1111 // walk around, just do not parse all contents of bigger
pools

int active = false

while true
if
test_cheat "limits"
then
active = true - active // toggle
end

if
active == false
then
wait 500
continue
end

use_text_commands {state} true

float pos = 120.0


pos = DRAW_MISSION_CLEANUP_LIST_INFO(pos)
//pos = DRAW_POOL_INFO(0x00965560, "Collisions %d/%d", pos) //
CColStore::ms_pColPool
//pos = DRAW_POOL_INFO(0x0096A7D8, "EntryExit %d/%d", pos) //
CEntryExitManager::mp_poolEntryExits
//pos = DRAW_POOL_INFO(0x008E3FB0, IPLs %d/%d", pos) // CIplStore::ms_pPool
pos = DRAW_POOL_INFO(0x00B74490, "Peds %d/%d", pos) // CPools::ms_pPedPool
//pos = DRAW_POOL_INFO(0x00B744A8, "Ped tasks %d/%d", pos) //
CPools::ms_pTaskPool
//pos = DRAW_POOL_INFO(0x00B744C0, "Ped brains %d/%d", pos) //
CPools::ms_pPedIntelligencePool
pos = DRAW_POOL_INFO(0x00B7449C, "Objects %d/%d", pos) //
CPools::ms_pObjectPool
pos = DRAW_POOL_INFO(0x00B74494, "Vehicles %d/%d", pos) //
CPools::ms_pVehiclePool

wait 0
end

terminate_this_script

function DRAW_COUNT_LINE(vPos: float, txt: string, count: int, total: int): float

set_text_right_justify {state} true


set_text_scale {widthScale} 0.25 {heightScale} 1.0
set_text_edge {size} 1 {red} 0 {green} 0 {blue} 0 {alpha} 240
SET_TEXT_COLOR(count, total)
display_text_formatted {offsetLeft} 635.0 {offsetTop} vPos {format} txt {args}
count total

vPos += 10.0
return vPos
end

function DRAW_MISSION_CLEANUP_LIST_INFO(vPos: float): float


int count = read_memory_with_offset {address} 0x00A90850 {offset} 0x258 {size}
1 // CTheScripts::MissionCleanUp.m_Count
int size = 75 // CMissionCleanup max size

vPos = DRAW_COUNT_LINE(vPos, "Mission Cleanup %d/%d", count, size)


return vPos
end

function DRAW_POOL_INFO(poolAddres: int, txt: string, vPos: float): float


int count, size
count, size = GET_POOL_INFO(poolAddres)

vPos = DRAW_COUNT_LINE(vPos, txt, count, size)

return vPos
end

// blend color from green to red


function SET_TEXT_COLOR(count: int, size: int)
//float countF, sizeF
float countF =# count
float sizeF =# size

float val = countF


val /= sizeF

// clamp
if
val < 0.0
then
val = 0.0
end
if
val > 1.0
then
val = 1.0
end

int r, g
if
val < 0.5
then
// green to orange
val *= 2.0 // 0.0 to 0.5 -> 0.0 to 1.0
val *= 255.0
r =# val // to int

g = 255
else
// orange to red
r = 255

// 0.5 to 1.0 -> 1.0 to 0.0


val *= -2.0
val += 2.0

val *= 255.0
g =# val // to int
end

// brightness
r /= 2
g /= 2
r += 127
g += 127

set_text_colour {red} r {green} g {blue} 128 {alpha} 255


end

function GET_POOL_INFO(address: int): int, int


int pool = read_memory address {size} 4 {vp} false // dereference pointer
if
pool == 0
then
return 0 0
end

int size = read_memory_with_offset {address} pool {offset} 0x8 {size} 4 //


CPool::m_nSize

// for performance reasons do not iterate through all elements of realy big
pools
int processSize
if
size < Pool_Size_Cap
then
processSize = size
else
processSize = Pool_Size_Cap
end

// count empty slots


int byteMap = read_memory_with_offset {address} pool {offset} 0x4 {size} 4 //
CPool::m_byteMap

int count = 0
int i = 0
while i < processSize
int flags = read_memory_with_offset {address} byteMap {offset} i {size}
1 // tPoolObjectFlags
if
not is_local_var_bit_set_const {number} flags {n} 7 //
tPoolObjectFlags::bEmpty
then
count += 1
end

i += 1
end

return count size


end

Common questions

Powered by AI

The script uses the function `GET_POOL_INFO`, which reads the memory address of a pool to determine its size and the number of elements currently used. For pools that exceed the set `Pool_Size_Cap`, only the capped size is processed. It calculates the number of occupied slots by iterating over a byte map that flags whether each slot is empty or not, incrementing a count for each occupied slot. These values are then displayed using the `DRAW_COUNT_LINE` function .

The graphical position for displaying pool information is managed through a float variable `pos`. Initial position is set to a specific value (120.0 in this case), and as each pool's information is drawn, the position is updated by the `DRAW_COUNT_LINE` function, which increments the position by 10.0 after drawing each line of text, ensuring that the displayed information appears sequentially on the screen without overlap .

The `TERMINATE_THIS_SCRIPT` command is used to stop the execution of the script. Within this script's context, it serves as an endpoint, effectively ceasing all operations specified in the script after execution conditions are fulfilled or when it's no longer necessary to run the script, ensuring resources are not wasted on unnecessary processes .

The `processSize` variable is utilized to determine the number of slots to iterate over, capping it to `Pool_Size_Cap` when the pool size exceeds this limit. This variable ensures the script does not exceed handling an excessive number of elements, which could degrade performance. By limiting the iteration size, it effectively prevents unnecessary processing overhead associated with large pools, aiding in maintaining script efficiency and responsiveness .

When handling pool sizes larger than the preset capacity (`Pool_Size_Cap`), the script caps the processing size to the limit instead of iterating over every element. This decision is important for performance reasons, as iterating through a very large number of pool elements could cause significant slowdowns. By limiting the processing to only manageable chunks, the script maintains efficiency without overloading the system .

The script toggles the active state of displaying limits information based on the detection of a specific cheat code 'limits'. Initially, the script continuously checks if the cheat has been activated, toggling the `active` variable between true and false each time the cheat is detected. This toggle enables or disables the on-screen display depending on the state, with the script waiting to update until the next detection .

The script uses color coding to visually indicate pool usage, transitioning from green to red based on the ratio of used to total slots. The function `SET_TEXT_COLOR` blends colors, turning the text green when usage is low, orange at medium usage, and red when nearly full. This is achieved by adjusting RGB values based on the usage ratio, which are then set for the on-screen display text color .

Large pool sizes can significantly impact performance in script loops due to the necessity to iterate over all elements, which can be computationally expensive. The script proposes a solution by drawing stats on every frame from variables and updating these stats by processing pools only once every few seconds, instead of continuously iterating through all elements of larger pools. This approach helps in reducing the performance hit associated with large pool sizes .

The `DRAW_MISSION_CLEANUP_LIST_INFO` function reads the current count and maximum size of mission cleanup entries from memory, and displays this information on the screen. Its purpose is to provide visual feedback on mission cleanup status, allowing the user to monitor how many cleanup entries are active compared to the limit. This contributes to the script's functionality by offering real-time update capabilities of critical game data during script execution .

The script determines if a pool slot is empty or occupied by evaluating each slot's flags stored in the byte map using the `is_local_var_bit_set_const` function. This checks whether the specific flag `bEmpty` is set or not for each slot. The count of occupied slots is incremented for each non-empty slot. This mechanism plays a crucial role in assessing pool usage stats by accurately determining the number of active slots compared to the pool's total capacity .

You might also like