Jump to content

[SOLVED]Gui with IPod as Background


Recommended Posts

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

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 by Guest
Link to comment
this is more compact

use getPlayerSpeed(getLocalPlayer(),true/false), and it works clientside too.

even more compact :D

  
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
this is more compact

use getPlayerSpeed(getLocalPlayer(),true/false), and it works clientside too.

even more compact :D

  
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

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

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? :D

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...