BriGhtx3 Posted May 28, 2011 Share Posted May 28, 2011 (edited) I want to ask how i can create a gui like this : 2. How do i create a speedometer? I want to make one by myself, but i don't know how to get the Player speed and to rotate the needle. Edited May 28, 2011 by Guest Link to comment
Aibo Posted May 28, 2011 Share Posted May 28, 2011 gui iblabla image is created by using guiCreateStaticImage or dxDrawImage. and other gui functions: https://wiki.multitheftauto.com/wiki/Cli ... _functions speed is calculated from vehicle element velocity (see example): https://wiki.multitheftauto.com/wiki/GetElementVelocity then resulting speed is passed to dxDrawImage of a needle as rotation parameter (adjusted to some degree range if needed) Link to comment
karlis Posted May 28, 2011 Share Posted May 28, 2011 (edited) this is more compact function getPlayerSpeed(player,mph) local multiplier=mph and 100 or 161 --in case mph argument is true, it will return speed in mph, else-kph local velX,velY,velZ=getElementVelocity(getPedOccuipiedVehicle(player) or player) return (velx^2+velY^2+velZ^2)^0.5*multiplier end use getPlayerSpeed(getLocalPlayer(),true/false), and it works clientside too. Edited May 28, 2011 by Guest Link to comment
BriGhtx3 Posted May 28, 2011 Author Share Posted May 28, 2011 Thanks to both of you First I create my IPOD/Cellphone then a Speedometer. Link to comment
Aibo Posted May 28, 2011 Share Posted May 28, 2011 this is more compactuse getPlayerSpeed(getLocalPlayer(),true/false), and it works clientside too. even more compact function getPlayerSpeed(player,mph) local velX,velY,velZ=getElementVelocity(getPedOccuipiedVehicle(player) or player) return (velx^2+velY^2+velZ^2)^0.5*(mph and 100 or 161) end Link to comment
karlis Posted May 28, 2011 Share Posted May 28, 2011 this is more compactuse getPlayerSpeed(getLocalPlayer(),true/false), and it works clientside too. even more compact getPlayerSpeed(player,mph) local velX,velY,velZ=getElementVelocity(getPedOccuipiedVehicle(player) or player) return (velx^2+velY^2+velZ^2)^0.5*(mph and 100 or 161) end true, but omg what i was a noob, i forgot to put "function" word at first!! EDIT:lol how we found it out same time. Link to comment
BriGhtx3 Posted May 28, 2011 Author Share Posted May 28, 2011 Why is here an error? Debugscript doesn't say anything, and when i press F4 or type /handy, the image doesn't show oO function IPhone() local x,y = guiGetScreenSize() guiCreateStaticImage( 20,200, 229, 405, "bg.png", false ) end addCommandHandler("handy", IPhone) bindKey("F4", "down", IPhone) Link to comment
Aibo Posted May 28, 2011 Share Posted May 28, 2011 have you added your image to meta.xml? Link to comment
karlis Posted May 28, 2011 Share Posted May 28, 2011 define gui size before the function, as it doesn't change. Link to comment
BriGhtx3 Posted May 28, 2011 Author Share Posted May 28, 2011 What do you mean? Edit : I added onClientResourceStart, and I didn't see it too. I think the position is wrong. But why? Edit 2 : Got it! phone = guiCreateStaticImage( screenWidth/2 - 299, screenHeight - 380, 229, 405, "bg.png", false ) My error? The client.lua file was in the Handy folder. The image too. In the meta the image is in the handy folder but in the code is written : bg.png. The paths weren't the same but both right. And now : How do I hide it? Link to comment
karlis Posted May 28, 2011 Share Posted May 28, 2011 guiSetVisible(element gui-widget,bool visible) 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