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!

[SA] ¿How to use the IF AND & IF OR?


MixelAnomaly
 Share

Recommended Posts

Hi everyone, it's me again, this time i want to know how to use IF AND, and IF OR, since i am needing to make if i kill an enemy, X things happens, for example: the red cone disappears from his head, i was wondering if you could lend a hand with it, the IF OR i'm not sure i will use it, but it's better to be safe than sorry.

Edited by MixelAnomaly
Link to comment
Share on other sites


Writing scripts needs to use conditional checks to can decide when specified code should be executed

It's like questions, for example:
"Has user the Spacebar_key pressed?"
"if yes, then show a text message"


It often needs to specify the situation, so 2 or more conditons are needed, for example:

"Is CJ driving a vehicle AND has user the Spacebar_key pressed?"
"if yes, then show a text message"


Or give more options, for example:

"Has user the Spacebar_key OR Enter_key pressed?"
"if yes, then show a text message"

 

 

Below two example scripts

 

First script checks if OR
Either TAB_key or Backspace_Key needs to be pressed to can pass the conditional check

{$CLEO .cs}
:Akt
thread 'AKT'

:Akt_01
wait 0
if
0256: player $PLAYER_CHAR defined
jf @Akt_01
if or
0AB0:   key_pressed 8//-----------------key = Backspace
0AB0:   key_pressed 9//-----------------key = TAB
jf @Akt_01
08B2: toggle_thermal_vision 1
wait 3000
08B2: toggle_thermal_vision 0
jump @Akt_01

 

 

Second script checks if AND
Both keys must be pressed, TAB_key and Backspace_Key together, to can pass the conditional check

{$CLEO .cs}
:Akt
thread 'AKT'

:Akt_01
wait 0
if
0256: player $PLAYER_CHAR defined
jf @Akt_01
if and
0AB0:   key_pressed 8//-----------------key = Backspace
0AB0:   key_pressed 9//-----------------key = TAB
jf @Akt_01
08B2: toggle_thermal_vision 1
wait 3000
08B2: toggle_thermal_vision 0
jump @Akt_01

 

 

 

 

Edited by ZAZ
  • Like 2
Link to comment
Share on other sites

I always have this in mind sir, what is the different between using "JF" and "Else_Jump" ? Is there any different ? And if we already used all "Local" variable, is there a way to not use "Global" variable instead ? I see some cleo script have a hundred "Local" variable like [email protected] or [email protected] etc. All that i know is we can use from [email protected] - [email protected] where [email protected] and [email protected] is for time thing. How is that possible ?

Edited by 007Ripper
Link to comment
Share on other sites

 

10 hours ago, 007Ripper said:

 "JF" and "Else_Jump" ? Is there any different ?

No, it have same meaning, but several different variation to write

 

 

Quote

And if we already used all "Local" variable, is there a way to not use "Global" variable instead ?
I see some cleo script have a hundred "Local" variable like [email protected] or [email protected] etc.

 

Mission scripts can have 1000 locals, [email protected] till [email protected]
This requires a correct installation of mission scripts inside main.scm
For Cleo it needs to write the directive {$CLEO .cm} at beginning to compile the script as *.cm

The other normal scripts are limited to [email protected] and [email protected] and [email protected] is for timer


Having not enough locals is mostly a fallacy of unadvanced coders, because you can really do a lot with 32 locals
because a part of the locals are just needed temporary
Example:
the codes below should make explosions infront of CJ as well behind of CJ

04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset  0.0  15.0  0.0
04C4: create_coordinate 21@ 22@ 23@ from_actor $PLAYER_ACTOR offset  0.0  -15.0  0.0

020C: create_explosion_with_radius 6 at 11@ 12@ 13@
0565: create_temporary_explosion_fire 11@ 12@ 13@  6

020C: create_explosion_with_radius 6 at 21@ 22@ 23@
0565: create_temporary_explosion_fire 21@ 22@ 23@  6


But it needs to use only [email protected] [email protected] [email protected] in following case
 

04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset  0.0  15.0  0.0
020C: create_explosion_with_radius 6 at 11@ 12@ 13@
0565: create_temporary_explosion_fire 11@ 12@ 13@  6

04C4: create_coordinate 11@ 12@ 13@ from_actor $PLAYER_ACTOR offset  0.0  -15.0  0.0
020C: create_explosion_with_radius 6 at 11@ 12@ 13@
0565: create_temporary_explosion_fire 11@ 12@ 13@  6

After first explosion, the coords locals [email protected] [email protected] [email protected] aren't needed anymore
and [email protected] [email protected] [email protected] can be used again with new content

 

 

 

If still not enough locals, there're some other methods

 

1. opcode 0AB1: call_scm_func @subscript [email protected] [email protected] [email protected] [email protected] (with cleo only)

 

 This code leads the reading process to a subscript or code block that have it's own scope
 This code allows to attach up to 32 parameter to can send as well receive data

 

 
2. starting a thread
 code for cleo: 0A92: create_custom_thread "MultiThread.cs" 1 2 3 4
 code for main.scm: 004F: create_thread @AUDIOL [email protected] 0 1 1 0
 

This code allows to attach up to 32 parameter to can send data

With create_thread is it possible to initialize the same script again, more times
You can run same script in maybe hundred instances, started from same script that will be started again

 

 

3. Thread Memory (with cleo only)
 I never did it but read the posts of kosticn101

 

 

 

 

 

 

 

 

 

 

Edited by ZAZ
Link to comment
Share on other sites

Wow, it really open my mind i always make different locals for coordinat only what a waste. I have many things to ask but, thats it for now. Things that i like from cleo scripting is, we can do everything we want like adding powers etc, the only limit is our imagination. More wise today, Thank you sir.

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.