Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Summer Special
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

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

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

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    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. DYOM
      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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
ThAtSgOtTaHuRt

simple question - how to jump if int = a certain #

Recommended Posts

ThAtSgOtTaHuRt

my coding is really bad - but I am learning. I have:

 

 

0209: @0 = random_int  400  611;all cars

 

 

but while using that it can create a car(s) that crashes the game. so how could I make it so if "@0" equals a certain number it will jump to the beginning of the thread. I have a list of car IDs that may crash the game so all I need is the code to make this work.

 

would this work:

 

 

0209: @0 = random_int  400  611;all cars00D6: if  10039:   @0 ==  402 ;; integer values0039:   @0 ==  454 ;; integer values0039:   @0 ==  499 ;; integer values0039:   @0 ==  455 ;; integer values004C: jump_if_true ££CAR_SPAWN

 

 

how do you jump if something is true? are my middle lines any good? also, what about the "00D6: if 1" line? please help me out if you know.

 

 

thanks,

TGH

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
random_download

if's work like this: for each condition you have you add one to the if parameter. The parameter also starts at 0. So if you have 4 conditions like you have, you want if 3. Or, if 23 if any one of them can cause it to jump, whereas with if 3 every single condition must be false for it to jump.

Also, to make a condition NOT, change the first nubmer of the opcode to an 8:

 

0209: @0 = random_int  400  611;all cars00D6: if  238039:   NOT @0 ==  402;; integer values8039:   NOT @0 ==  454;; integer values8039:   NOT @0 ==  499;; integer values8039:   NOT @0 ==  455;; integer values004C: jump_if_flase ££CAR_SPAWN

 

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

thanks for your help, it really helped me a lot, but could you explain the

 

 

if 23 if any one of them can cause it to jump

 

now say if I had 33 cars in my list - what number would I use to jump if ANY ONE is false? 232?

 

-TGH

Share this post


Link to post
Share on other sites
ocram88

i think thats better

 

 

0209: @0 = random_int  400  611;all cars00D6: if  238039:   @0 ==  402;; integer values8039:   @0 ==  454;; integer values8039:   @0 ==  499;; integer values8039:   @0 ==  455;; integer values004C: jump_if_flase ££CAR_SPAWN0247: request_model @0

 

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

here is what I have in total but since my RANDOM_INT can be any car - it sometimes crashes the game. so I have a list of all boats, police vehilces, and trains that I dont want to be able to be spawned. I have 33 in the list - what "if" number would I use to include all 33 vehicles but allow ANY ONE to actiate teh jump.

 

 

:CAR_SPAWN0001: wait 1000 ms00D6: if 100E1:   key_pressed  0   6;aim + handbrake00E1:   key_pressed  0  18;crouch + horn004D: jump_if_false ££CAR_SPAWNjf ££CAR_SPAWN0209: @0 = random_int  400  611;all cars00D6: if  232 <-------------------------------------[PROBLEM AREA]8039:   NOT @0 ==  472;; integer values8039:   NOT @0 ==  473;; integer values8039:   NOT @0 ==  493;; integer values8039:   NOT @0 ==  595;; integer values8039:   NOT @0 ==  484;; integer values8039:   NOT @0 ==  430;; integer values8039:   NOT @0 ==  453;; integer values8039:   NOT @0 ==  452;; integer values8039:   NOT @0 ==  446;; integer values8039:   NOT @0 ==  454;; integer values8039:   NOT @0 ==  416;; integer values8039:   NOT @0 ==  427;; integer values8039:   NOT @0 ==  490;; integer values8039:   NOT @0 ==  528;; integer values8039:   NOT @0 ==  407;; integer values8039:   NOT @0 ==  544;; integer values8039:   NOT @0 ==  523;; integer values8039:   NOT @0 ==  598;; integer values8039:   NOT @0 ==  596;; integer values8039:   NOT @0 ==  597;; integer values8039:   NOT @0 ==  599;; integer values8039:   NOT @0 ==  594;; integer values8039:   NOT @0 ==  441;; integer values8039:   NOT @0 ==  464;; integer values8039:   NOT @0 ==  501;; integer values8039:   NOT @0 ==  465;; integer values8039:   NOT @0 ==  464;; integer values8039:   NOT @0 ==  590;; integer values8039:   NOT @0 ==  569;; integer values8039:   NOT @0 ==  449;; integer values8039:   NOT @0 ==  537;; integer values8039:   NOT @0 ==  538;; integer values8039:   NOT @0 ==  570;; integer values004D: jump_if_false ££CAR_SPAWN0247: request model @0038B: load requested models00D6: if  00248:   model @0 available04C4: create_coordinate @1 @2 @3 from_actor $Player_Actor offset  0.0  8.0  1.000A5: @4 = create_car @0 at  @1 @2 @302AC: set_car @4 immunities 1 1 1 1 101C3: remove_references_to_car @4;; randomizes car for next use0001: wait 2000 ms0002: jump ££CAR_SPAWN

 

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
AdTec_224

user posted image

 

 

