richardcheckim Posted May 7, 2011 Share Posted May 7, 2011 Hello, I am newbie in making cleo scripts, but after reading of few tutorials, I decided to make "test cleo", what shows save diskette icon after pressing "8" key on numpad. This is my script code: {$CLEO .cs}//-------------MAIN---------------thread 'TEST':TEST_1if andPlayer.Defined($PLAYER_CHAR) 0AB0: key_pressed 1040570: $630 = create_asset_radar_marker_with_icon 36 at 1410.187 1758.98 10.8203return When I started my game, it crashed after loading screen. So I remove my test cleo, but game still won´t work. So I want to ask, where I made a mistake in my code, and what can cause that my game don´t work after removing that script. Thanks for your answers! Link to comment Share on other sites More sharing options...
ZAZ Posted May 7, 2011 Share Posted May 7, 2011 Hello, I am newbie in making cleo scripts, but after reading of few tutorials, I decided to make "test cleo", what shows save diskette icon after pressing "8" key on numpad. This is my script code: {$CLEO .cs}//-------------MAIN---------------thread 'TEST':TEST_1if andPlayer.Defined($PLAYER_CHAR) 0AB0: key_pressed 1040570: $630 = create_asset_radar_marker_with_icon 36 at 1410.187 1758.98 10.8203return When I started my game, it crashed after loading screen. So I remove my test cleo, but game still won´t work. So I want to ask, where I made a mistake in my code, and what can cause that my game don´t work after removing that script. Thanks for your answers! read the tutorial again Scripting/Writing a Thread The scripts which are running in GTA are called THREAD They are defined in the main.scm as thread with the create_thread command or a mission script as mission As well the Extern scripts of script.img are also threads. The cleo programm checks if there is .cs file in the Cleo folder and if yes, it start this script as thread Script structur / short version: At first, the head, it beginns with the Cleo directive {$CLEO .cs} First Label (adress) :Akt Then give the thread a name 03A4: name_thread 'AKT' now put a code inthere which will doing something and then end_custom_thread as last code its ready then to test it ingame {$CLEO .cs}:Akt03A4: name_thread 'AKT'08B2: toggle_thermal_vision 10A93: end_custom_thread Script above activates the Infrarot view unless in cutscenes The script ends then, will be deactivated because it ends with opcode 0A93: end_custom_thread The script will be started by each loading of savegame or by start new game ______________________________________________________________________________________ Next step / using conditional checks A conditional check requires minimum 3 opcodes 1. the IF-variation 2. the real question 3. the jump instruction by negation 1. if 2. 0AB0: key_pressed 8 3. 004D: jump_if_false @akt_01 We use the previous script again but now we wonna be able to switch into normal view Therefore we use a conditional check and build a "LOOP" Loop means that a jump instruction can send the reading process to a previous adress I call such an adress "Loop-adress" Important: The first opcode after such a Loop-adress must be the wait opcode mostly wait 0 millisecond the jump instruction can be a jump instruction by negation or also a normal jump instruction 004D: jump_if_false @akt_01 or 0002: jump @akt_01 The conditional check of a key press in the script below should be passed by pressing BACKSPACE {$CLEO .cs}:Akt03A4: name_thread 'AKT'08B2: toggle_thermal_vision 1:Akt_01//----------------------------Loop adresse0001: wait 0 msif0AB0: key_pressed 8004D: jump_if_false @Akt_01//--------jump instruction by negation08B2: toggle_thermal_vision 00A93: end_custom_thread Script above activates the Infrarot view and toggle back to normal view by key_press The reading process is looping as long as BACKSPACE is not pressed the jump instruction by negation sends the reading process allways to the label :Akt_01 1000 times per second CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Bad.boy! Posted May 7, 2011 Share Posted May 7, 2011 (edited) You have to make a jf or else_jump after an if. And you used a global ($630), that can make the game crash to, so use a local instead ([email protected] for example). Data types : (doublepoint) marks a Label (adress) :MAIN_1 @ is used for 2 different functions 1. in jump instruction to mark the label which should be reached 004D: jump_if_false @SAVE_50050: gosub @SAVE_140002: jump @SAVE_1 2. to mark LOCAL VARIABLES The stuff in the game needs a identity for registration to can handle with it The identities can be variable, for exemble by calculating something The local variable is builded with the @ sign and a number [email protected], [email protected], ... [email protected] from [email protected] up to [email protected] is possible, [email protected] and [email protected] are for timers, thats maximum in an .cs file [email protected] defines a parked_car generator 014B: [email protected] = init_parked_car_generator #PCJ600 0 17 1 alarm 0 door_lock 0 0 10000 at 2490.0 -1682.0 13.5 angle 90.0 [email protected] can then be used furthermore as variable name of the parked_car generator 014C: set_parked_car_generator [email protected] cars_to_generate_to 101 $ is used to mark a GLOBAL VARIABLE The stuff in the game needs a identity for registration to can handle with it The identities can be variable, for exemble by calculating something The global variable is builded with the $ sign and a a letter or a word or a number or both But using global variables in Cleo scripts can cause heavy bugs or crashs only $PLAYER_CHAR, $PLAYER_ACTOR, $ONMISSION are valid global, local, whats that ? Global variables are used in the main.scm to communicate between different threads Local variables are also used in the main.scm but they can not communicate between different threads You can create a car with a LOCAL variable in a thread as [email protected] and also with [email protected] in an other thread of main.scm [email protected] = create_car You have then 2 different cars, commanded from 2 different threads You can create a car with GLOBAL variable in a thread but dont use again the same global to create it again in an other thread. $mycar5 = create_car But you can command the car from an other thread of the main.scm by using a GLOBAL variable At least: The GLOBAL variables are storable, the LOCAL variables not But dont using global variables in Cleo scripts because they can cause heavy bugs or crashs only $PLAYER_CHAR, $PLAYER_ACTOR, $ONMISSION are valid Edited May 7, 2011 by Bad.boy! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now