Thank you very much for your advice! I thought that he would not ask such a question, since the default GTA HUD has such an animation by default, and did it right on the user interface.
Here is the corrected code:
Client:
local delay = 20
function moneyChange(commandName, count)
count = tonumber(count)
if type(count) ~= "number" then return end
local operaceType = "give"
if count < 0 then
operaceType = "take"
count = -count
end
local addMoney = 0
local modf = 1
if count > 100 then modf = modf*10 end
if count > 1000 then modf = modf*10 end
if count > 10000 then modf = modf*10 end
if count > 100000 then modf = modf*10 end
if count > 1000000 then modf = modf*10 end
local timer = setTimer(function()
addMoney = math.random(1,modf)
count = count - addMoney
if count < 1000000 and modf == 100000 then modf = modf/10 end
if count < 100000 and modf == 10000 then modf = modf/10 end
if count < 10000 and modf == 1000 then modf = modf/10 end
if count < 1000 and modf == 100 then modf = modf/10 end
if count < 100 and modf == 10 then modf = modf/10 end
if count <= 0 then
triggerServerEvent("money:moneyChange", resourceRoot, localPlayer, count + addMoney, operaceType)
count = 0
if isTimer(timer) then
killTimer(timer)
timer = nil
end
return
end
triggerServerEvent("money:moneyChange", resourceRoot, localPlayer, addMoney, operaceType)
end, delay, 0)
end
addCommandHandler("money", moneyChange)
addEventHandler("onClientRender", root, function()
dxDrawText(tostring(getPlayerMoney(localPlayer)), 500, 300, _, _, _, 3)
end)
Server:
addEvent("money:moneyChange", true)
addEventHandler("money:moneyChange", root, function(player, count, operaceType)
if not player or not count or not operaceType then return end
if operaceType == "give" then
givePlayerMoney(player, count)
else
takePlayerMoney(player, count)
end
end)