local money = getElementData(localPlayer, \"char >> money\")
local moneyChanging = false
local newMoney = 0
local maxNuls = 10
local nulsText = \"0000\"
local nuls = utfSub(nulsText, 1, maxNuls - string.len(tostring(money)))
--local money = convertNumber(getElementData(localPlayer, \"char >> money\"))
local typeColors = {
[\"+\"] = \"#7cc576\",
[\"-\"] = \"#d02424\",
}
addEventHandler(\"onClientElementDataChange\", localPlayer,
function(dName, oValue)
if oValue == nil or not oValue then oValue = 0 end
if dName == \"char >> money\" then
local value = getElementData(source, dName)
nuls = utfSub(nulsText, 1, maxNuls - string.len(tostring(value)))
money = convertNumber(value)
if value > oValue then
moneyChangeType = \"+\"
newMoney = value - oValue
money = typeColors[moneyChangeType] .. money
elseif oValue > value then
moneyChangeType = \"-\"
newMoney = oValue - value
money = typeColors[moneyChangeType] .. money
end
playSound(\"files/moneychange.mp3\")
money = convertNumber(money)
moneyChanging = true
setTimer(
function()
moneyChanging = false
money = getElementData(localPlayer, \"char >> money\")
nuls = utfSub(nulsText, 1, maxNuls - string.len(tostring(money)))
end, 2500, 1
)
end
end
)
function drawnMoney()
if not getElementData(localPlayer, \"hudVisible\") then return end
--Money
local enabled,x,y,w,h,sizable,turnable = getDetails(\"money\")
if moneyChanging then
shadowedText(moneyChangeType .. newMoney .. \" Ft\", x, y, x + w, y + h, tocolor(255,255,255,255), 1, \"pricedown\", \"center\", \"center\", false, false, false, true)
dxDrawText(moneyChangeType .. typeColors[moneyChangeType] .. newMoney .. \" #ffffffFt\", x, y, x + w, y + h, tocolor(255,255,255,255), 1, \"pricedown\", \"center\", \"center\", false, false, false, true)
else
if money < 0 then
shadowedText(nuls .. money ..\" Ft\", x, y, x + w, y + h, tocolor(255,255,255,255), 1, \"pricedown\", \"center\", \"center\", false, false, false, true)
dxDrawText(nuls .. typeColors[\"-\"] .. money ..\" #ffffffFt\", x, y, x + w, y + h, tocolor(255,255,255,255), 1, \"pricedown\", \"center\", \"center\", false, false, false, true)
else
shadowedText(nuls .. money ..\" Ft\", x, y, x + w, y + h, tocolor(255,255,255,255), 1, \"pricedown\", \"center\", \"center\", false, false, false, true)
dxDrawText(nuls .. hexColor .. money ..\" #ffffffFt\", x, y, x + w, y + h, tocolor(255,255,255,255), 1, \"pricedown\", \"center\", \"center\", false, false, false, true)
end
end
end