Wysłany: 2022-08-04, 14:29
bobson987
Wiek: 22 Na forum: 1433 dni Posty: 6
Nick w MP: bobson987
Piwa : 124
Witam potrzebuje pomocy w skalowaniu hudu
rozdzialka:1366x768x32
rozdzialka:1024x768x32
Kod: local screenW, screenH = guiGetScreenSize()
local zoom = exports.nrpg_interface:getInterfaceZoom()
local hudPos = {x=math.floor(screenW/2+1010/zoom/2), y=0, w=math.floor(550/zoom), h=math.floor(110/zoom)}
hudPos.y = math.floor(85/zoom)
main = {
getLib = exports.nrpg_lib,
onlineTime = 0,
onlineTime2 = 0,
premiumMoney = 3000,
afkTimes = 0,
}
tick = getTickCount()
online = 0
local interface = {
backgroundRectangle2 = main.getLib:dgsCreateRoundRect({{5,false},{5,false},{5,false},{5,false}},tocolor(16,147,170, 255)),
backgroundRectangle = main.getLib:dgsCreateRoundRect({{5,false},{200,false},{5,false},{200,false}},tocolor(35,35,35, 255)),
--backgroundRectangle3 = main.getLib:dgsCreateRoundRect({{2,false},{2,false},{2,false},{2,false}},tocolor(55, 55, 55, 255)),
heart_icon = dxCreateTexture("img/heart_icon.png"),
logo_icon = dxCreateTexture("img/LOGO.png"),
factionRectangles = {
["SARA"] = main.getLib:dgsCreateRoundRect({{15,false},{15,false},{15,false},{15,false}},tocolor(200, 135, 0, 255)),
["SAPD"] = main.getLib:dgsCreateRoundRect({{15,false},{15,false},{15,false},{15,false}},tocolor(0, 64, 200, 255)),
["SAFD"] = main.getLib:dgsCreateRoundRect({{15,false},{15,false},{15,false},{15,false}},tocolor(200, 0, 0, 255)),
},
}
main.renderHUD = function()
if getElementData(localPlayer, "player:sid") and not getElementData(localPlayer,"notshowhud") then
local x, y, w, h = hudPos.x, math.floor(hudPos.y), hudPos.w, hudPos.h
local money = getPlayerMoney(localPlayer)
local level = exports["nrpg_levels"]:getLevel(localPlayer) or 0
local exp = exports["nrpg_levels"]:getExp(localPlayer) or 0
local health = getElementHealth(localPlayer) or 0
local faction = getElementData(localPlayer, "player:faction") or false
dxDrawImage(hudPos.x+math.floor(-1990/zoom), hudPos.y-math.floor(-902/zoom), hudPos.w-math.floor(-2100/zoom), hudPos.h, interface.backgroundRectangle2, 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawImage(hudPos.x+math.floor(-2001/zoom), hudPos.y-math.floor(-905/zoom), hudPos.w-math.floor(-2025/zoom), hudPos.h-math.floor(2), interface.backgroundRectangle, 0, 0, 0, tocolor(255, 255, 255, 255), false)
--exports["nrpg_avatars"]:dxCreateAvatar(hudPos.x+math.floor(115/zoom), hudPos.y-math.floor(69/zoom), math.floor(125/zoom), math.floor(125/zoom), 255, tocolor(255, 175, 0, 255))
dxDrawLinedRectangle(hudPos.x+math.floor(-605/zoom), hudPos.y-math.floor(-940/zoom), math.floor(240/zoom), math.floor(25/zoom), tocolor(16,147,170, 200), 1)
dxDrawRectangle(hudPos.x+math.floor(-605/zoom), hudPos.y-math.floor(-940/zoom), math.floor(240/zoom), math.floor(25/zoom), tocolor(100, 100, 100, 105))
dxDrawRectangle(hudPos.x+math.floor(-605/zoom), hudPos.y-math.floor(-940/zoom), math.floor(240/zoom)*exp/100, math.floor(25/zoom), tocolor(16,147,170, 155))
dxDrawText(level, x+math.floor(-600/zoom), y-math.floor(-940/zoom), x+w, y+h, tocolor(255, 255, 255, 200), 1, exports.nrpg_interface:getGUIFont('money11'), "left", "top", false, false, false, true, false)
dxDrawText(tonumber(level)+1, x+math.floor(450/zoom), y-math.floor(-940/zoom), math.floor(1095/zoom), y+h, tocolor(255, 255, 255, 200), 1, exports.nrpg_interface:getGUIFont('money11'), "right", "top", false, false, false, true, false)
dxDrawLinedRectangle(hudPos.x+math.floor(-950/zoom), hudPos.y-math.floor(-940/zoom), math.floor(240/zoom), math.floor(25/zoom), tocolor(175, 55, 55, 255), 1)
dxDrawRectangle(hudPos.x+math.floor(-950/zoom), hudPos.y-math.floor(-940/zoom), math.floor(240/zoom), math.floor(25/zoom), tocolor(100, 55, 55, 55))
dxDrawRectangle(hudPos.x+math.floor(-950/zoom), hudPos.y-math.floor(-940/zoom), math.floor(240/zoom)*health/100, math.floor(25/zoom), tocolor(155, 55, 55, 255))
dxDrawImage(hudPos.x+math.floor(-940/zoom), hudPos.y-math.floor(-942/zoom), math.floor(18/zoom), math.floor(18/zoom), interface.heart_icon, 0, 0, 0, tocolor(255, 255, 255, 225), false)
dxDrawImage(hudPos.x+math.floor(-1450/zoom), hudPos.y-math.floor(-906/zoom), math.floor(85/zoom), math.floor(85/zoom), interface.logo_icon, 0, 0, 0, tocolor(255, 255, 255, 225), false)
dxDrawText("HP", x+math.floor(-840/zoom), y-math.floor(-942/zoom), x+w, y+h, tocolor(255, 255, 255, 200), 1, exports.nrpg_interface:getGUIFont('money9'), "left", "top", false, false, false, true, false)
dxDrawText("MTAPerfect", x+math.floor(-1359/zoom), y-math.floor(-965/zoom), x+w, y+h, tocolor(255,255,255, 255), 1, exports.nrpg_interface:getGUIFont('money9'), "left", "top", false, false, false, true, false)
if faction then
dxDrawImage(hudPos.x+math.floor(300/zoom), hudPos.y+math.floor(940/zoom), math.floor(100/zoom), math.floor(35/zoom), interface.factionRectangles[faction], 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText(faction, x+math.floor(150/zoom), y+math.floor(945/zoom), x+w, y+h, tocolor(255, 255, 255, 255), 1, exports.nrpg_interface:getGUIFont('money11'), "center", "top", false, false, false, true, false)
end
dxDrawText("#ffffff"..exp.." #ffffffEXP", x+math.floor(-505/zoom), y+math.floor(942/zoom), x+w, y+h, tocolor(255, 255, 255, 200), 1, exports.nrpg_interface:getGUIFont('money10'), "left", "top", false, false, false, true, false)
dxDrawText("#ffffff"..main.przecinkiAdd(money).."#9bff9b PLN", x+math.floor(200/zoom), y+math.floor(942/zoom), math.floor(1350/zoom), y+h, tocolor(155, 255, 155, 200), 1, exports.nrpg_interface:getGUIFont('money10'), "right", "top", false, false, false, true, false)
local posX,posY,posZ = getElementPosition(localPlayer)
local ulica = getZoneName(posX,posY,posZ, false)
local ulica2 = getZoneName(posX,posY,posZ, true)
--dxDrawText(ulica2, math.floor(436/zoom), screenH-math.floor(79/zoom), x+w, y+h, tocolor(0, 0, 0, 255), 1, exports.nrpg_interface:getGUIFont('bold18'), "left", "top", false, false, false, true, false)
--dxDrawText(ulica, math.floor(436/zoom), screenH-math.floor(49/zoom), x+w, y+h, tocolor(0, 0, 0, 255), 1, exports.nrpg_interface:getGUIFont('normal15'), "left", "top", false, false, false, true, false)
--dxDrawText(ulica2, math.floor(435/zoom), screenH-math.floor(80/zoom), x+w, y+h, tocolor(0, 94, 209, 225), 1, exports.nrpg_interface:getGUIFont('bold18'), "left", "top", false, false, false, true, false)
--dxDrawText(ulica, math.floor(435/zoom), screenH-math.floor(50/zoom), x+w, y+h, tocolor(225, 225, 225, 225), 1, exports.nrpg_interface:getGUIFont('normal15'), "left", "top", false, false, false, true, false)
if (getTickCount() - tick) >= (1000) then
tick = getTickCount()
online=online+1
main.addTime(1000)
end
end
end
addEventHandler("onClientResourceStart", resourceRoot, function()
showPlayerHudComponent("all", false)
showPlayerHudComponent("crosshair", true)
addEventHandler("onClientRender", root, function()
main.renderHUD()
end)
end)
toggleHUD = false
bindKey("F7", "down", function()
if toggleHUD == false then
setElementData(localPlayer, "notshowhud", true)
showChat(false)
toggleHUD = true
else
setElementData(localPlayer, "notshowhud", false)
showChat(true)
toggleHUD = false
end
end)
main.addTime = function(seconds)
main.onlineTime = main.onlineTime + 1
main.onlineTime2 = main.onlineTime2 + 1
if main.onlineTime2 > 60 then
setElementData(localPlayer, "player:hours", tonumber(getElementData(localPlayer, "player:hours") or 0)+1)
main.onlineTime2 = 0
end
if main.onlineTime > (60*60) then
if getElementData(localPlayer, "player:premiumplus") then
outputChatBox("#5cb3ffⓘ #FFFFFFOtrzymujesz #005ed1"..main.przecinkiAdd(main.premiumPlusMoney).." PLN#ffffff za przegran? godzin?.", 0, 94, 209, true)
triggerServerEvent("givePlayerBankMoney", localPlayer, main.premiumPlusMoney)
main.onlineTime = 0
elseif getElementData(localPlayer, "player:premium") then
outputChatBox("#5cb3ffⓘ #FFFFFFOtrzymujesz #005ed1"..main.przecinkiAdd(main.premiumMoney).." PLN#ffffff za przegran? godzin?.", 0, 94, 209, true)
triggerServerEvent("givePlayerBankMoney", localPlayer, main.premiumMoney)
main.onlineTime = 0
end
end
end
main.getPedWeapons = function(ped)
local playerWeapons = {}
if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" then
for i=2,9 do
local wep = getPedWeapon(ped,i)
if wep and wep ~= 0 then
table.insert(playerWeapons,wep)
end
end
else
return false
end
return playerWeapons
end
main.przecinkiAdd = function(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
function dxDrawLinedRectangle( x, y, width, height, color, _width, postGUI )
_width = _width or 1
dxDrawLine ( x, y, x+width, y, color, _width, postGUI ) -- Top
dxDrawLine ( x, y, x, y+height, color, _width, postGUI ) -- Left
dxDrawLine ( x, y+height, x+width, y+height, color, _width, postGUI ) -- Bottom
return dxDrawLine ( x+width, y, x+width, y+height, color, _width, postGUI ) -- Right
end
[/code][/list]
Wysłany: 2022-08-12, 15:52
MartinPanZycia
Zielony w LUA
Wiek: 27 Na forum: 3728 dni Posty: 476
Nick w MP: Rodzaje
Piwa : 878
drugi SS nie dzia?a
wi?c nie mam por?wnania, i dla mnie dziwnie skalujesz
je?li dzia?a to OK, ale je?li nie to spr?buj inny spos?b skalowania ja mam taki
mojeW , mojeH = 1920 , 1080
sW , sH = guiGetScreenSize ()
w , h = ( sW / mojeW ), ( sH / mojeH )
dxDrawImage ( 15 * w , 15 * h , 154 * w , 51 * h , "files/rectangle.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 150 ), false )
Wysłany: 2022-08-26, 14:53
JavvaN
Producent pomysłów
Wiek: 25 Na forum: 1858 dni Posty: 17
Nick w MP: JavvaN
Piwa : 193
A ja np. polecam takie
Kod:
local screenW, screenH = guiGetScreenSize()
local scaleX, scaleY = 1920/screenW, 1080/screenH
dxDrawImage(1234/scaleX, 997/scaleY, 69/scaleX, 69/scaleY, "image.png")
Więcej szczegółów
Wystawiono 1 piw(a):borsuk
Tagi: skalowanie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: