0% found this document useful (0 votes)
97 views2 pages

CLEO Sound Button

This document is a CLEO script for Grand Theft Auto: San Andreas that initializes and plays a sound effect when specific keys (Space or Shift) are pressed. It includes error handling for loading the audio file and maintains a counter that increments with each key press. The script runs in a loop, displaying the current count and instructions to the player.

Uploaded by

etinosaosato6
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)
97 views2 pages

CLEO Sound Button

This document is a CLEO script for Grand Theft Auto: San Andreas that initializes and plays a sound effect when specific keys (Space or Shift) are pressed. It includes error handling for loading the audio file and maintains a counter that increments with each key press. The script runs in a loop, displaying the current count and instructions to the player.

Uploaded by

etinosaosato6
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}

const Path_Sound_Button = ".\cleo_tests\Audio\Ding.mp3"

// init sounds
int asButton
if
not asButton = load_audio_stream {audioFileName} Path_Sound_Button
then
// failed to load the file. Print error and exit
debug_on
trace "CLEO Sound Button: ~r~~h~~h~Failed to load sound file '%s'"
Path_Sound_Button
terminate_this_script
end
set_audio_stream_type asButton {type} [Link]

// main loop
int counter = 0
while true
//wait {time} 16 // cap this script loop at 60 FPS
wait {time} 0 // as fast as game renders

// slow increment button


if
is_key_pressed {keyCode} [Link]
then
set_audio_stream_state asButton {action} [Link]
set_audio_stream_state asButton {action} [Link]
counter += 1

// wait for key release or timeout


TimerA = 0
while true
if or
not is_key_pressed {keyCode} [Link]
TimerA > 100
then
break // exit the loop
end

wait {time} 0
end
end

// rapid increment button


if
is_key_pressed {keyCode} [Link]
then
set_audio_stream_state asButton {action} [Link]
set_audio_stream_state asButton {action} [Link]
counter += 1
end
// display message
print_formatted_now {format} "Count: %d~n~Press ~h~SPACE~s~ or ~h~SHIFT~s~ to
increment." {time} 150 {args} counter // display longer than button timeout delay,
so no text flashing occur
end

terminate_this_script // never executed, but good to have

You might also like