Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

[VC] Some questions for modding in CLEO Scripts


Nova7GFU
 Share

Recommended Posts

Well, these questions are mainly to create an "advanced Bodyguard" And would do to learn more about CLEO and have a bodyguard to look after me when walking on the street and I meet Haitians annoying, you know.

 

1) How to store the "Actor" who attack "Player_Actor" in a variable? For example, a "cop" shoots the "player", then the "cop" is detected and stored in Variable [email protected]

 

2) How I can add weapons to the "actors" without the game crashes? (I tried loading the model, check and put with the 'opcode: 01B2' to the actor, but the game crashes).

 

That's all for now.

 

Sorry for my bad english.

Link to comment
Share on other sites

spaceeinstein

There is an example code for 01B2 here.

Link to comment
Share on other sites

There is an example code for 01B2 here.

Sir, I've already tried this way.

:Name_Threadthread 'THREAD'0247: request_model 1030247: request_model #M4:Label_01wait 0IF    0248: model 103 available    0248: model #M4 availableTHEN    04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0    009A: [email protected] = create_actor 4 103 at [email protected] [email protected] [email protected]    01B2: give_actor [email protected] weapon #M4 ammo 500    01DF: tie_actor [email protected] to_player $PLAYER_CHAR    0249: release_model 103    0249: release_model #M4ELSE    jump @Label_01END

This is just one example of what I did.

 

Sorry for my english.

 

EDIT:

the game still crashes, why?

Edited by Nova7GFU
Link to comment
Share on other sites

thehambone

Three things:

IF    0248: model 103 available    0248: model #M4 available

This should be an "IF AND" statement, since you have more than one condition and you want both conditions to be true in order to continue. (SannyBuilder should throw an error about this)

01B2: give_actor [email protected] weapon #M4 ammo 500

The second parameter for this opcode is not the weapon model ID. It is the weapon number, which is different than the model ID. For the M4, the weapon number is 26. You can find a list of all weapon numbers here.

004E: end_thread

You must add this to the end of your code or it will crash.


I recommend using constants in your code as it makes your code easier to read and understand. It's also easier to make changes (such as changing the ped model) when you use constants.

Here's the full, working code (with constants).

{$CLEO .cs}const    PED_MODEL = 103    WEAP_MODEL = #M4    WEAP_NUMBER = 26end:Name_Threadthread 'THREAD'0247: request_model PED_MODEL0247: request_model WEAP_MODEL:Label_01wait 0IF AND    0248: model PED_MODEL available    0248: model WEAP_MODEL availableTHEN    04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0    009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected]    01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500    01DF: tie_actor [email protected] to_player $PLAYER_CHAR    0249: release_model PED_MODEL    0249: release_model WEAP_MODELELSE    jump @Label_01END004E: end_thread
Edited by thehambone

San Andreas Countryside
Meet the GTA 3 players who've spent a decade playing pass-the-pad to 100% the game - GamesRadar

GTA:LCS Save Editor - Supports Android, iOS, PS2, and PSP saves!

GTA3 Save Editor  - Big update in the works!

 

Link to comment
Share on other sites

IF    0248: model 103 available    0248: model #M4 available

This should be an "IF AND" statement, since you have more than one condition and you want both conditions to be true in order to continue. (SannyBuilder should throw an error about this)

Exactly, Sanny Builder does, but that's not the problem.

 

And thanks for reply, I'll try and then tell you.

 

EDIT:

 

I'm a n00b, I forgot jump @Label_01 after creating the actor.

 

I want more than one bodyguard, but with the '004E: end_thread' I can only have one.

 

Here the code:

