Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2016-12-09, 12:34


Sexior







Wiek: 30
Na forum: 3601 dni
Posty: 29

Piwa: 11

Respekt: 40

Witam,
Ot?? mam problem z skryptem na hud, bo jak mam go wgranego i kilka skrypt?w z ogrpg to hud nie pokazuje si?.
Pomog? by kto??

Kod:


local font = dxCreateFont("font.otf", 33)

local sw,sh = guiGetScreenSize()

addEventHandler("onClientPreRender", root, function()
local x,y,z = getElementPosition(localPlayer)
local ulica = getZoneName(x,y,z, false)
local ulica2 = getZoneName(x,y,z, true)
if ulica2~=ulica then ulica = " "..ulica.."\n"..ulica2 else ulica = " "..ulica end
if dxSetAspectRatioAdjustmentEnabled then
dxSetAspectRatioAdjustmentEnabled(true)
end
if isPlayerHudComponentVisible("radar") and getElementInterior(localPlayer) == 0 then
dxDrawText(ulica, sw*4/20, sh*18/20, sw*4/20, sh*18/20+sh*1/21.9, tocolor(255,255,255,255), 0.33, font, "left", "center")
dxDrawRectangle(sw*2.5/20, sh*18/20, sw*0.7/4, sh*1/21.9, tocolor(inDMZone and 100 or 0, 0, 0, 100))
end
end)

resourceroot = getResourceRootElement(getThisResource())
local noreloadweapons = {} --Weapons that doesn't reload (including the flamethrower, minigun, which doesn't have reload anim).
noreloadweapons[16] = true
noreloadweapons[17] = true
noreloadweapons[18] = true
noreloadweapons[19] = true
noreloadweapons[25] = true
noreloadweapons[33] = true
noreloadweapons[34] = true
noreloadweapons[35] = true
noreloadweapons[36] = true
noreloadweapons[37] = true
noreloadweapons[38] = true
noreloadweapons[39] = true
noreloadweapons[41] = true
noreloadweapons[42] = true
noreloadweapons[43] = true

local meleespecialweapons = {} --Weapons that don't shoot, and special weapons.
meleespecialweapons[0] = true
meleespecialweapons[1] = true
meleespecialweapons[2] = true
meleespecialweapons[3] = true
meleespecialweapons[4] = true
meleespecialweapons[5] = true
meleespecialweapons[6] = true
meleespecialweapons[7] = true
meleespecialweapons[8] = true
meleespecialweapons[9] = true
meleespecialweapons[10] = true
meleespecialweapons[11] = true
meleespecialweapons[12] = true
meleespecialweapons[13] = true
meleespecialweapons[14] = true
meleespecialweapons[15] = true
meleespecialweapons[40] = true
meleespecialweapons[44] = true
meleespecialweapons[45] = true
meleespecialweapons[46] = true

local moneyChangeTable = {["tick"] = 0, ["amount"] = 0}

function convertNumber ( number )
local formatted = number
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if ( k==0 ) then
break
end
end
return formatted
end

local playerMoney = getPlayerMoney ( localPlayer )

