papam77 Posted October 30, 2013 Share 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? Link to comment
myonlake Posted October 30, 2013 Share 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. Link to comment
papam77 Posted October 30, 2013 Author Share Posted October 30, 2013 But I defined g_Money like getPlayerMoney() local g_Money = getPlayerMoney() Link to comment
TAPL Posted October 30, 2013 Share 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 Link to comment
BieHDC Posted October 30, 2013 Share Posted October 30, 2013 btw: do money sets ONLY SERVERSIDE or it wont be triggert Link to comment
.:HyPeX:. Posted October 30, 2013 Share 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.. Link to comment
myonlake Posted October 31, 2013 Share 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. 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