Coding

 Reply to this postStart new topic

CLEO 4 - Great New Functions

Deji
post Feb 26 2010, 09:32 PM
Post #1


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Let's go over some of the great new functions in CLEO 4!


Car Spawner


SANNY
for 0@ = 400 to 611
    0ADB: 1@v = car_model 0@ name
    0ADE: 1@v = text_by_GXT_entry 1@v
    if
        0ADC: test_cheat 1@v
    then
        0ADD: spawn_car_with_model 0@ at_player_location
        0ACE: show_formatted_text_box "%s spawned..." 6@v
    end
end


Here we have 0ACE, 0ADB, 0ADC, 0ADD and 0ADE in use together to create a great car spawning system easily.

The for loop goes through all possible car models.

0ADB gets the cars model name (LANDSTAL for example).

In San Andreas... The model names of cars are the same as the GXT Entry names for the car... So we can use the model name to get the GXT Entry Name and use that to get the car name.

0ADE gets the text according to the GXT Entry. Here we are getting the cars text.

0ADC lets you type what cheat the player has to type for the condition to turn true. Here we use the cars name to test if the player has typed it. So if he types "STRECH" or "LANDSTALKER", the code will continue.

0ADD spawns a car straight away with no need to load models etc. The same way that Rockstar used to spawn cars when cheats were typed.

0ACE displays a text box that you specify... With the ability to include variable contents in your string as shown above.


All these make a great car spawner! And I'm sure you could make one better with this as a guide.


Dynamic GXT


SANNY
0ADF: add_dynamic_GXT_entry "_TEST" text "Test string"


This can add GXT entries on the fly.

It's best to use the opcodes that allow you to make a text box without gxt/fxt than adding dynamic GXT entries... Since these use more memory.

You can use the format text opcodes to customize the text string.

SANNY
0AE0: remove_dynamic_GXT_entry "_TEST"


Make sure you remove the GXT when you're finished! This will free memory.


Aim & Kill


SANNY
0AD2: $actor = player $PLAYER_CHAR targeted_actor


Now getting the actor a player is aiming at is a whole lot easier! This can be used as a condition:

SANNY
if
    0AD2: 0@ = player $PLAYER_CHAR targeted_actor
then
    0321: kill_actor 0@
end


... In case you're too lazy to pull the trigger.


File Seeking


SANNY
0AD5: file 0@ seek 4 from_origin 1


Now you can skip parts of a file to read what is relevant.

Good for settings files when you don't want to make loads of code to skip the file wink.gif


String Combining


SANNY
1@v = "I feel "

0@ = 1 // good

if
    0039:   0@ == 0
then
    3@v = "great"
end
if
    0039:   0@ == 1
then
    3@v = "good"
end
if
    0039:   0@ == 2
then
    3@v = "like mass homicide"
end
0AD3: 5@v = format "%s%s!" 1@v 3@v
0ACA: show_text_box 5@v


Should print out...

CODE
I feel good!


Note the format opcode can combine plenty more kinds of strings and characters.


Partial String Retrieval


You can retrieve part of a string.

SANNY
0@v = "string1 string2"
0AC7: 4@ = var 0@ offset
4@ += 7 // first 7 chars of the string. store as hex.
0AD3: 5@v = format "%.*s" 6 4@
0ACA: show_text_box 5@v


Should print out:

CODE
string1


Thanks to Alien for assisting me with this.


More CLEO 4 Opcodes


--------------------
Go to the top of the page
 
+Quote Post
Trickstar
post Feb 27 2010, 08:53 PM
Post #2


Newbie In Training

Posts: 17
From: Cedar Rapids, IA, USA
Joined: 30-January 10



You know they have another version released aa couple hours ago right? Since I don't want to retype everything, I'll just post the link to the topic at my forums.

http://www.grandtheftauto-gaming.com/forum...;t=84&p=297


--------------------

Y'all Want Me?
Go to the top of the page
 
+Quote Post
Deji
post Feb 28 2010, 12:22 AM
Post #3


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Yeah they've fixed the gosub_if_false bug that I was having.

I've already made a great mod using CLEO 4 functions to be part of ze Ultimate CLEO Trainer... Which will be even more Ultimate now that a new version of CLEO is out.


--------------------
Go to the top of the page
 
+Quote Post
Trickstar
post Feb 28 2010, 12:55 AM
Post #4


Newbie In Training

Posts: 17
From: Cedar Rapids, IA, USA
Joined: 30-January 10



0AD5: file 0@ seek 4 from_origin 1

This and text are of the most use to me of the new opcodes.


--------------------

Y'all Want Me?
Go to the top of the page
 
+Quote Post
Deji
post Feb 28 2010, 01:01 AM
Post #5


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Yeah... It was always simple enough just to read past a number of bytes but this saves variables and lines of code I guess. And closing/opening files can get annoying.

I've always had problems with using files... And once you mess a file operation up, the file needs to be deleted and re-made in order to fix any issues. Can get really annoying.

I was hoping for PHP-like file functions.


--------------------
Go to the top of the page
 
+Quote Post
Trickstar
post Feb 28 2010, 01:04 AM
Post #6


Newbie In Training

Posts: 17
From: Cedar Rapids, IA, USA
Joined: 30-January 10



Hell no! PHP is way to cryptic looking, its annoying enough just using it for web sites. I want Java or C++ like operations (which the newest version apparantly supports).


--------------------

Y'all Want Me?
Go to the top of the page
 
+Quote Post
Deji
post Feb 28 2010, 02:10 AM
Post #7


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Ugh... Hate C++ syntax. Too unorganized. PHP is really well done..

SANNY
$text1 = "slicka-slim shady";
$text = "Hi, " . "my name is";
$text .= " " . $text1;
echo $text;


CODE
Hi, my name is slicka-slim shady


Lol... Fell in love with it from the moment I started being able to make databases and shish out of it... Can get a bit annoying at times but there's always a way to do anything. PHP is great at file functions, though. Especially with the explode and implode functions (split and combine text)... I managed to get PHP to build it's own database out of the sascm.ini for the Opcode Database. tongue.gif A lot quicker than doing it by hand.

At least it's no where like Javascript... Which is the worst damn language to exist... Not just in syntax but also in what it actually does... Fail.


--------------------
Go to the top of the page
 
+Quote Post
Trickstar
post Feb 28 2010, 02:36 AM
Post #8


Newbie In Training

Posts: 17
From: Cedar Rapids, IA, USA
Joined: 30-January 10



I don't think so. Java/Javascript is more plain English than PHP. The only reason Javascript doesn't have proper "file" options is because it is a risk of security. For most things I prefer ASP.Net, but for sh*t that requires databases and security or editing binary files, I use cryptic ass PHP.


--------------------

Y'all Want Me?
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: