papam77 Posted October 30, 2013 Posted October 30, 2013 function boughtSM ( button ) if button == "left" then if ( g_Money == 15 ) or ( g_Money > 15 ) then outputChatBox ("#ffffffYou bought Salad Meal", 255,255,255, true ) takePlayerMoney (15) else outputChatBox ("#ff0000Sorry, you have no enough money", 255,255,255, true ) takePlayerMoney (0) end end end Why it needs restart script to check money again? Because When I set my money to 15, I need then restart this script to check it again, because without restart it writes You've no enough money... Where's the problem?
myonlake Posted October 30, 2013 Posted October 30, 2013 g_Money is a variable somewhere. You have to make sure you keep g_Money updated, or just replace g_Money with getPlayerMoney(). You should also take under consideration that client-side money actions only affect the client and not the server - therefore it doesn't synchronize and they can abuse the code quite easily.
papam77 Posted October 30, 2013 Author Posted October 30, 2013 But I defined g_Money like getPlayerMoney() local g_Money = getPlayerMoney()
TAPL Posted October 30, 2013 Posted October 30, 2013 But I defined g_Money like getPlayerMoney()local g_Money = getPlayerMoney() function boughtSM ( button ) if button == "left" then local g_Money = getPlayerMoney() -- define it inside the function. if ( g_Money >= 15 ) then -- >= greater than or equal to. outputChatBox ("#ffffffYou bought Salad Meal", 255,255,255, true ) takePlayerMoney (15) else outputChatBox ("#ff0000Sorry, you have no enough money", 255,255,255, true ) -- takePlayerMoney (0) -- no need for this. end end end
BieHDC Posted October 30, 2013 Posted October 30, 2013 btw: do money sets ONLY SERVERSIDE or it wont be triggert
.:HyPeX:. Posted October 30, 2013 Posted October 30, 2013 btw: do money sets ONLY SERVERSIDE or it wont be triggert wait what? you can just make the client side to send stuff to server side.. i dont get at all your post..
myonlake Posted October 31, 2013 Posted October 31, 2013 You can set and manage money client-side, but it will never be synchonized with the server or other players in that case. I suggest using triggerServerEvent and set the money server-side in order to to make sure the money will always be synchronized.
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