Jump to content

MaurO^

Recommended Posts

-- This code is NOT tested and may need adjustments in order to work properly.

-- Client Side
local money

function moneyChange(oldMoney,newMoney)
	local inc
	local change
	if newMoney > oldMoney then
		inc = 'raised'
		change = newMoney-oldMoney
	elseif newMoney < oldMoney then
		inc = 'lowered'
		change = oldMoney-newMoney
	end
	outputChatBox('Your money has '..inc..' by '..change..' Balance: '..newMoney,0,255,255)
end

addEventHandler('onClientRender',root,function()
	local newCash = getPlayerMoney(localPlayer)
	if not money then
		money = newCash
	else
		if newCash > money or newCash < money then
			moneyChange(money,newCash)
			money = newCash
		end
	end
end)


-- Serverside
local money = {}

function moneyChange(player,oldMoney,newMoney)
	local inc
	local change
	if newMoney > oldMoney then
		inc = 'raised'
		change = newMoney-oldMoney
	elseif newMoney < oldMoney then
		inc = 'lowered'
		change = oldMoney-newMoney
	end
	outputChatBox('Your money has '..inc..' by '..change..' Balance: '..newMoney,player,0,255,255)
end

setTimer(function()
	for i,plr in pairs(getElementsByType('player')) do
		local newCash = getPlayerMoney(plr)
		if not money[plr] then
			money[plr] = newCash
		else
			if newCash > money[plr] or newCash < money[plr] then
				moneyChange(plr,money[plr],newCash)
				money[plr] = newCash
			end
		end
	end
end,1000,0)

I hope that this has helped you, have a nice day.

Edited by ShayF
  • Thanks 1
Link to comment
23 hours ago, ShayF said:

-- This code is NOT tested and may need adjustments in order to work properly.

-- Client Side
local money

function moneyChange(oldMoney,newMoney)
	local inc
	local change
	if newMoney > oldMoney then
		inc = 'raised'
		change = newMoney-oldMoney
	elseif newMoney < oldMoney then
		inc = 'lowered'
		change = oldMoney-newMoney
	end
	outputChatBox('Your money has '..inc..' by '..change..' Balance: '..newMoney,0,255,255)
end

addEventHandler('onClientRender',root,function()
	local newCash = getPlayerMoney(localPlayer)
	if not money then
		money = newCash
	else
		if newCash > money or newCash < money then
			moneyChange(money,newCash)
			money = newCash
		end
	end
end)


-- Serverside
local money = {}

function moneyChange(player,oldMoney,newMoney)
	local inc
	local change
	if newMoney > oldMoney then
		inc = 'raised'
		change = newMoney-oldMoney
	elseif newMoney < oldMoney then
		inc = 'lowered'
		change = oldMoney-newMoney
	end
	outputChatBox('Your money has '..inc..' by '..change..' Balance: '..newMoney,player,0,255,255)
end

setTimer(function()
	for i,plr in pairs(getElementsByType('player')) do
		local newCash = getPlayerMoney(plr)
		if not money[plr] then
			money[plr] = newCash
		else
			if newCash > money[plr] or newCash < money[plr] then
				moneyChange(plr,money[plr],newCash)
				money[plr] = newCash
			end
		end
	end
end,1000,0)

I hope that this has helped you, have a nice day.

 

thanks, it worked for me :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...