Wysłany: 2025-04-01, 20:26
MjuziQu
Wiek: 21 Na forum: 448 dni Posty: 5
Jak przekształcić ten skrypt tak aby aktualizował punkty życie (hp) oraz pieniądze (money) natychmiastowo? (MOŻE BYĆ NA MYSQL)
Kod: local komponenty = {
{"ammo", "armour", "clock", "health", "money", "weapon", "wanted"}
}
local main = {}
local sx, sy = guiGetScreenSize()
local money = getPlayerMoney(localPlayer)
local hp = getElementHealth(localPlayer)
function sw(value)
return sx*value/1920
end
function sh(value)
return sy*value/1080
end
main.ui = {
textures = {
bg = dxCreateTexture('files/hudzik.png'),
}
}
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function()
for i=1, #komponenty [1] do
showPlayerHudComponent(komponenty[1][i],false)
end
end)
addEventHandler("onClientRender",root,function()
dxDrawImage(sw(0), sh(0), sw(1920), sh(1080), main.ui.textures.bg, 0, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawText(przecinek(money).."", sw(770 + 1), sh(1032 + 1), sw(1114 + 1), sh(1068 + 1), tocolor(0, 0, 0, 255), 2.40, "default", "left", "top", false, false, false, false, false)
dxDrawText(przecinek(money).."", sw(770), sh(1032), sw(1114), sh(1068), tocolor(255, 255, 255, 255), 2.40, "default", "left", "top", false, false, false, false, false)
dxDrawText("17", sw(655 + 1), sh(1032 + 1), sw(722 + 1), sh(1068 + 1), tocolor(0, 0, 0, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText("17", sw(655), sh(1032), sw(722), sh(1068), tocolor(255, 255, 255, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText("152,322", sw(347 + 1), sh(1032 + 1), sw(476 + 1), sh(1068 + 1), tocolor(0, 0, 0, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText("152,322", sw(347), sh(1032), sw(476), sh(1068), tocolor(255, 255, 255, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText("12,322", sw(519 + 1), sh(1032 + 1), sw(612 + 1), sh(1068 + 1), tocolor(0, 0, 0, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText("12,322", sw(519), sh(1032), sw(612), sh(1068), tocolor(255, 255, 255, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText(math.floor(hp).."%", sw(201 + 1), sh(1032 + 1), sw(303 + 1), sh(1068 + 1), tocolor(0, 0, 0, 255), 2.40, "default", "center", "top", false, false, false, false, false)
dxDrawText(math.floor(hp).."%", sw(201), sh(1032), sw(303), sh(1068), tocolor(255, 255, 255, 255), 2.40, "default", "center", "top", false, false, false, false, false)
end)
function przecinek(liczba)
local format = liczba
while true do
format, k = string.gsub(format, "^(-?%d+)(%d%d%d)", '%1,%2')
if ( k==0 ) then
break
end
end
return format
end
Wysłany: 2025-04-01, 20:59
MlodyRafonix
Wiek: 26 Na forum: 1899 dni Posty: 103
Piwa : 954
getPlayerMoney
getElementHealth
local health = math . floor ( getElementHealth ( localPlayer ))
dxDrawText ( "#ffffffZdrowie: " .. health .. "#0cad1a%" , 156 / zoom , sy - 225 / zoom , 590 / zoom , sy + 69 / zoom , tocolor ( 255 , 255 , 255 , 200 ), 1 / zoom , font , "right" , "center" , true , true , false , true , false )
dxDrawText ( "#ffffffGotówka: " ..( getPlayerMoney () or 0 ).. "#0cad1a $" , 156 / zoom , sy - 265 / zoom , 650 / zoom , sy - 0 / zoom , tocolor ( 255 , 255 , 255 , 255 ), 1 / zoom , font , "right" , "center" , true , true , false , true , false )
podpięte do onClientRender
Wysłany: 2025-04-02, 17:12
_jvneczek
Wiek: 22 Na forum: 4325 dni Posty: 1513
Nick w MP: _jvneczek
Piwa : 3949
local komponenty = {
{ "ammo" , "armour" , "clock" , "health" , "money" , "weapon" , "wanted" }
}
local main = {}
local sx , sy = guiGetScreenSize ()
function sw ( value )
return sx * value / 1920
end
function sh ( value )
return sy * value / 1080
end
main . ui = {
textures = {
bg = dxCreateTexture ( 'files/hudzik.png' ),
}
}
addEventHandler ( "onClientResourceStart" , getResourceRootElement ( getThisResource ()), function()
for i = 1 , #komponenty [1] do
showPlayerHudComponent ( komponenty [ 1 ][ i ], false )
end
end )
addEventHandler ( "onClientRender" , root ,function()
local money = getPlayerMoney ( localPlayer )
local hp = getElementHealth ( localPlayer )
dxDrawImage ( sw ( 0 ), sh ( 0 ), sw ( 1920 ), sh ( 1080 ), main . ui . textures . bg , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), true )
dxDrawText ( przecinek ( money ).. "" , sw ( 770 + 1 ), sh ( 1032 + 1 ), sw ( 1114 + 1 ), sh ( 1068 + 1 ), tocolor ( 0 , 0 , 0 , 255 ), 2.40 , "default" , "left" , "top" , false , false , false , false , false )
dxDrawText ( przecinek ( money ).. "" , sw ( 770 ), sh ( 1032 ), sw ( 1114 ), sh ( 1068 ), tocolor ( 255 , 255 , 255 , 255 ), 2.40 , "default" , "left" , "top" , false , false , false , false , false )
dxDrawText ( "17" , sw ( 655 + 1 ), sh ( 1032 + 1 ), sw ( 722 + 1 ), sh ( 1068 + 1 ), tocolor ( 0 , 0 , 0 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( "17" , sw ( 655 ), sh ( 1032 ), sw ( 722 ), sh ( 1068 ), tocolor ( 255 , 255 , 255 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( "152,322" , sw ( 347 + 1 ), sh ( 1032 + 1 ), sw ( 476 + 1 ), sh ( 1068 + 1 ), tocolor ( 0 , 0 , 0 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( "152,322" , sw ( 347 ), sh ( 1032 ), sw ( 476 ), sh ( 1068 ), tocolor ( 255 , 255 , 255 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( "12,322" , sw ( 519 + 1 ), sh ( 1032 + 1 ), sw ( 612 + 1 ), sh ( 1068 + 1 ), tocolor ( 0 , 0 , 0 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( "12,322" , sw ( 519 ), sh ( 1032 ), sw ( 612 ), sh ( 1068 ), tocolor ( 255 , 255 , 255 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( math . floor ( hp ).. "%" , sw ( 201 + 1 ), sh ( 1032 + 1 ), sw ( 303 + 1 ), sh ( 1068 + 1 ), tocolor ( 0 , 0 , 0 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
dxDrawText ( math . floor ( hp ).. "%" , sw ( 201 ), sh ( 1032 ), sw ( 303 ), sh ( 1068 ), tocolor ( 255 , 255 , 255 , 255 ), 2.40 , "default" , "center" , "top" , false , false , false , false , false )
end )
function przecinek ( liczba )
local format = liczba
while true do
format , k = string . gsub ( format , "^(-?%d+)(%d%d%d)" , '%1,%2' )
if ( k == 0 ) then
break
end
end
return format
end
Tagi: jak :: zrobić :: aby :: oraz :: pieniadze :: były :: aktualizowane?
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: