bartje01 Posted March 6, 2011 Author Share Posted March 6, 2011 Yay the text works now. I also get my cash when I die. But Solidsnake is right. When I reconnect it doesn't save. How to save this? Thanks so much guys Link to comment
Castillo Posted March 6, 2011 Share Posted March 6, 2011 (edited) Easy o,O function onLoginSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) if getAccountData ( account, "data.cash" ) then givePlayerMoney(source, tonumber(getAccountData(account,"data.cash"))) outputChatBox ( "You're cash is transfered back!", source ) else setAccountData( account, "data.cash", 0 ) outputChatBox ( "You're new and your cash will now be saved." ) end end end function onWastedSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then local getPlayerCash = getElementData ( source, "data.cash" ) setElementData ( source, "data.cash", getPlayerCash + 100 ) outputChatBox ( "You got 100$ for your death.", source ) end end function onQuitSaveCash() if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) end end addEventHandler ( "onPlayerQuit", root, onQuitSaveCash ) function onLogoutSaveCash() if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) setPlayerMoney(source,0) end end addEventHandler ( "onPlayerLogout", root, onLogoutSaveCash ) addEventHandler ( "onPlayerLogin", root, onLoginSetCash ) addEventHandler ( "onPlayerWasted", root, onWastedSetCash ) function myCash ( thePlayer ) if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then account = getPlayerAccount(thePlayer) local cash = getAccountData ( account, "data.cash" ) outputChatBox ( "Your cash is: " .. tostring ( cash ), thePlayer ) end end addCommandHandler ( "cash", myCash ) Try if it works (not tested) Edited March 6, 2011 by Guest Link to comment
bartje01 Posted March 6, 2011 Author Share Posted March 6, 2011 WHere is the easy part of that Didn't worked btw:( In my console no errors or warnings In my script editor there are errors: ')'Expected (to close '(' at line 45) near 'end' '' expected near 'end' ')' expected (to close '(' at line 53) near 'setPlayerMoney' Btw. Why setPlayerMoney? I didn't need that with element date cash right? Link to comment
Castillo Posted March 6, 2011 Share Posted March 6, 2011 Ok, i fixed the missing ")" and now should work. Link to comment
bartje01 Posted March 6, 2011 Author Share Posted March 6, 2011 Errors gone but still no saving Dammiiieeet Not so easy I guess Your code looks really hard. The step from sa-mp to MTA is so hard for me Link to comment
Castillo Posted March 6, 2011 Share Posted March 6, 2011 I will test it later, right now i'am busy. Link to comment
bartje01 Posted March 6, 2011 Author Share Posted March 6, 2011 Alright np. Take your time Link to comment
proracer Posted March 6, 2011 Share Posted March 6, 2011 This should work, I tested it.. function onLoginSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) if getAccountData ( account, "data.cash" ) then givePlayerMoney(source, tonumber(getAccountData(account,"data.cash"))) outputChatBox ( "You're cash is transfered back!", source ) else setAccountData( account, "data.cash", 0 ) outputChatBox ( "You're new and your cash will now be saved." ) end end end function onWastedSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then local getPlayerCash = getAccountData ( account, "data.cash" ) setAccountData ( account, "data.cash", tonumber(getPlayerCash) + 100 ) outputChatBox ( "You got 100$ for your death.", source ) end end function onQuitSaveCash() if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) end end addEventHandler ( "onPlayerQuit", root, onQuitSaveCash ) function onLogoutSaveCash() if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) setPlayerMoney(source,0) end end addEventHandler ( "onPlayerLogout", root, onLogoutSaveCash ) addEventHandler ( "onPlayerLogin", root, onLoginSetCash ) addEventHandler ( "onPlayerWasted", root, onWastedSetCash ) function myCash ( thePlayer ) if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then account = getPlayerAccount(thePlayer) local cash = getAccountData ( account, "data.cash" ) outputChatBox ( "Your cash is: " .. tostring ( cash ) .. " $ ", thePlayer ) end end addCommandHandler ( "cash", myCash ) Link to comment
bartje01 Posted March 7, 2011 Author Share Posted March 7, 2011 OMFGOMFGOMFG I WORKS YAHIOOOOOO PRORACER AWEEESOOME (L) THANKYOU BOTH BOTH OF YOU. AWWEEESOME HEROES!!!!!! TYTY 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