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!

Lights on and off


Edmachine
 Share

Recommended Posts

Hi!

 

Well, I got my game crashed because I tried to get the LIGHTS ON AND OFF code from Back To Reality mod to another MAIN.SCM file ... probably I didnt do the right things but let me explain... I put this code(writen by myself)

004F: create_thread ££LIGHTS_1 

with other that like codes in ;-------------MAIN--------------- THEN I copied from BACK TO REALITY SCM file and chagned MAPINIT to LIGHTS this

:LIGHTS_103A4: name_thread 'LIGHTS' 004F: create_thread ££LIGHTS_6 004F: create_thread ££LIGHTS_8 004F: create_thread ££LIGHTS_30 004E: end_thread:LIGHTS_60001: wait  0 ms0006: $11019.75 =  0;; integer values:LIGHTS_80001: wait  0 ms00D6: if  0 0038:   $ON_MISSION ==  0;; integer values004D: jump_if_false ££LIGHTS_8 00D6: if  4 8018:   NOT   $11030.75 >  0;; integer values84A7:   NOT   actor $PLAYER_ACTOR driving_boat84C8:   NOT   actor $PLAYER_ACTOR driving_flying_vehicle00E1:   key_pressed  0  17 00DF:   actor $PLAYER_ACTOR driving004D: jump_if_false ££LIGHTS_8 0001: wait  300 ms00D6: if  0 00E1:   key_pressed  0  17 004D: jump_if_false ££LIGHTS_8 00D6: if  0 0018:   $11019.75 >  0;; integer values004D: jump_if_false ££LIGHTS_30 0006: $11019.75 =  0;; integer values067F: set_car $11026.75 headlights  2 0001: wait  300 ms0002: jump ££LIGHTS_8 :LIGHTS_300001: wait  0 ms0006: $11019.75 =  1;; integer values067F: set_car $11026.75 headlights  1 0001: wait  300 ms0002: jump ££LIGHTS_8 

 

 

And thinked: hmm... hope it works... pressed COMPILE button and runned SA... started a new game... first time tried every FIRE key in vehicle RESULT: Nothing Overlooked the codes and added the

004F: create_thread ££LIGHTS_1 

as I said earlier... COMPILE again... run SA... new game... oh and oh, well, sh*t happens smile.gif game crashed sad.gif Dont jugde me rough I am just a n00b at coding and scriptmaking stuff so help the young tounge.gif I am not sure how CSN make that code... are there any codes that I needed to put in??

We will be the arms that lift you up oqKntbC.gifWe will be the hand that strike you down

Link to comment
Share on other sites

Crashs, because your code have many errors...

 

Code have loops of creating threads...

 

How much time it may repeating itself ?

 

p.s.

Limit of threads - 96

 

p.p.s.

Use it:

 

:HEADLIGHTS

thread "HEADLIGHTS"

var

  [email protected] : Car = 0

  [email protected] : Integer = 0

  2@ : Integer = 0

  [email protected] : Integer = 0

end // var

 

while true              // on/off

wait 0

  if Actor.Driving($PLAYER_ACTOR)

  then

      0811: [email protected] = actor $PLAYER_ACTOR car

      if  [email protected] > 0

      then

          [email protected] += -1

      else

          if 00E1: key_pressed 0 7

          then

              [email protected] = 12

          end

          if 00E1: key_pressed 0 5

          then

              [email protected] = 12

          end

          if [email protected] > 0

          then

              [email protected] += -1

          else

              if 00E1: key_pressed 0 17

              then

                  if [email protected] == 0

                    then

                      067F: control_car [email protected] lights 2

                      [email protected] = 1

                      [email protected] = 12

                    else

                      067F: control_car [email protected] lights 1

                      [email protected] = 0

                      [email protected] = 12

                  end // if

              end

          end 

      end

  end

end

end_thread

 

 

Fire - on/off

Link to comment
Share on other sites

@ ASM: it is really nice that you are trying to help, peoples appreciate help here ,but you have to be very carefour and specified about that. do not give advise someone who is starting coding when you aren't sure about the lesson which you are about to give that person. please. one more please: spear yurself bouncing the ball back, it is not going to help.

 

