hm..
Wiek: 26 Na forum: 2569 dni Posty: 50
Nick w MP: Pan_Cebulka_YT
Piwa : 3
Wilq , ale w?a?nie nie wiem gdzie to jest
[ Dodano : 2020-01-11, 16:28 ]
local sx , sy = guiGetScreenSize ()
local px , py = ( sx / 1920 ), ( sy / 1080 )
screenW , screenH = guiGetScreenSize ()
local anims , builtins = {}, { "Linear" , "InQuad" , "OutQuad" , "InOutQuad" , "OutInQuad" , "InElastic" , "OutElastic" , "InOutElastic" , "OutInElastic" , "InBack" , "OutBack" , "InOutBack" , "OutInBack" , "InBounce" , "OutBounce" , "InOutBounce" , "OutInBounce" , "SineCurve" , "CosineCurve" }
function table . find ( t , v )
for k , a in ipairs ( t ) do
if a == v then
return k
end
end
return false
end
function animate ( f , t , easing , duration , onChange , onEnd )
assert ( type ( f ) == "number" , "Bad argument @ 'animate' [expected number at argument 1, got " .. type ( f ).. "]" )
assert ( type ( t ) == "number" , "Bad argument @ 'animate' [expected number at argument 2, got " .. type ( t ).. "]" )
assert ( type ( easing ) == "string" or ( type ( easing ) == "number" and ( easing >= 1 or easing <= #builtins)), "Bad argument @ 'animate' [Invalid easing at argument 3]")
assert ( type ( duration ) == "number" , "Bad argument @ 'animate' [expected function at argument 4, got " .. type ( duration ).. "]" )
assert ( type ( onChange ) == "function" , "Bad argument @ 'animate' [expected function at argument 5, got " .. type ( onChange ).. "]" )
table . insert ( anims , { from = f , to = t , easing = table . find ( builtins , easing ) and easing or builtins [ easing ], duration = duration , start = getTickCount ( ), onChange = onChange , onEnd = onEnd })
return #anims
end
function destroyAnimation ( a )
if anims [ a ] then
table . remove ( anims , a )
end
end
addEventHandler ( "onClientRender" , root , function( )
local now = getTickCount ( )
for k , v in ipairs ( anims ) do
v . onChange ( interpolateBetween ( v . from , 0 , 0 , v . to , 0 , 0 , ( now - v . start ) / v . duration , v . easing ))
if now >= v . start + v . duration then
if type ( v . onEnd ) == "function" then
v . onEnd ( )
end
table . remove ( anims , k )
end
end
end )
fonts = {
dxCreateFont ( "Roboto-Bold.ttf" , 15 ),
dxCreateFont ( "Roboto-Light.ttf" , 17 ),
}
speedo = {
dxCreateTexture ( ":pystories-licznik/bg.png" , "argb" , true , "clamp" ),
}
function math . round ( number , decimals , method )
decimals = decimals or 0
local factor = 10 ^ decimals
if ( method == "ceil" or method == "floor" ) then return math [ method ]( number * factor ) / factor
else return tonumber (( "%." .. decimals .. "f" ): format ( number )) end
end
function getElementSpeed ( theElement , unit )
-- Check arguments for errors
assert ( isElement ( theElement ), "Bad argument 1 @ getElementSpeed (element expected, got " .. type ( theElement ) .. ")" )
local elementType = getElementType ( theElement )
assert ( elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile" , "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")" )
assert (( unit == nil or type ( unit ) == "string" or type ( unit ) == "number" ) and ( unit == nil or ( tonumber ( unit ) and ( tonumber ( unit ) == 0 or tonumber ( unit ) == 1 or tonumber ( unit ) == 2 )) or unit == "m/s" or unit == "km/h" or unit == "mph" ), "Bad argument 2 @ getElementSpeed (invalid speed unit)" )
-- Default to m / s if no unit specified and 'ignore' argument type if the string contains a number
unit = unit == nil and 0 or (( not tonumber ( unit )) and unit or tonumber ( unit ))
-- Setup our multiplier to convert the velocity to the specified unit
local mult = ( unit == 0 or unit == "m/s" ) and 50 or (( unit == 1 or unit == "km/h" ) and 180 or 111.84681456 )
-- Return the speed by calculating the length of the velocity vector , after converting the velocity to the specified unit
return ( Vector3 ( getElementVelocity ( theElement )) * mult ). length
end
local sw , sh = guiGetScreenSize ()
local scale = 1920 / sw
addEventHandler ( "onClientRender" , getRootElement (), function()
local pojazd = getPedOccupiedVehicle ( localPlayer )
if pojazd then
if getVehicleName ( pojazd ) == "Reefer" then return end
if getElementData ( pojazd , "vehicle.selling" ) then return end
id = getElementData ( pojazd , "vehicle:id" )
local sx , sy , sz = getElementVelocity ( pojazd )
local predkosc = math . ceil ((( sx ^ 2 + sy ^ 2 + sz ^ 2 )^( 0.5 )) * 171 )
local nazwa = getVehicleName ( pojazd )
local poj = getElementData ( pojazd , "vehicle:pojemnosc" ) or ""
-- local speed = GetVehicleSpeed () > 285 and math . random ( 279 , 280 ) or GetVehicleSpeed ()
local km = getElementData ( pojazd , "vehicle:mileage" ) or 0
if poj == 2 then poj = 1.4 end
if poj == 3 then poj = 1.6 end
if poj == 4 then poj = 1.8 end
if poj == 5 then poj = 2.2 end
if poj == 6 then poj = 2.4 end
jednostka = "L"
if getVehicleName ( pojazd ) == "Alpha" then jednostka = "%" end
local bak = getElementData ( pojazd , "bak" ) or 100
local paliwo = getElementData ( pojazd , "vehicle:fuel" ) or 100
r , g , b = 230 , 230 , 230
dxDrawImage ( 1398 / scale , 970 / scale , 522 / scale , 90 / scale , speedo [ 1 ], 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( string . format ( '%03d' , predkosc ).. " km/h" , 1409 / scale , 1151 / scale , 1585 / scale , 884 / scale , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , fonts [ 1 ], "center" , "center" , false , false , false , false , false )
dxDrawText ( string . format ( '%.0f' , km ).. " km" , 1552 / scale , 1151 / scale , 1779 / scale , 884 / scale , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , fonts [ 1 ], "center" , "center" , false , false , false , false , false )
dxDrawText ( string . format ( '%.0f' , paliwo ).. "/" .. bak .. " " .. jednostka , 1701 / scale , 1151 / scale , 1945 / scale , 884 / scale , tocolor ( 0 , 0 , 0 , 255 ), 1.00 , fonts [ 1 ], "center" , "center" , false , false , false , false , false )
dxDrawText ( string . format ( '%03d' , predkosc ).. " km/h" , 1408 / scale , 1150 / scale , 1584 / scale , 883 / scale , tocolor ( r , g , b , 255 ), 1.00 , fonts [ 1 ], "center" , "center" , false , false , false , false , false )
dxDrawText ( string . format ( '%.0f' , km ).. " km" , 1552 / scale , 1150 / scale , 1778 / scale , 883 / scale , tocolor ( r , g , b , 255 ), 1.00 , fonts [ 1 ], "center" , "center" , false , false , false , false , false )
dxDrawText ( string . format ( '%.0f' , paliwo ).. "/" .. bak .. " " .. jednostka , 1700 / scale , 1150 / scale , 1944 / scale , 883 / scale , tocolor ( r , g , b , 255 ), 1.00 , fonts [ 1 ], "center" , "center" , false , false , false , false , false )
end
end )
[ Dodano : 2020-01-11, 16:28 ]
to jest licznik