marty_1985 0 Posted August 24, 2005 Share Posted August 24, 2005 How can i make a code that when a car speeds up to 88 miles per hours and something would happen? Link to post Share on other sites
wauzie 1 Posted August 24, 2005 Share Posted August 24, 2005 Something like this: EDIT: i'll put it in Codes :Label0811: $Playercar = actor $PLAYER_ACTOR car02E3: $Carspeed = car $Playercar speed:Labelcheckif 0$Carspeed == 88jf ££Labelcheck;========;activation;======== Link to post Share on other sites
Demarest 24 Posted August 24, 2005 Share Posted August 24, 2005 LOT of stuff missing. Also you would want a greater than equal check. Not to mention that 02E3 captures a float. Link to post Share on other sites
marty_1985 0 Posted August 25, 2005 Author Share Posted August 25, 2005 What is the Opcode 0811, I can't find it in the list of opcodes Link to post Share on other sites
ceedj 29 Posted August 25, 2005 Share Posted August 25, 2005 (edited) Untested, but should work... 004F: create_thread ££DrivingCheck:DrivingCheck0001: wait 50 ms00D6: if 000E0: player $PLAYER_CHAR driving004D: jump_if_false ££DrivingCheck03C1: $PlayerCar = player $PLAYER_CHAR car;; gets the player car:SpeedCheck02E3: $Speed = car $PlayerCar speed;; gets the car's speed as a float0001: wait 250 ms00D6: if 00030: $Speed >= 40.0;; floating-point values004D: jump_if_false ££SpeedCheck----do stuff here--------jump to wherever when finished---- Max speed is 50.0, so you'll have to figure out a way to get your "88" speed converted to something the game can recognize. I used 40.0 beacuse that's pretty fast, but not the max speed. 30.0 to 35.0 might be even closer. You MAY want to put a check in to see if a player is defined, but if the player is in a car, it's a pretty safe bet that that player is defined. Check out the Love Fist mission "Publicity Tour" for a good example of this... Have fun! Edited August 25, 2005 by ceedj Link to post Share on other sites
Quadropheniac90 3 Posted August 25, 2005 Share Posted August 25, 2005 @ceedj: You should place waits in front of the '00D6: if 0', it jumps back to itself when it's false, and then it needs a wait, or it'll crash. Link to post Share on other sites
ceedj 29 Posted August 25, 2005 Share Posted August 25, 2005 @ceedj: You should place waits in front of the '00D6: if 0', it jumps back to itself when it's false, and then it needs a wait, or it'll crash. Ack, you're right. Been coding in C++ for a while now; most of the if's I use in that do not need the waits. Thanks for the heads up; post edited. Link to post Share on other sites
Demarest 24 Posted August 25, 2005 Share Posted August 25, 2005 You MAY want to put a check in to see if a player is defined, but if the player is in a car, it's a pretty safe bet that that player is defined. If player is not defined, using a check like "if player driving" risks crashing the engine by referencing that doesn't exist. Never seen it happen, but is good coding. Just pointing out the REASON why it's used instead of encouraging others to cross their fingers. Link to post Share on other sites
ceedj 29 Posted August 25, 2005 Share Posted August 25, 2005 You MAY want to put a check in to see if a player is defined, but if the player is in a car, it's a pretty safe bet that that player is defined. If player is not defined, using a check like "if player driving" risks crashing the engine by referencing that doesn't exist. Never seen it happen, but is good coding. Just pointing out the REASON why it's used instead of encouraging others to cross their fingers. You are correct. It IS good coding. I've just never had a need for checking to see if my player is defined, so I've never used it. Link to post Share on other sites
random_download 0 Posted August 26, 2005 Share Posted August 26, 2005 00D6: if 00030: $Speed >= 40.0;; floating-point values004D: jump_if_false ££SpeedCheck Here you should probably jump to label :DrivingCheck as if the player gets out of the car before reaching the speed, the code will continue to loop, and possibly crash if the car gets destroyed. Link to post Share on other sites
Demarest 24 Posted August 26, 2005 Share Posted August 26, 2005 (edited) Yes and no. The code as it sits would not benefit from jumping back. Also, I think the timings are backwards. Should look more like (in MB 0.22) :LabelMYMOD03A4: name_thread "88MPH":LabelMYMOD10001: wait 250& ms00D6: if 0?0256: player $PLAYER_CHAR defined004D: jump_if_false ££LabelMYMOD100D6: if 000E0: player $PLAYER_CHAR driving004D: jump_if_false ££LabelMYMOD103C1: [email protected] = player $PLAYER_CHAR car;; gets the player car:LabelMYMOD20001: wait 50? ms00D6: if 1?0256: player $PLAYER_CHAR defined0119: NOT car [email protected] wrecked004D: jump_if_false ££LabelMYMOD300D6: if 0?0442: player $PLAYER_CHAR in_car [email protected]: jump_if_false £LabelMYMOD302E3: [email protected] = car [email protected] speed00D6: if 00031: [email protected] >= 40.0;; floating-point values004D: jump_if_false ££LabelMYMOD2;----- stuff you want done when target speed is reached:LabelMYMOD301C3: remove_references_to_car [email protected]: jump ££LabelMYMOD1 Note that as before, the author is reponsible for clearing the car out of memory and either terminating the thread or having it jump back after the appropriate conditions are met. As always, watched for infinite loops! [EDIT] The timings were missing datatypes and the is not wrecked check wasn't in the best if. Edited August 26, 2005 by Demarest Link to post Share on other sites
damian001 158 Posted August 31, 2005 Share Posted August 31, 2005 marty_1985, while reading your username and your question, you also sound like a back to the future fan as well as I am there is a mod somewhere here called Vice City XXL. It has a delorean that when you hit 88 mph, it shows a COOL time travel effect (looks just like from the movie) and you respawn somewhere else and in a different time try to find it! Link to post Share on other sites