OffRoader23 Posted February 16, 2008 Posted February 16, 2008 I'm trying to run a check if speed is higher then 30 MPH and under 250 MPH, how would I do that? I know it would be like function blah ( ) local shpeed = getPlayerSpeed ( player, 1) if shpeed >= 30 and shpeed <= 250 then do crap else dont do crap end end What would I replaced and with? &? ||? or?
norby89 Posted February 16, 2008 Posted February 16, 2008 lua uses and / or so 'and' would be correct
Mr.Hankey Posted February 16, 2008 Posted February 16, 2008 as there's no getPlayerSpeed function i think you should do it like this =) (at least the wiki says this is the way to calculate the speed) function blah () local speedx, speedy, speedz = getElementVelocity ( player ) local speed = (speedx^2 + speedy^2 + speedz^2)^(0.5) if speed >= 30 and speed <= 250 then do crap else don't do crap end end
OffRoader23 Posted February 16, 2008 Author Posted February 16, 2008 But I tried and it it's like OMFG SYNTAX.... Maybe I did something wrong, I'll try it again and post results, thanks. And yea, I know, my script has getPlayerSpeed function released by that guy a while back, I have code that works already but am trying to get a range from 30-250 for a speed boost script when you hold accelerate.
OffRoader23 Posted February 16, 2008 Author Posted February 16, 2008 Nevermind, I'm dumb, I don't know what I did wrong before but it works fine now. I think I did if speed => 30 and <= 250. What is the key called for reverse/brakes when your in the car? if ( getControlState ( v, "accelerate") ) then works for accelerate if ( getControlState ( v, "brakes") ) then doesn't. Thanks for the help btw.
norby89 Posted February 16, 2008 Posted February 16, 2008 it's "brake_reverse" http://development.mtasa.com/index.php? ... trol_names
OffRoader23 Posted February 16, 2008 Author Posted February 16, 2008 Ohhhh never seen that page before. Very useful. Thanks!
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