@Edmachine:

1. there must be a simple check at the very beginning if $PLAYER is playing aka

0256:  player $PLAYER_ACTOR defined

 

2. there must be a definition for your global $11026.75 with command get_char_car aka

00d9: $11026.75 = actor $PLAYER_ACTOR car

after first check and after second check "is player driving"

you can create 4 threads no problem but you do not have to. create one thread. search the forum since there is a lot of examples, guides... take your time, do not rush into it.

Link to comment
Share on other sites

You didn't create the extra threads...

 

 

004F: create_thread ££LIGHTS_1

004F: create_thread ££LIGHTS_6

004F: create_thread ££LIGHTS_8

004F: create_thread ££LIGHTS_30

 

And that might, also be a 2, 3,4567..so on..? There is a mod with the d3d9.dll in it: http://jax.elite-tek.com/

Link to comment
Share on other sites

 

@Edmachine:

1. there must be a simple check at the very beginning if $PLAYER is playing aka

0256:  player $PLAYER_ACTOR defined

 

2. there must be a definition for your global $11026.75 with command get_char_car aka

00d9: $11026.75 = actor $PLAYER_ACTOR car

after first check and after second check "is player driving"

you can create 4 threads no problem but you do not have to. create one thread. search the forum since there is a lot of examples, guides... take your time, do not rush into it.

Aahhh.... where do I put them??? As I said: I don't know a sh*t about coding tounge.gif

We will be the arms that lift you up oqKntbC.gifWe will be the hand that strike you down

Link to comment
Share on other sites

Hi,

 

 

First create only one thread

004F: create_thread ��LIGHTS_1 

 

then you don't have to create a thread for every little ":LIGHTS_X".

 

Watch which opcode you are using, particulary with "maths" commands like :

 

 

0004: $11019.75 =  0;; integer values

is much better than what you've used (0006 is for locals "@s" and would crash the game if use with global "$s")

 

After that you code need to check if player is playing, then driving, to go to the rest of the code :

 

00D6: if  2      // if your compiler can handle it is equal to "and" 0256:   player $PLAYER_ACTOR defined  //player playing 00DF:   actor $PLAYER_ACTOR driving 0038:   $ON_MISSION ==  0;; integer values004D: jump_if_false ��LIGHTS_6  //put it with :LIGHTS_6 before 0004: $11019.75 = 0 separted from :LIGHTS_8

 

 

Once that's done the thread know that the player exist and is driving so you can tell him to remember what car is he driving, for that use what PLPynton told you, put it with :LIGHTS_6 after 0004: $11019.75 = 0 separted from :LIGHTS_8 :

 

 

00d9: $11026.75 = actor $PLAYER_ACTOR car

 

 

Now $11026.75 is the car that you're driving

Then you can do the if key pressed thingy in :LIGHTS_8 :

 

 

00D6: if  000E1:   key_pressed  0  17004D: jump_if_false ��LIGHTS_800D6: if  0   84A4: not  $11019.75 == 0 //this one is a magic opcode where you can use globals, locals, integers.... don't have to worry of the crash004D: jump_if_false ��LIGHTS_300004: $11019.75 =  0;; integer values  //0006 is for locals067F: set_car $11026.75 headlights  20001: wait  300 ms0002: jump ��LIGHTS_8:LIGHTS_300001: wait  0 ms0004: $11019.75 =  1;; integer values  //0006 is for locals067F: set_car $11026.75 headlights  10001: wait  300 ms0002: jump ��LIGHTS_8

 

 

 

And now what you wanted to code whould work. But there is something you havn't thought of !!!!! When your player will be changing vehicle your thread won't notice and will still be active on old one.

 

To avoid that you need a if that will check only if actor is still driving :

 

00D6: if  0 00DF:   actor $PLAYER_ACTOR driving004D: jump_if_false ��LIGHTS_6

 

Put it in top of :LIGHTS_8 (but AFTER wait 0 ms).

 

 

Then you should be fine. I hope I was clear enough so you can understand what I'm telling you. Hope you will get it to work.

 

 

Have fun

Edited by tomworld10
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.