WorthlessCynomys Posted January 1, 2017 Share Posted January 1, 2017 I have a problem with the visibility of outputChatBox. So it's part of a GUI. You press the button on the GUI, it sends the command to the server, the server checks if you have the money for the stuff and if you have, you got a fancy new weapon, but if you don't, the server triggers a clientside event, wich outputs the message, that you don't have enough money. The problem is, that the message, that warns you, that you don't have the money, appears for every online player. CLIENTSIDE function nomoney() outputChatBox("Nincs rá pénzed.") end addEvent("nomoney", true) addEventHandler("nomoney", resourceRoot, nomoney) SERVERSIDE function Deagleb() money = getPlayerMoney(client) if money>=100 then setPlayerMoney(client, money-100) giveWeapon(client, 24, 14, true) else triggerClientEvent("nomoney", resourceRoot) end end addEvent("Deagle", true) addEventHandler("Deagle", resourceRoot, Deagleb) Thanks for the help. Link to comment
Tails Posted January 1, 2017 Share Posted January 1, 2017 That's because the triggerClientEvent is being triggered on all clients. You have to specify the actual client. Try this: triggerClientEvent(client, "nomoney", resourceRoot) Link to comment
WorthlessCynomys Posted January 2, 2017 Author Share Posted January 2, 2017 Thanks, it worked. You're cool. 1 Link to comment
Mr.Loki Posted January 2, 2017 Share Posted January 2, 2017 Instead of triggering a client event which is very inefficient in this situation in the "else" section you can just put the outputChatBox message there and set it visible only to the client so that line 7 would be something like: outputChatBox ("yourmesaage",client) 2 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