Search In
• More options...
Find results that contain...
Find results in...

# A little question

## Recommended Posts

How can i make a code that when a car speeds up to 88 miles per hours and something would happen?

##### Share on other sites

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;========`

##### Share on other sites
LOT of stuff missing. Also you would want a greater than equal check. Not to mention that 02E3 captures a float.
##### Share on other sites

What is the Opcode 0811, I can't find it in the list of opcodes

##### Share on other sites

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 by ceedj
##### Share on other sites
@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.
##### Share on other sites
@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.

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites

`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.

##### Share on other sites

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 by Demarest
##### Share on other sites

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!

## Create an account

Register a new account

×