Edmachine Posted June 9, 2006 Share Posted June 9, 2006 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 game crashed Dont jugde me rough I am just a n00b at coding and scriptmaking stuff so help the young 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 We will be the hand that strike you down Link to comment Share on other sites More sharing options...
_ASM_ Posted June 9, 2006 Share Posted June 9, 2006 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 More sharing options...
_ASM_ Posted June 9, 2006 Share Posted June 9, 2006 p.p.p.s. So, this code written for Sanny Builder 2.96 (and over) Link to comment Share on other sites More sharing options...
PLPynton Posted June 9, 2006 Share Posted June 9, 2006 @ 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 More sharing options...
stan101 Posted June 9, 2006 Share Posted June 9, 2006 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 More sharing options...
Edmachine Posted June 10, 2006 Author Share Posted June 10, 2006 @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 We will be the arms that lift you up We will be the hand that strike you down Link to comment Share on other sites More sharing options...
tomworld10 Posted June 10, 2006 Share Posted June 10, 2006 (edited) 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 June 11, 2006 by tomworld10 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now