addEventHandler("onClientRender", root, function()
if isPlayerMapVisible() then return end

showPlayerHudComponent("money", false)
showPlayerHudComponent("wanted", false)
showPlayerHudComponent("weapon", false)
showPlayerHudComponent("ammo", false)
showPlayerHudComponent("clock", false)
showPlayerHudComponent("health", false)
showPlayerHudComponent("armour", false)
showPlayerHudComponent("breath", false)

if getElementData(localPlayer, "zalogowany") then

ammoinclip = getPedAmmoInClip (getLocalPlayer()) -- The ammo inside the clip
totalammo = getPedTotalAmmo(getLocalPlayer())-getPedAmmoInClip(getLocalPlayer()) -- The total ammo minus ammo inside clip
totalammo2 = getPedTotalAmmo(getLocalPlayer())
showammo1 = ammoinclip
showammo2 = totalammo
showammo3 = totalammo2
health = getElementHealth( getLocalPlayer() )
lineLength1 = 114 * ( health / 100 ) -- Health bar

armor = getPedArmor( getLocalPlayer() )
lineLength2 = 114 * ( armor / 100 ) -- Armor bar


local hour, mins = getTime ()
time = hour .. ":" .. (((mins < 10) and "0"..mins) or mins)

local kasa = string.format("%08d", getPlayerMoney(getLocalPlayer()))

--dxDrawRectangle((sw - -700) / 2, (sh - 700) / 2, 100, 100, tocolor(0, 0, 0, 160))
--dxDrawRectangle((sw - -910) / 2, (sh - 700) / 2, 149, 40, tocolor(0, 0, 0, 160))
--dxDrawRectangle((sw - -910) / 2, (sh - 610) / 2, 149, 55, tocolor(0, 0, 0, 160))
dxDrawRectangle(sw*15.47/20, sh*1.24/20, sw*1.55/20, sh*2.5/20, tocolor(0, 0, 0, 160))
dxDrawRectangle(sw*17.1/20, sh*1.24/20, sw*2.34/20, sh*1/20, tocolor(0, 0, 0, 160))
dxDrawRectangle(sw*17.1/20, sh*2.4/20, sw*2.34/20, sh*1.35/20, tocolor(0, 0, 0, 160))
--dxDrawRectangle((sw - -700) / 2, (sh - 490) / 2, 254, 50, tocolor(0, 0, 0, 160))
dxDrawRectangle(sw*15.47/20, sh*3.85/20, sw*3.97/20, sh*1.1/20, tocolor(0, 0, 0, 160))
dxDrawRectangle(sw*2.5/20, sh*18.8/20, sw*0.7/4, sh*1.1/21.9, tocolor(inDMZone and 100 or 0, 0, 0, 100))
dxDrawText("Nick: "..getPlayerName(localPlayer).." UID: "..getElementData(localPlayer, "UID"), sw*4.6/20, sh*9.5/20, sw*4/20, sh*29/20, tocolor(250,250,250,200), 0.45, font, "center", "center")
--dxDrawText("PLN "..kasa.."", (sw - \-715) / 2, (sh - 480) / 2, (sw - -700) / 2, (sh - 490) / 2, tocolor(5, 89, 0, 255), 0.7, font, "left", "top", false, false, false, false, false)
dxDrawText("PLN "..kasa.."", sw*15.6/20, sh*3.9/20, sw*4/20, sh*27/20, tocolor(5, 89, 0, 255), 0.7, font, "left", "top", false, false, false, false, false)

dxDrawText(tostring (time),sw*20/20, sh*1.18/20, sw*16.4/20, sh*1/20,tocolor(250,250,250,200),0.8,font,"center","top",false,false,false)

tick = getTickCount ()

-- For active health bar
local maxHealth = 100; -- get max health stat
local colourPercent = ( health / maxHealth ) * 200;
local red, green; -- we don't need blue because we don't use it, it'll be 0
if health < ( maxHealth / 2 ) then
red = 200;
green = ( health / 50 ) * ( colourPercent * 2 );
else
green = 200;
red = 200 - ( ( health - 50 ) / 50 ) * 200;
end
-- For inactive health bar
local maxHealth = 75; -- get max health stat
local colourPercent1 = ( health / maxHealth ) * 75;
local red1, green1; -- we don't need blue because we don't use it, it'll be 0
if health < ( maxHealth / 2 ) then
red1 = 75;
green1 = ( health / 50 ) * ( colourPercent1 * 2 );
else
green1 = 75;
red1 = 75 - ( ( health - 50 ) / 50 ) * 75;
end
local color1 = tocolor( 0, 0, 0, 255 )
local color2 = tocolor( 255, 0, 0, 255 )

dxDrawRectangle(sw*17.2/20, sh*3.3/20, sw*1.88/20, sh*0.35/20,color1, false) -- Health inactive bar
dxDrawRectangle(sw*17.25/20, sh*3.35/20,lineLength1,sh*0.25/20,color2,false) --Health active bar

--[[if armor <= 0 then

else
dxDrawRectangle(sw*17.2/20, sh*2.85/20, sw*1.88/20, sh*0.35/20,tocolor(0,0,0,200),false)
dxDrawRectangle(sw*17.25/20, sh*2.9/20,lineLength2,sh*0.25/20,tocolor(200,200,200,200),false) -- Armor active bar -- Armor inactive bar
end]]

local weaponID = getPedWeapon (getLocalPlayer()); -- Get weaponzz ID
local weaponName = getWeaponNameFromID(weaponID)
dxDrawImage(sw*15.57/20, sh*1.14/20, sw*1.35/20, sh*2.3/20,"img/hud/".. tostring( weaponName ) .. ".png",0.0,0.0,0.0,tocolor(255,255,255,200),false)

if noreloadweapons [getPedWeapon(getLocalPlayer())] then
dxDrawText(sw*15.57/20, sh*1.14/20, sw*1.35/20, sh*2.3/20,tocolor(200,200,200,200),0.4,font,"right","top",false,false,false) -- No reload weapons (for shotgun, grenades, etc)

elseif meleespecialweapons [getPedWeapon(getLocalPlayer())] then
-- Draw Nothing for melee and special weapons.

else --Weapons that reloads.
dxDrawText(tostring (showammo2),(sw - -780) / 2, (sh - 540) / 2,(sw - -770) / 2, (sh - 700) / 2,tocolor(255,255,255,255),0.4,font,"right","top",false,false,false)
dxDrawText("|",(sw - -800) / 2, (sh - 540) / 2,(sw - -790) / 2, (sh - 700) / 2,tocolor(255,255,255,255),0.4,font,"left","top",false,false,false)
dxDrawText(tostring (showammo1),(sw - -820) / 2, (sh - 540) / 2,(sw - -810) / 2, (sh - 700) / 2,tocolor(255,255,255,255),0.4,font,"left","top",false,false,false)
end

else

end
end)


