Jump to content

Event Money


Recommended Posts

هذا حق @#x1AhMeD-09

addEvent "onPlayerMoneyChange" 

function onPreFunction(sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ...)
	local args = {...}
	if functionName == "setPlayerMoney" or functionName == "takePlayerMoney" or functionName == "givePlayerMoney" and #args == 2 and isElement(args[1]) then
		triggerEvent("onPlayerMoneyChange", args[1], args[2])
	end
end
addDebugHook("preFunction", onPreFunction)

-- مثال

addEventHandler("onPlayerMoneyChange", root,
	function(newMoney)
		outputChatBox(getPlayerName(source).."'s money changed to "..newMoney, root, 255, 0, 0, true)
	end
)

 

Link to comment
5 minutes ago, Default#^ said:

هذا حق @#x1AhMeD-09


addEvent "onPlayerMoneyChange" 

function onPreFunction(sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ...)
	local args = {...}
	if functionName == "setPlayerMoney" or functionName == "takePlayerMoney" or functionName == "givePlayerMoney" and #args == 2 and isElement(args[1]) then
		triggerEvent("onPlayerMoneyChange", args[1], args[2])
	end
end
addDebugHook("preFunction", onPreFunction)

-- مثال

addEventHandler("onPlayerMoneyChange", root,
	function(newMoney)
		outputChatBox(getPlayerName(source).."'s money changed to "..newMoney, root, 255, 0, 0, true)
	end
)

 

يب وحصلت واحد تاني بعد في اليوزفل فنكشنس

بس هادا ما يجيب لاق؟

Link to comment
4 minutes ago, Default#^ said:

لأ

في مشكله

يعني فلوسي كانت 0 , ضفت علي فلوسي 5 , كتبلي ان فلوسك صارت 5 , بعد ثانية كتبلي فلوسك صارت 0

يرجعلي القيمة القديمة بعد الرسالة الاصلية بثانية

Link to comment
On 01/04/2016 at 09:06, Jupiter said:

NOTE : هذا مو فنكشن لكنه ايفينت وما لقيت مواضيع وما يلزم موضوع جديد مشان ايفنت فقلت اطرححه هنا

---------------------------

onClientPlayerMoneyChange

ClientSide event

 

الايفينت يتنفذ لما تتغير فلوس الاعب المحلي فيه

Parameters

_________________________________________________________


int OldMoney, int NewMoney 
 

 

• OldMoney : الفلوس اللي كانت مع الاعب قبل التغيير

• NewMoney : الفلوس اللي مع الاعب بعد التغيير

Source

_________________________________________________________

(المصدرهو الاعب المحلي (اللي تغيرت فلوسه

Source Code

_________________________________________________________


local EventPlayerMoney = getPlayerMoney(localPlayer) 
  
addEventHandler("onClientRender", root,  
function () 
    if EventPlayerMoney ~= getPlayerMoney(localPlayer) then 
        triggerEvent("onClientPlayerMoneyChange", localPlayer, tonumber(EventPlayerMoney), tonumber(getPlayerMoney(localPlayer))) 
        EventPlayerMoney = getPlayerMoney(localPlayer) 
    end 
end 
) 
  
addEvent "onClientPlayerMoneyChange" 

 

 

Example

_________________________________________________________

المثال ذا يتحقق كل مرة لما تتغير فلوسه اذا كانت فوق 8000 ويطلع نص بلشات


VehiclePrice = 8000 
  
addEventHandler("onClientPlayerMoneyChange", root,  
function (OldMoney, NewMoney) 
    if NewMoney >= VehiclePrice then 
        outputChatBox("Now you can buy the vehicle !", 0, 255, 0) 
    elseif OldMoney < VehiclePrice then 
        outputChatBox("get more money to buy the vehicle", 255, 0, 0) 
    end 
end 
) 
 

 

 

  • Like 1
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...