{$CLEO .cs}const    PED_MODEL = 103    WEAP_MODEL = #M4    WEAP_NUMBER = 26end:Name_Threadthread 'THREAD'[email protected] = 0:Label_010247: request_model PED_MODEL0247: request_model WEAP_MODELwait 0IF AND    0248: model PED_MODEL available    0248: model WEAP_MODEL availableTHEN    IF        [email protected] == 0    THEN        IF            0AB0: key_pressed 0x73        THEN            04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0            009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected]            01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500            0319: set_actor [email protected] running 1            01DF: tie_actor [email protected] to_player $PLAYER_CHAR            0249: release_model PED_MODEL            0249: release_model WEAP_MODEL            [email protected] = 1            jump @Label_01        ELSE            jump @Label_01        END    ELSE        IF            [email protected] == 1        THEN            IF or                Actor.Dead($PLAYER_ACTOR)                Actor.Dead([email protected])            THEN                Actor.DestroyWithFade([email protected])                Actor.RemoveReferences([email protected])                [email protected] = 0                wait 1000                jump @Label_01            ELSE                jump @Label_01            END        ELSE            jump @Label_01        END    ENDELSE    jump @Label_01END

But, I don't understand why sometimes not attack who attacked me.

 

PS: All who are interested please help me, I will appreciate your help.

 

EDIT2:

 

Now, I don't understand WHY sometimes does not disappear when the player dies.

 

I using 'RemoveReferences' and 'DestroyWithFade'.

Edited by Nova7GFU
Link to comment
Share on other sites

Load models only as soon as they're needed (not before the keypress)

 

----

Nice to see that you're able to use a var as "switch/step controler" -> [email protected]

But i think it's not necessary for that tiny script

Test the script inside the spoiler

 

 

 

{$CLEO .cs}thread 'BGUARD'const    PED_MODEL = 103    WEAP_MODEL = #M4    WEAP_NUMBER = 26endwhile truewait 0    if        0256:   player $PLAYER_CHAR defined     then        if            0AB0: key_pressed 0x73// press F4 key        then            0247: request_model PED_MODEL            0247: request_model WEAP_MODEL                        while true                wait 0                IF AND                    0248: model PED_MODEL available                    0248: model WEAP_MODEL available                THEN                    04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0                    009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected]                    01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500                    04F5: unknown_actor [email protected] kiss_player $PLAYER_CHAR on 1                    0249: release_model PED_MODEL                    0249: release_model WEAP_MODEL                                        break                end            end                        while 0256:   player $PLAYER_CHAR defined                wait 0                            if                    8118: not actor [email protected] dead                then                    if                        00E9:   player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0                    then                        if                            8320:   not actor [email protected] in_range_of_player $PLAYER_CHAR                        then                            01DF: tie_actor [email protected] to_player $PLAYER_CHAR                        end                                    else                        break                    end                else                    break                                            end            end            03E5: text_box 'FEM_OFF'                        Actor.RemoveReferences([email protected])                    end            endend

 

Everthing is inside the key_press check: model load, loop to check if models are loaded and actor spawn, then the loop to ckeck if actor dies as well if he is still in range, also Actor.RemoveReferences

a textbox message "OFF" appears at the end to indicate especially if actor is too far away

 

I made loops by using the while statement,

 

either for ever (as long as game is running ingame):

 

while true

wait 0

end

 

or with condition

 

while 0256: player $PLAYER_CHAR defined

wait 0

end

 

the command break let the code leave the loop

 

 

 

I found this method in the gangmem thread of vc main.scm:

 

 

 

04F5: unknown_actor [email protected] kiss_player $PLAYER_CHAR on 1if    00E9: player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0then    if        8320: not actor [email protected] in_range_of_player $PLAYER_CHAR    then        01DF: tie_actor [email protected] to_player $PLAYER_CHAR        .....

 

Edited by ZAZ
Link to comment
Share on other sites

