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!

Piece of code


Quadropheniac90
 Share

Recommended Posts

Quadropheniac90

I made a piece of code to make a car $PLCAR be able to drop bombs and when the button with which the bombs are dropped is pressed when a bomb is made, it explodes. Also, when you get into a car that is not $PLCAR, the new car cannot drop bombs or explode bombs which have been dropped by another car. I still have to make a sphere somewhere or something to remove references to the old $PLCAR and make the car in the sphere $PLCAR, but for now I made the first car the player enters at the start of the game $PLCAR for easy testing. Here's the code (I don't care if anybody rips it, it's probably not good enough anyways):

 

 

:CARWEAPS 0001: wait 0 ms 0247: request_model #SATCHEL038B: load_requested_models:CHECKCHAIN0001: wait 0 ms00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 00449:   actor $PLAYER_ACTOR in_a_car004D: jump_if_false ££CHECKCHAIN03C0: $PLCAR = actor $PLAYER_ACTOR car 00D6: if 08119:   NOT   car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD:CARCHECKKEY0001: wait 0 ms00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 08119:   NOT   car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD00D6: if 00448:   actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££CARCHECKKEY00D6: if 000E1:   key_pressed  0  17004D: jump_if_false ££CARCHECKKEY0002: jump ££KEYREL:KEYREL 0001: wait 0 ms00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 08119:   NOT   car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD00D6: if 00448:   actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££CARCHECKKEY00D6: if 080E1:   NOT   key_pressed  0  17004D: jump_if_false ££KEYREL0002: jump ££GOGO1 :GOGO10001: wait 0 ms 00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF 00D6: if 08119:   NOT   car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD00D6: if 00248:   model #SATCHEL available004D: jump_if_false ££GOGO100D6: if 083CA:   NOT   object @6 exists004D: jump_if_false ££EXPLODE00D6: if 00448:   actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££GOGO10050: gosub ££DROPBOMB0002: jump ££CARWEAPS:DROPBOMB0407: create_coordinate @1 @2 @3 from_car $PLCAR offset  0.0 -3.0 -.50174: @4 = car $PLCAR z_angle0009: @4 +=  90.0;; floating-point values02CE: @5 = ground_z @1 @2 @3 0107: @6 = create_object #SATCHEL at @1 @2 @30249: release_model #SATCHEL 0177: set_object @6 z_angle_to @40051: return                           :EXPLODE00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF 020C: create_explosion_with_radius  10 at @1 @2 @3064B: @7 = create_particle "EXPLOSION_SMALL" at @1 @2 @3  1064C: make_particle @7 visible0108: destroy_object @60002: jump ££CARCHECKKEY :CRWCKPDD01C3: remove_references_to_car $PLCAR (This is for ease of coding as well, I can make a new car $PLCAR when my previous one broke down. Normally, I'd end the thread off course.)    0002: jump ££CARWEAPS       :PLDEF00D6: if 083CA:   NOT   object @6 exists004D: jump_if_false ££PLDEF_B0002: jump ££CARWEAPS   :PLDEF_B020C: create_explosion_with_radius  10 at @1 @2 @3064B: @7 = create_particle "EXPLOSION_SMALL" at @1 @2 @3  1064C: make_particle @7 visible0108: destroy_object @60002: jump ££CARWEAPS

 

 

I'm not very good at it, and I'd appreciate any help shortening it, or even someone telling me if it has to be shortened. Is it good as it is? Or can it be more compact? Thanks for any help. smile.gif

 

EDIT: Because there's no way I can let people save their bombdrop addition, I will do the following whenever the player is in a garage:

 

I check if the car is in one of the saving garages, if so, I display text, and I check if the player still in, always checking if the car's wrecked or the player is defined, and the moment the player is out, the script ends. (Restarts, because of the create_thread. It does restart after it ends, doesn't it?) Then, the whole thing can be done again, etc. smile.gif

 

I also add that only normal cars and bikes can drop bombs, no bicycles, planes, heli's, and boats. Though boats could be fun. tounge.gif

Edited by teun.steenbekkers
user posted image
Link to comment
Share on other sites

random_download

Couple of places you could make it slightly more compact without altering what the code actually does:

 

0002: jump ££KEYREL:KEYREL

 

0002: jump ££GOGO1:GOGO1

 

In those two places the jumps aren't needed as the code goes straight to the next label anyway.

 

 

:EXPLODE00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF

 

There you don't need the player_defined check, as there was already one since the last wait.

 

 

:CARWEAPS0001: wait 0 ms

 

The wait is not needed there, as the code will always go on to a wait just below it.

 

If you change what your code does, you could make it more compact. The check to see if the model is loaded could have the player_defined and in_car checks removed, as it doesn't matter if these change whilst the model is loading. You could also remove the same checks when checking to see if the key has been released. Alternativly, if you wanted to keep these checks you could use a gosub to them as you do the same ones 4 times in different places I think. Hope this helps smile.gif

Link to comment
Share on other sites

Quadropheniac90

Yeah, thanks! smile.gif One question though: How should I make that 'gosub' for the checks? Those checks all have a 'jump_if_false' of course, but I thought a 'gosub' always had to return. Now I think it'd just jump to another thread and stuff up, or something. Or am I way off here? biggrin.gif

 

Thanks for the help. smile.gif

user posted image
Link to comment
Share on other sites

random_download

Ahhh, you're right lol. You wouldn't be able to gosub but you could do:

 

:CARCHECKKEY0001: wait 0 [email protected] = ££CARCHECKKEY_20002: jump ££GosubTypeThing:CARCHECKKEY_200D6: if 00448:   actor $PLAYER_ACTOR in_car $PLCAR004D: jump_if_false ££CARCHECKKEY00D6: if 000E1:   key_pressed  0  17004D: jump_if_false ££CARCHECKKEY0002: jump ££KEYREL...:GosubTypeThing00D6: if 00256:   player $PLAYER_CHAR defined004D: jump_if_false ££PLDEF00D6: if 08119:   NOT   car $PLCAR wrecked004D: jump_if_false ££CRWCKPDD0002: jump @0

 

Which would probably make your code more compact, however it would mean that the game had to process extra commands. Sacrifice efficiency for space, or vica versa.

Link to comment
Share on other sites

Quadropheniac90

I'll stay with this one then. Now to add me a trigger.

user posted image
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.