cokacola Posted June 6, 2011 Share Posted June 6, 2011 (edited) Hey I got 3 questions for you guys: 1.My cars have 100 fuel when first spawned. At the moment, there is preset fuel decreases depending on your speed. I was wondering if there is some form of math equation for fuel reduction based on the speed, so I won't have to write like 30 IF statements in my code. 2.How do I create a little red bar that slowly goes down to reflect the amount of fuel(between 0 and 100) that the car has(only visible to the occupants of the vehicle, or possibly the driver) --not asking for code, just some hints / tips / functions on how to do this myself, I don't like asking people to make my scripts for me, its not right {solved} 3.If the above question is answered, how can I create rounded text in the center of the bar? I know the serverside code for adding text, but got no idea on how to round it, so it isn't like "89.44356454", but rather just "89".{solved} So, for any people who can help me, I thank you Edited June 6, 2011 by Guest Link to comment
Aibo Posted June 6, 2011 Share Posted June 6, 2011 1. well figure out a formula yourself. take your consumption on mimimum speed and maximum speed, and devise a formula that would produce these value on similar speeds? though maybe someone got better suggestions. 2. dxDrawImage (if you want some fancy bar) that you can stretch or simple dxDrawRectangle. "going down" can be made by setting the image/rectangle height/Y according to fuel amount. you can also try guiCreateStaticImage and resizing that (though i prefer dx drawin for dynamic stuff). as for showing it vehicle occupant, add onClientVehicleEnter(Exit) event handler that will show/hide the bar to the player that entered. 3. use dxDrawText with center X alignment (or guiCreateLabel if you're going with gui). as for rounding you can use Lua's math.ceil(), math.floor(), math.modf() for that. Link to comment
cokacola Posted June 6, 2011 Author Share Posted June 6, 2011 Okay, thanks I'll look into the GUI functions. As for the math, I'd have figured it out myself, but I seem to be bad at math(not even sure where to start ) Link to comment
karlis Posted June 6, 2011 Share Posted June 6, 2011 if you don't like linear increase in cost of fuel, you could wait until 1.1 and use getEasingValue() for some function you think that will fit Link to comment
Moderators Citizen Posted June 6, 2011 Moderators Share Posted June 6, 2011 Personnaly I use a squarre function ( i.e: speed^2 ) but then you have to reduce it with / ( ie : (speed^2)/60 ) and change 60 and make test until you think that's a good fuel decrease. ( My system use the consomation of the vehicules ie: 3 L/100Km ) Link to comment
karlis Posted June 6, 2011 Share Posted June 6, 2011 also it'd be cool to take note of car weight and maximum velocity from 1.1 ownwards, and we all know normal car consumes least fuel not driving at 5kph, but at ~50-100(not sure the exact amount). Link to comment
Moderators Citizen Posted June 6, 2011 Moderators Share Posted June 6, 2011 Yeah I made that if my car have a consomation of 8 L/100Km it's only if you stay at 50Km/h Link to comment
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