Same code as ZAZ's, but tweaked a bit to be shorter and more R* style with checks (notice different loops). Also removed script name since it's useless with CLEO scripts (unless you're doing inter-script communication):

 

 

{$CLEO}0000: BGUARDconst	PED_MODEL = 103	WEAP_MODEL = #M4	WEAP_NUMBER = 26endwhile true	wait 0	if 0256:   player $PLAYER_CHAR defined	then		if 0AB0: key_pressed 0x73// press F4 key		then			0247: request_model PED_MODEL			0247: request_model WEAP_MODEL			while true				if or					8248: not model PED_MODEL available					8248: notmodel WEAP_MODEL available				jf break				wait 0			end			04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0			009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected]			01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500			04F5: set_char [email protected] as_player_friend $PLAYER_CHAR on 1			0249: release_model PED_MODEL			0249: release_model WEAP_MODEL			while 0256:   player $PLAYER_CHAR defined				if 8118: not actor [email protected] dead				jf break				if 00E9:   player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0				jf break				wait 0				if 8320:   not actor [email protected] in_range_of_player $PLAYER_CHAR				then					01DF: tie_actor [email protected] to_player $PLAYER_CHAR				end			end			03E5: text_box 'FEM_OFF'			01C2: remove_references_to_actor [email protected]		end	endend
Since both scripts are valid and 100% identical behaviour wise, you could consider this an example of different coding styles! Edited by Silent
Link to comment
Share on other sites

Amazing Silent it so very short! but i wonder. What different with loop REPEAT until FALSE, sorry copy'paste just for learning.

{$CLEO}0000: BGUARDconst    PED_MODEL = 103    WEAP_MODEL = #M4    WEAP_NUMBER = 26endwhile true    wait 0    if 0256:   player $PLAYER_CHAR defined    then        if 0AB0: key_pressed 0x73// press F4 key        then            0247: request_model PED_MODEL            0247: request_model WEAP_MODEL            REPEAT                wait 0            if or                8248: not model PED_MODEL available                8248: notmodel WEAP_MODEL available            jf break            until FALSE

                04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0                009A: [email protected] = create_actor 4 PED_MODEL at [email protected] [email protected] [email protected]                01B2: give_actor [email protected] weapon WEAP_NUMBER ammo 500                04F5: set_char [email protected] as_player_friend $PLAYER_CHAR on 1                0249: release_model PED_MODEL                0249: release_model WEAP_MODEL                while 0256:   player $PLAYER_CHAR defined                    if 8118: not actor [email protected] dead                    jf break                    if 00E9:   player $PLAYER_CHAR 0 [email protected] radius 100.0 100.0                    jf break                    wait 0                    if 8320:   not actor [email protected] in_range_of_player $PLAYER_CHAR                    then                        01DF: tie_actor [email protected] to_player $PLAYER_CHAR                    end                end                03E5: text_box 'FEM_OFF'                01C2: remove_references_to_actor [email protected]            end        end    end
Since both scripts are valid and 100% identical behaviour wise, you could consider this an example of different coding styles!
Edited by X-Falcon
Link to comment
Share on other sites

 

repeat...until false and while true are identical, but the first one is objectively more awkward ;) You wouldn't see it in any real-purpose language, unlike a while loop.

Edited by Silent
Link to comment
Share on other sites

Ah, I didn't know that is have awkward language. But i wouldn't out the fact, i also see Master Seemann old post that common showing the while loop.
Seems this can amplify the absolute while true. Guess when the both loop work properties, i would keep the both to be tried. Thank you for feedback Silent. :cool:

Link to comment
Share on other sites

Well, thank you very much Mr. @ZAZ and Mr. @Silent for replies. :cookie::cookie:

 

New learned skill.

 

EDIT:

Personally, I prefer the style that Mr. ZAZ suggested.

 

Sorry for my english.

Edited by Nova7GFU
Link to comment
Share on other sites

  • 5 weeks later...

I have a new question!

How I can put my own camera like this?

 

Howtomakethat.jpg

 

Objective: Handling my own camera with Mouse pointing where I want

 

Issue: The camera only points in the direction (read code) and I can't move the camera

 

Here the code:

{$CLEO .cs}0000: SLOWMOB // TESTED!CONST    SWITCHER = [email protected] TRUE    wait 0    IF        00E1: player 0 pressed_key 6    THEN        04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 0.4 -1.5 0.7        Camera.SetPosition([email protected], [email protected], [email protected], 0.0, 0.0, 0.0)        Camera.PointAt([email protected], [email protected], [email protected], 2)        SWITCHER = 1    ELSE        IF            SWITCHER == 1        THEN            Camera.Restore_WithJumpCut()            SWITCHER = 0        END    ENDEND

I hope some help. :cookie:

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.