Mefisto_PL Posted November 3, 2012 Posted November 3, 2012 I've made a Money System.. When I quit or logout my cash is saved.. But when I have for example $666 and when I use takePlayerMoney ( blah blah blah 500 for example ) then I have $166, when I quit I have $666.. WHY?!
Castillo Posted November 3, 2012 Posted November 3, 2012 You are taking it client side? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
theDavid Posted November 3, 2012 Posted November 3, 2012 Where you save your data? Tutorials, IT and news www.simpleask.co.uk
Mefisto_PL Posted November 4, 2012 Author Posted November 4, 2012 You are taking it client side? Yup. Where you save your data? Did you see any code here? I save my data in server-side script..
DiSaMe Posted November 4, 2012 Posted November 4, 2012 setPlayerMoney/givePlayerMoney/takePlayerMoney: Note: Using this function client side (not recommended) will not change a players money server side. -
Cadu12 Posted November 12, 2012 Posted November 12, 2012 Just change client-side to server-side. Ingame nick: Cadu12
myonlake Posted November 14, 2012 Posted November 14, 2012 Using triggerServerEvent ? If you really have to keep your code client-side, then yes, use triggerServerEvent. If you can do the same code server-side, then do it server-side. If I helped you, please click the like button on the right Thanks!
Cadu12 Posted November 14, 2012 Posted November 14, 2012 Using triggerServerEvent for setPlayerMoney/givePlayerMoney/takePlayerMoney It is BAD idea, because hacker is able to set money. Ingame nick: Cadu12
Mefisto_PL Posted November 15, 2012 Author Posted November 15, 2012 So what I must use in your opinion ?
Mefisto_PL Posted November 17, 2012 Author Posted November 17, 2012 Sorry for Off-Topic, but still I have this problem..
Castillo Posted November 17, 2012 Posted November 17, 2012 What problem? money problem? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
myonlake Posted November 17, 2012 Posted November 17, 2012 (edited) We gave you 100 examples and you haven't understood a single one of them? Give us a break. Test the money function by typing /ctest in-game. You should lose $100.00 and when you logout/quit the game, it will save your money. When you log in, it will return back your money. This is just an example, you must understand the code and please take time to read and understand it. Client-side addCommandHandler("ctest", function(cmd) triggerServerEvent("onMoneyTaken", localPlayer) end ) Server-side addEventHandler("onPlayerQuit", root, function(quitType, reason, responsibleElement) if isGuestAccount(getPlayerAccount(source)) then return end setAccountData(getPlayerAccount(source), "player:money", getPlayerMoney(source)) end ) addEventHandler("onPlayerLogout", root, function(previousAccount, currentAccount) if isGuestAccount(getPlayerAccount(source)) then return end setAccountData(getPlayerAccount(source), "player:money", getPlayerMoney(source)) end ) addEventHandler("onPlayerLogin", root, function(previousAccount, currentAccount, autoLogin) if getAccountData(currentAccount, "player:money") then setPlayerMoney(source, tonumber(getAccountData(currentAccount, "player:money"))) else setPlayerMoney(source, 200) end end ) addEvent("onMoneyTaken", true) addEventHandler("onMoneyTaken", root, function() takePlayerMoney(source, 100) end ) Edited November 17, 2012 by Guest If I helped you, please click the like button on the right Thanks!
Mefisto_PL Posted November 17, 2012 Author Posted November 17, 2012 Cadu12 Wrote that is easy to hack for hackers.. but I forget about hacks isn't allowed in MTA ;x ( I know this way, and I want to use that, I understand it ) ///EDIT In server-side isn't "addEvent" function and only that I don't understand.
myonlake Posted November 17, 2012 Posted November 17, 2012 Copy the code again then... If I helped you, please click the like button on the right Thanks!
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