--[[addEventHandler("onClientRender", root, function()
if isPlayerMapVisible() then return end

showPlayerHudComponent("money", false)
showPlayerHudComponent("wanted", false)
showPlayerHudComponent("weapon", false)
showPlayerHudComponent("ammo", false)
showPlayerHudComponent("clock", false)
showPlayerHudComponent("health", false)
showPlayerHudComponent("armour", false)\
showPlayerHudComponent("breath", false)

ammoinclip = getPedAmmoInClip (getLocalPlayer()) -- Thze ammo inside the clip
totalammo = getPedTotalAmmo(getLocalPlayer())-getPedAmmoInClip(getLocalPlayer()) -- The total ammo minus ammo inside clip
totalammo2 = getPedTotalAmmo(getLocalPlayer())
showammo1 = ammoinclip
showammo2 = totalammo
showammo3 = totalammo2
health = getElementHealth( getLocalPlayer() )
lineLength1 = 114 * ( health / 100 ) -- Health bar

armor = getPedArmor( getLocalPlayer() )
lineLength2 = 114 * ( armor / 100 ) -- Armor bar


local hour, mins = getTime ()
time = hour .. ":" .. (((mins < 10) and "0"..mins) or mins)

local kasa = string.format("%08d", getPlayerMoney(getLocalPlayer()))

dxDrawRectangle((sw - -700) / 2, (sh - 700) / 2, 100, 100, tocolor(0, 0, 0, 160))
dxDrawRectangle((sw - -910) / 2, (sh - 700) / 2, 149, 40, tocolor(0, 0, 0, 160))
dxDrawRectangle((sw - -910) / 2, (sh - 610) / 2, 149, 55, tocolor(0, 0, 0, 160))
dxDrawRectangle((sw - -700) / 2, (sh - 490) / 2, 254, 50, tocolor(0, 0, 0, 160))
dxDrawText("Nick: "..getPlayerName(localPlayer).." UID: "..getElementData(localPlayer, "UID"), sw*2/20, sh*10/20, sw*4/20, sh*29/20, tocolor(250,250,250,200), 0.50, font, "center", "center")
dxDrawText("PLN "..kasa.."", (sw - -715) / 2, (sh - 480) / 2, (sw - -700) / 2, (sh - 490) / 2, tocolor(5, 89, 0, 255), 0.7, font, "left", "top", false, false, false, false, false)

dxDrawText(tostring (time),(sw - -1200) / 2, (sh - 705) / 2,(sw - -910) / 2, (sh - 700) / 2,tocolor(250,250,250,200),0.8,font,"center","top",false,false,false)

tick = getTickCount ()

-- For active health bar
local maxHealth = 100; -- get max health stat
local colourPercent = ( health / maxHealth ) * 200;
local red, green; -- we don't need blue because we don't use it, it'll be 0
if health < ( maxHealth / 2 ) then
red = 200;
green = ( health / 50 ) * ( colourPercent * 2 );
else
green = 200;
red = 200 - ( ( health - 50 ) / 50 ) * 200;
end
-- For inactive health bar
local maxHealth = 75; -- get max health stat
local colourPercent1 = ( health / maxHealth ) * 75;
local red1, green1; -- we don't need blue because we don't use it, it'll be 0
if health < ( maxHealth / 2 ) then
red1 = 75;
green1 = ( health / 50 ) * ( colourPercent1 * 2 );
else
green1 = 75;
red1 = 75 - ( ( health - 50 ) / 50 ) * 75;
end
local color1 = tocolor( 0, 0, 0, 255 )
local color2 = tocolor( 255, 0, 0, 255 )

-- For the health bar
if getTickCount () %1500 < 500 and health <= 20 and armor <=0 then -- If health is less than 20%, armor is 0%, the health bar will blink by hiding the health bar every 1.5 seconds.

else
dxDrawRectangle((sw - -950) / 2, (sh - 550) / 2,114.0,10.0,color1, false) -- Health inactive bar
dxDrawRectangle((sw - -950) / 2, (sh - 550) / 2,lineLength1,11.0,color2,false) --Health active bar
end

if armor <= 0 then

else
dxDrawRectangle(sWidth-206,sHeight-43,lineLength2,10.0,tocolor(200,200,200,200),false) -- Armor active bar
dxDrawRectangle(sWidth-206,sHeight-43,114.0,10.0,tocolor(50,50,50,150),false) -- Armor inactive bar
end

local weaponID = getPedWeapon (getLocalPlayer()); -- Get weapon ID
local weaponName = getWeaponNameFromID(weaponID)
dxDrawImage((sw - -710) / 2, (sh - 705) / 2, 90, 90,"img/hud/".. tostring( weaponName ) .. ".png",0.0,0.0,0.0,tocolor(255,255,255,200),false)

if noreloadweapons [getPedWeapon(getLocalPlayer())] then
dxDrawText(tostring (showammo3),(sw - -700) / 2, (sh - 700) / 2,(sw - -700) / 2, (sh - 700) / 2,tocolor(0,255,255,200),0.4,font,"right","top",false,false,false) -- No reload weapons (for shotgun, grenades, etc)

elseif meleespecialweapons [getPedWeapon(getLocalPlayer())] then
-- Draw Nothing for melee and special weapons.

else --Weapons that reloads.
dxDrawText(tostring (showammo2),(sw - -780) / 2, (sh - 540) / 2,(sw - -770) / 2, (sh - 700) / 2,tocolor(255,255,255,255),0.4,font,"right","top",false,false,false)
dxDrawText("|",(sw - -800) / 2, (sh - 540) / 2,(sw - -790) / 2, (sh - 700) / 2,tocolor(255,255,255,255),0.4,font,"left","top",false,false,false)
dxDrawText(tostring (showammo1),(sw - -820) / 2, (sh - 540) / 2,(sw - -810) / 2, (sh - 700) / 2,tocolor(255,255,255,255),0.4,font,"left","top",false,false,false)
end
end)]]




Ostatnio zmieniony przez Sexior 2016-12-09, 13:07, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-12-09, 12:58


zabijaka2000







Wiek: 26
Na forum: 4983 dni
Posty: 147
Nick w MP: aleks556

Piwa: 13

Respekt: 80

Ostrzeżeń: 20%
Je?li s? komunikaty w db3 to je podaj. Kod tez mo?esz, bo ma?o komu b?dzie si? chcia?o to pobiera?.

[ Dodano: 2016-12-09, 15:38 ]
Wydaj? mi si?, ?e przy logowaniu nie nadaje Ci daty "zalogowany".

Podpis
San Fierro Stories Roleplay
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: działa :: hud
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku