28WL Posted May 3, 2015 Share Posted May 3, 2015 Hi. How I can make outputChatBox in client when for example the player click on the button (marketplace-shop item) and he gets a message that he bough something or he need money? CLIENT: function Buy_1 () if getElementData(getLocalPlayer(),"Money") >= 1000 then triggerServerEvent("Trigger_Buy_1_True",getLocalPlayer()) setElementData(getLocalPlayer(),"Money",(getElementData(getLocalPlayer(),"Money") or 0)-1000) setElementData(getLocalPlayer(),"Chips", 1) else triggerServerEvent("Trigger_Buy_1_False",getLocalPlayer()) end Can someone help me? I want only to see by myself if I buy it. Now it shows that for everyone, so... SERVER: function Script_Buy_1_True ( source ) local source = playersource outputChatBox("You have bought a (Chips) for a (Money).", playersource, 255, 255, 255, true) end addEvent("Trigger_Buy_1_True",true) addEventHandler("Trigger_Buy_1_True",getRootElement(),Script_Buy_1_True) function Script_Buy_1_False ( source ) local source = playersource outputChatBox("You don't have enough (Money) to buy a (Chips).", playersource, 255, 255, 255, true) end addEvent("Trigger_Buy_1_False",true) addEventHandler("Trigger_Buy_1_False",getRootElement(),Script_Buy_1_False) Link to comment
WhoAmI Posted May 3, 2015 Share Posted May 3, 2015 You don't have to trigger it. If you use outputChatBox clientside it will be showed only to localPlayer. function Buy_1 () if getElementData(getLocalPlayer(),"Money") >= 1000 then setElementData(getLocalPlayer(),"Money",(getElementData(getLocalPlayer(),"Money") or 0)-1000) setElementData(getLocalPlayer(),"Chips", 1) outputChatBox("You have bought a (Chips) for a (Money).", 255, 255, 255, true) else outputChatBox("You don't have enough (Money) to buy a (Chips).", 255, 255, 255, true) end end Link to comment
delete Posted May 3, 2015 Share Posted May 3, 2015 It happens because you have added outputchatbox server side. Link to comment
TAPL Posted May 3, 2015 Share Posted May 3, 2015 function Script_Buy_1_True() outputChatBox("You have bought a (Chips) for a (Money).", client, 255, 255, 255, true) end addEvent("Trigger_Buy_1_True",true) addEventHandler("Trigger_Buy_1_True", getRootElement(), Script_Buy_1_True) function Script_Buy_1_False() outputChatBox("You don't have enough (Money) to buy a (Chips).", client, 255, 255, 255, true) end addEvent("Trigger_Buy_1_False",true) addEventHandler("Trigger_Buy_1_False", getRootElement(), Script_Buy_1_False) Link to comment
WhoAmI Posted May 3, 2015 Share Posted May 3, 2015 Yea, exactly, in this case you don't need to use s-side. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now