Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more example scripts. #231

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions examples/Limits_Info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// CLEO5 example script
// Sanny Builder 4
// mode: GTA SA (v1.0 - SBL)
{$CLEO .cs}

script_name {name} "lim_info"

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

// 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 < size
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
96 changes: 96 additions & 0 deletions examples/Sounds_Browser.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// CLEO5 example script
// Sanny Builder 4
// mode: GTA SA (v1.0 - SBL)
{$CLEO .cs}

script_name {name} "sound_br"

int soundId = 1000
int keyWasDown = false
while true
wait 0

print_formatted_now "Sound id: %d~n~Press ~y~<~s~ and ~y~>~s~ to browse,~n~hold ~y~SHIFT~s~ to browse faster.~n~Press ~y~?~s~ to play again." {time} 1 {args} soundId

// handle browse keys
if or
is_key_pressed {keyCode} KeyCode.OemComma // <
is_key_pressed {keyCode} KeyCode.OemPeriod // >
then
keyWasDown = true

int step
if
is_key_pressed {keyCode} KeyCode.OemPeriod
then
step = 1
else
step = -1
end
if
is_key_pressed {keyCode} KeyCode.Shift
then
step *= 10
end
soundId += step

// warp around if out of bounds
if
soundId < 1000
then
soundId = 1190
end
if
soundId > 1190
then
soundId = 1000
end

// wait for key release or timeout
while true
if and
not is_key_pressed {keyCode} KeyCode.OemComma // <
not is_key_pressed {keyCode} KeyCode.OemPeriod // >
then
break // keys released
end

if
TimerA > 30 // auto repeat time in miliseconds
then
TimerA = 0
break
end

wait 0
end

continue
end

// handle play key
if
is_key_pressed {keyCode} KeyCode.Oem2 // ? key
then
keyWasDown = true

wait 50
continue
end

if
keyWasDown == true
then
float x, y, z
x, y, z = get_char_coordinates $scplayer

add_one_off_sound {pos} x y z {soundId} soundId

keyWasDown = false
end

// keys are up
TimerA = -200 // extra delay before auto repeat activates
end

terminate_this_script
102 changes: 102 additions & 0 deletions examples/Train_Spawner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// CLEO5 example script
// Sanny Builder 4
// mode: GTA SA (v1.0 - SBL)
{$CLEO .cs}

script_name {name} "train_sp"

int trainType = -1

while true
wait 333

int area = get_area_visible

if and
test_cheat "train"
is_player_control_on $player1
area == 0 // overworld
then
float pos[3]
pos[0], pos[1], pos[2] = get_char_coordinates $scplayer

warp_char_from_car_to_coord $scplayer {pos} pos[0] pos[1] pos[2] // remove player from car if in any
delete_mission_trains

// get next train type
trainType += 1
if
trainType > 15
then
trainType = 0
end

int trainHandle = TRAIN_CREATE(trainType, pos[0], pos[1], pos[2], false)

// set colors to the engine and all carriages
int color1 = generate_random_int_in_range {min} 0 {max} 8
int color2 = generate_random_int_in_range {min} 0 {max} 8
TRAIN_PAINT(trainHandle, color1, color2)

warp_char_into_car $scplayer {vehicle} trainHandle
set_train_speed trainHandle {speed} 5.0

point_camera_at_car {vehicle} trainHandle {mode} CameraMode.CamOnAString {switchStyle} SwitchType.JumpCut
restore_camera

print_help_formatted {text} "Train type: %d~n~Colors: %d, %d" {args} trainType color1 color2
end
end

terminate_this_script


function TRAIN_CREATE(type :int, posX :int, posY :int, posZ :int, direction :int) : int
request_model #TRAM
request_model #FREIGHT // freight train locomotive
request_model #STREAK // passenger train locomotive
request_model #FREIFLAT // freight flat railroad car
request_model #FREIBOX // freight box railroad car
request_model #STREAKC // passenger railroad car
load_all_models_now // force load now

int handle = create_mission_train {type} type {pos} posX posY posZ {direction} direction

mark_model_as_no_longer_needed #TRAM
mark_model_as_no_longer_needed #FREIGHT
mark_model_as_no_longer_needed #STREAK
mark_model_as_no_longer_needed #FREIFLAT
mark_model_as_no_longer_needed #FREIBOX
mark_model_as_no_longer_needed #STREAKC

// some trains spawns with driver. Remove him
int driverHandle = get_driver_of_car handle
if
driverHandle <> -1
then
remove_char_from_car_maintain_position driverHandle {vehicle} handle
delete_char driverHandle
end

return handle
end


function TRAIN_PAINT(handle :int, color1 :int, color2 :int)
change_car_colour handle {color1} color1 {color2} color2

int idx = 1
while true
int carriage = get_train_carriage handle {number} idx
if
carriage == -1
then
break
end

change_car_colour carriage {color1} color1 {color2} color2

idx += 1
end
end

Loading