:CAR_SPAWN0001: wait 1000 ms00D6: if 100E1:   key_pressed  0   6;aim + handbrake00E1:   key_pressed  0  18;crouch + horn004D: jump_if_false ££CAR_SPAWN00D6: if  68039:   NOT @0 ==  472;; integer values8039:   NOT @0 ==  473;; integer values8039:   NOT @0 ==  493;; integer values8039:   NOT @0 ==  595;; integer values8039:   NOT @0 ==  484;; integer values8039:   NOT @0 ==  430;; integer values8039:   NOT @0 ==  453;; integer values00D6: if  68039:   NOT @0 ==  452;; integer values8039:   NOT @0 ==  446;; integer values8039:   NOT @0 ==  454;; integer values8039:   NOT @0 ==  416;; integer values8039:   NOT @0 ==  427;; integer values8039:   NOT @0 ==  490;; integer values8039:   NOT @0 ==  528;; integer values00D6: if  68039:   NOT @0 ==  407;; integer values8039:   NOT @0 ==  544;; integer values8039:   NOT @0 ==  523;; integer values8039:   NOT @0 ==  598;; integer values8039:   NOT @0 ==  596;; integer values8039:   NOT @0 ==  597;; integer values8039:   NOT @0 ==  599;; integer values00D6: if  68039:   NOT @0 ==  594;; integer values8039:   NOT @0 ==  441;; integer values8039:   NOT @0 ==  464;; integer values8039:   NOT @0 ==  501;; integer values8039:   NOT @0 ==  465;; integer values8039:   NOT @0 ==  464;; integer values8039:   NOT @0 ==  590;; integer values00D6: if  48039:   NOT @0 ==  569;; integer values8039:   NOT @0 ==  449;; integer values8039:   NOT @0 ==  537;; integer values8039:   NOT @0 ==  538;; integer values8039:   NOT @0 ==  570;; integer values004D: jump_if_false ££CAR_SPAWN0247: request model @0038B: load requested models00D6: if  00248:   model @0 available04C4: create_coordinate @1 @2 @3 from_actor $Player_Actor offset  0.0  8.0  1.000A5: @4 = create_car @0 at  @1 @2 @302AC: set_car @4 immunities 1 1 1 1 101C3: remove_references_to_car @4;; randomizes car for next use0001: wait 2000 ms0002: jump ££CAR_SPAWN

 

Edited by AdTec_224

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

ok like random_download said:

 

 

Or, if 23 if any one of them can cause it to jump, whereas with if 3 every single condition must be false for it to jump.

 

How would I change that so any ONE (one not all) would be able to jump to the start. The way you have it requires ALL of them to be false in order to jump - or does it not? Would I make it "00D6: if 26"

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
random_download

Yes, adding 20 to the if number makes it an OR statement, without the 20 it is AND. I think the limit on if numbers is 6 or 7 or something. Just split it up into several different if statements.

 

@ocram88: removing the NOT bits just makes it harder to see what is happening, as people may not notice the 8 instead of 0 as the first opcode number.

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

sweet, thanks! (to all) also I have one more question that should go into another topic but I will ask it here:

 

I created a coordinate for which the car will spawn at. But the coordinate doesnt have an angle - every time a car spawns it points towards 0 (rotation - relative the WORLD) Is there anyway that I can always make the car face 90 from the players current location (not 90 relative to the worlds z-axis, but perpendicular to the player).

 

For example I want this to happen: the player is currently looking in the 45 degree (relative to the worlds z-axis) direction and the car will spawn away from the player at the angle of 135 (45 + 90) how is this possible to do?

 

thanks,

TGH

Share this post


Link to post
Share on other sites
Demarest

Yes, adding 20 to the if number makes it an OR statement, without the 20 it is AND. I think the limit on if numbers is 6 or 7 or something.

7 and 27

 

 

Is there anyway that I can always make the car face 90 from the players current location (not 90 relative to the worlds z-axis, but perpendicular to the player).

Absolutely. Here's a rough sketch how

 

 

var = player's z anglevar = var - 90if var<0jump if false next sectionvar = var + 360next sectionthe rest of your code here

 

 

You can check out my car spawn mods for the specifics on how it's done with opcodes to use and all that. Remember that angles are always floats.

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

*EDIT*

 

ok I found out how to set players z_angle and how to change the cars z_angle.

 

I changed what I want to do. I want the car to point towards the player. so how could I do the following:

 

0172: @12 = actor $PLAYER_ACTOR z_angle

0175: set_car @4 z_angle_to @12 + 180 <--------- how do I had 180 to a var?

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
Zach

 

0172: @12 = actor $PLAYER_ACTOR z_angle000B: @12 +=  180.00175: set_car @4 z_angle_to @12

 

 

 

EDIT: Forgot we are dealing with floats.

 

EDIT(2): Though, be warned. I don't think it will be this simple. tounge.gif (It depends on if the engine can handle angles >= 360.0.)

Edited by Zach

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

wow thanks, tested and it works

 

 

*EDIT*

 

ALSO

 

