Üdv.
Vehicle Infos v1.0
Elkészítettem az első publikus scriptemet.
Képek: http://www.kephost.com/images/2015/05/30/mta-screen_2015-05-30_01-03-46.png[/img]
http://www.kephost.com/images/2015/05/30/mta-screen_2015-05-30_01-11-39.png[/img]
Letöltési link:
http://www.solidfiles.com/d/f0ace1e7b4/Várható fejlesztések:
- Jármű max férőhelyeinek száma
- Járműben ülők száma
- Járműben ülő játékosok nevei
<meta>
<info author=\"Norby\" name=\"Vehicle Informations Bar\" version=\"1.0\" type=\"script\" />
<script src=\"script.lua\" type=\"client\" />
</meta>
screenW, screenH = guiGetScreenSize()
function clientRender()
if isPedInVehicle( localPlayer ) then
local vehicleName = getVehicleName(getPedOccupiedVehicle( localPlayer ))
local health = math.round(getElementHealth(getPedOccupiedVehicle( localPlayer )) / 10, 1)
local healthProgress = health / 100
local healthDXW = (screenW * 0.3175) - (screenW * 0.1590)
local speed = math.round(getElementSpeed(getPedOccupiedVehicle( localPlayer ), 1))
local speedProgress = speed / 221
local speedDXW = (screenW * 0.3175) - (screenW * 0.1590)
dxDrawLine((screenW * 0.7806) - 1, (screenH * 0.2911) - 1, (screenW * 0.7806) - 1, screenH * 0.4644, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.9521, (screenH * 0.2911) - 1, (screenW * 0.7806) - 1, (screenH * 0.2911) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine((screenW * 0.7806) - 1, screenH * 0.4644, screenW * 0.9521, screenH * 0.4644, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.9521, screenH * 0.4644, screenW * 0.9521, (screenH * 0.2911) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawRectangle(screenW * 0.7806, screenH * 0.2911, screenW * 0.1715, screenH * 0.1733, tocolor(5, 0, 0, 150), false)
dxDrawText(vehicleName, screenW * 0.7868, screenH * 0.3011, (screenW * 0.7868) + 228, ( screenH * 0.3011) + 25, tocolor(255, 255, 255, 255), 1.00, \"sans\", \"center\", \"center\", false, false, true, false, false) dxDrawLine((screenW * 0.7868) - 1, (screenH * 0.3378) - 1, (screenW * 0.7868) - 1, screenH * 0.3689, tocolor(191, 0, 0, 200), 1, false)
dxDrawLine(screenW * 0.9451, (screenH * 0.3378) - 1, (screenW * 0.7868) - 1, (screenH * 0.3378) - 1, tocolor(191, 0, 0, 200), 1, false)
dxDrawLine((screenW * 0.7868) - 1, screenH * 0.3689, screenW * 0.9451, screenH * 0.3689, tocolor(191, 0, 0, 200), 1, false)
dxDrawLine(screenW * 0.9451, screenH * 0.3689, screenW * 0.9451, (screenH * 0.3378) - 1, tocolor(191, 0, 0, 200), 1, false)
dxDrawRectangle(screenW * 0.7868, screenH * 0.3378, screenW * 0.1583, screenH * 0.0311, tocolor(191, 0, 0, 0), false)
dxDrawRectangle(screenW * 0.7868, screenH * 0.3378, healthDXW*healthProgress , screenH * 0.0311, tocolor(191, 0, 0, 100), false)
dxDrawText(\"Health: \"..health..\"%\", screenW * 0.7861, screenH * 0.3378, screenW * 0.9444, screenH * 0.3678, tocolor(255, 255, 255, 255), 0.50, \"bankgothic\", \"center\", \"center\", false, false, false, false, false) dxDrawLine((screenW * 0.7868) - 1, (screenH * 0.3789) - 1, (screenW * 0.7868) - 1, screenH * 0.4111, tocolor(15, 147, 239, 255), 1, false)
dxDrawLine((screenW * 0.7868) - 1, (screenH * 0.3789) - 1, (screenW * 0.7868) - 1, screenH * 0.4111, tocolor(15, 147, 239, 255), 1, false)
dxDrawLine(screenW * 0.9451, (screenH * 0.3789) - 1, (screenW * 0.7868) - 1, (screenH * 0.3789) - 1, tocolor(15, 147, 239, 255), 1, false)
dxDrawLine((screenW * 0.7868) - 1, screenH * 0.4111, screenW * 0.9451, screenH * 0.4111, tocolor(15, 147, 239, 255), 1, false)
dxDrawLine(screenW * 0.9451, screenH * 0.4111, screenW * 0.9451, (screenH * 0.3789) - 1, tocolor(15, 147, 239, 255), 1, false)
dxDrawRectangle(screenW * 0.7868, screenH * 0.3789, screenW * 0.1583, screenH * 0.0322, tocolor(15, 147, 239, 0), false)
dxDrawRectangle(screenW * 0.7868, screenH * 0.3789, speedDXW*speedProgress, screenH * 0.0333, tocolor(15, 147, 239, 100), false)
dxDrawText(speed..\" km/h\", screenW * 0.7868, screenH * 0.3800, screenW * 0.9444, screenH * 0.4111, tocolor(255, 255, 255, 255), 1.00, \"sans\", \"center\", \"center\", false, false, false, false, false)
end
end
addEventHandler(\"onClientResourceStart\", resourceRoot,
function()
addEventHandler(\"onClientRender\", root, clientRender)
end
)
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) .. \")\")
assert(getElementType(theElement) == \"player\" or getElementType(theElement) == \"ped\" or getElementType(theElement) == \"object\" or getElementType(theElement) == \"vehicle\", \"Invalid element type @ getElementSpeed (player/ped/object/vehicle expected, got \" .. getElementType(theElement) .. \")\")
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