is there a way to define the OPOSITE of a var?

 

0172: @12 = actor $PLAYER_ACTOR z_angle

0175: set_car @4 z_angle_to -@12

^doesnt work^ - how can I just make the oposite of a var?

 

 

also thanks for your help zach, and all other posters in this topic: Demarest, random_download, AdTec_224

 

-TGH

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
Demarest
It's cool to see that angles greater than 360 work. If that's the case, then in my example, instead of subtracting 90 and bothering with an if, you could just add 270 smile.gif

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

the angles work - although, I am having the cars spawn away from me and have them drive towards me and stop next to me. they start at the correct angle (even when its more than 360) but when the angle is more than 360 the cars dont drive strait towards me they just do circles. any ideas?

 

this might help everyone figure it out - maybe:

 

 

04C4: create_coordinate @1 @2 @3 from_actor $Player_Actor offset  0.0  25.0  1.0 <---[sPAWNS HERE]04C4: create_coordinate @5 @6 @7 from_actor $Player_Actor offset  -2.0  1.0  0.0 <---[DRIVES HERE]0172: @12 = actor $PLAYER_ACTOR z_angle000B: @12 +=  180.0<----------------------------------------------------[POINTS CAR TOWARDS PLAYER]00A5: @4 = create_car @0 at  @1 @2 @30175: set_car @4 z_angle_to @1202AC: set_car @4 immunities 1 1 1 1 1 053F: set_car @4 tires_vulnerable  000A7: car @4 drive_to @5 @6 @7

 

 

as we determined the car faces towards me (z_angle + 180) but when the car's z_angle ends up being more than 360 the car does circles and doesnt drive to the cords

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
Zach

Maybe the engine just doesn't fully work with those angles. <shrug>

 

Try this and see if it works:

 

 

04C4: create_coordinate @1 @2 @3 from_actor $Player_Actor offset  0.0  25.0  1.004C4: create_coordinate @5 @6 @7 from_actor $Player_Actor offset  -2.0  1.0  0.00172: @12 = actor $PLAYER_ACTOR z_angle000B: @12 +=  180.0:AngleCheck00D6: if  00033:    360.0 >= @12004D: jump_if_false ££AngleOkay000F: @12 -=  360.0;; floating-point values:AngleOkay00A5: @4 = create_car @0 at  @1 @2 @30175: set_car @4 z_angle_to @1202AC: set_car @4 immunities 1 1 1 1 1053F: set_car @4 tires_vulnerable  000A7: car @4 drive_to @5 @6 @7

 

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt
yea, good work, a coterminal angle - I didnt even thingk of that. sure pays off to know your math! yea but now local variables change per thread - so I would have to change them to global variables. Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
Y_Less
Local variables change per thread, not per label, so that code will work.

Share this post


Link to post
Share on other sites
ThAtSgOtTaHuRt

ohhh. could you define the difference between thread and lable - so I can get a better understanding and be able to tell the difference. like I said in the beginning - I just started coding. I caught on quick though tutorials and such, but have yet to learn some of the basics.

 

also could you explain these (what they do), it might help me with the thread\lable concept:

 

 

03A4: name_thread 'NAME'-and-004F: create_thread ££NAME-and-jf ££NAME-and-004E: end_thread

 

 

THANKS for all your help, I really appreciate it.

 

Edited by ThAtSgOtTaHuRt

Share this post


Link to post
Share on other sites
Demarest

In a way, you answered your own question. Basic programming sees line numbers. In SCM, they're called labels because they don't have to be numbers. Name them what makes them easy for you and the compiler will convert them to how the game thinks of it.

 

When I first got into SCM, it was a mental challenge for me too because never before had I programmed in a multi-thread environment. Simply put, the game runs multipled threads at the same time. Think of it as simultaneous programs running. It doesn't TRULY run simultaneously, which is why SCM coding has wait commands. While one thread is waiting, the game is executing other threads one at a time. 3 of the opcodes you have there pertain to threads. One starts a thread. I can't go into specific, but it essentially lets the game know to set aside room and resources for another "program" to run along side the others. That thread will continue to run until it is ended. Why end a thread? Well say for example you complete all rampages. No use in wasting time and resources on monitoring whether or not you've picked up a certain rampage pickup any longer, so you end the thread. This lets the game know it can toss all resources it set aside for that thread out and focus on those still running.

 

Labels are ways of dividing a thread up. Any time you need to be able to jump to a particular part of the code, you will need a label to reference to (not always true, but only CyQ knows how to otherwise tounge.gif). The most common occurance of this is

 

label 1if (some check)jf label 2stuff to run only if the check is truelabel 2stuff that runs after the check regarless of whether it was true or not

 

or

 

label 1if (some check)jf label 2stuff to run only if the check is truejump label 3label 2stuff to run only if the check is falselabel 3stuff to run after the above regardles of whether it was true or not

 

All jumps and whatnot refer to labels. In fact, outside of creating, ending, and naming a thread, you'll never refer to the thread itself. And I'm not even sure naming the thread has any real use.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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