BieHDC Posted July 12, 2013 Share Posted July 12, 2013 hello, i dedcted a bug in a login panel which saves money too. So if player log out then the money is also there and he can buy something and then login again and have lost no money! So i wrote small script for setting money to 0 on logout but i am not sure if works: function money() setPlayerMoney( getRootElement(), 0 ) end addEventHandler("onPlayerLogout",getRootElement(),money) and can you tell me sure that the money will set back on login? Link to comment
itoko Posted July 12, 2013 Share Posted July 12, 2013 (edited) function money() setPlayerMoney( source, 0 ) end addEventHandler("onPlayerLogout",getRootElement(),money) and can you tell me sure that the money will set back on login? Well, that depend of your script that save the money, normally yes. Edited July 12, 2013 by Guest Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 have you chaged anything on script? Link to comment
itoko Posted July 12, 2013 Share Posted July 12, 2013 Sorry i forgot to edit it, i changed the target of the setPlayerMoney to the source. Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 This is script for save and load can i add there script? function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local playerpoints = getElementData(source,"Points") local playertime = getElementData(source,"Playtime") local playerwins = getElementData(source,"Wins") local playerdeaths = getElementData(source,"Deaths") local playerhunters = getElementData(source,"Hunters") setAccountData ( playeraccount, "money", playermoney ) setAccountData ( playeraccount, "points", playerpoints ) setAccountData ( playeraccount, "playtime", playertime ) setAccountData ( playeraccount, "wins", playerwins ) setAccountData ( playeraccount, "deaths", playerdeaths ) setAccountData ( playeraccount, "hunters", playerhunters ) end end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "money" ) local playerpoints = getAccountData ( playeraccount, "points" ) local playertime = getAccountData ( playeraccount, "playtime" ) local playerwins = getAccountData ( playeraccount, "wins" ) local playerdeaths = getAccountData ( playeraccount, "deaths" ) local playerhunters = getAccountData ( playeraccount, "hunters" ) setPlayerMoney ( source, playermoney ) setElementData(source,"Points",playerpoints or 0) setElementData(source,"Playtime",playertime or 0) setElementData(source,"Wins",playerwins or 0) setElementData(source,"Deaths",playerdeaths or 0) setElementData(source,"Hunters",playerhunters or 0) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 simply down 36 row? and will the money set back on login? Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 doesnt fixed bug sucessfully he loose money on logout, but if he first bought in acc then logout and then login money resettet -.- and if i make onPlayerQuit with onPlayerLogout incl the extra script? Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 ok also doesnt work same bug Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 debugscript 3 is always helps Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 also dont work in onPlayerLogout function incl admin rights Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 has no output situation: Client -1000 money because of buy something > logout > login > money not lost here script therewhile function onPlayerLogout ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playermoney = getPlayerMoney ( source ) local playerpoints = getElementData(source,"Points") local playertime = getElementData(source,"Playtime") local playerwins = getElementData(source,"Wins") local playerdeaths = getElementData(source,"Deaths") local playerhunters = getElementData(source,"Hunters") setAccountData ( playeraccount, "money", playermoney ) setAccountData ( playeraccount, "points", playerpoints ) setAccountData ( playeraccount, "playtime", playertime ) setAccountData ( playeraccount, "wins", playerwins ) setAccountData ( playeraccount, "deaths", playerdeaths ) setAccountData ( playeraccount, "hunters", playerhunters ) end end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "money" ) local playerpoints = getAccountData ( playeraccount, "points" ) local playertime = getAccountData ( playeraccount, "playtime" ) local playerwins = getAccountData ( playeraccount, "wins" ) local playerdeaths = getAccountData ( playeraccount, "deaths" ) local playerhunters = getAccountData ( playeraccount, "hunters" ) setPlayerMoney ( source, playermoney ) setElementData(source,"Points",playerpoints or 0) setElementData(source,"Playtime",playertime or 0) setElementData(source,"Wins",playerwins or 0) setElementData(source,"Deaths",playerdeaths or 0) setElementData(source,"Hunters",playerhunters or 0) end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) function money() setPlayerMoney( source, 0 ) end addEventHandler("onPlayerLogout",getRootElement(),money) Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 debugscript 3 is always helps Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 has NO output ! i tryed Link to comment
iPrestege Posted July 12, 2013 Share Posted July 12, 2013 function onPlayerLogout ( playeraccount ) local playermoney = getPlayerMoney ( source ) local playerpoints = getElementData(source,"Points") local playertime = getElementData(source,"Playtime") local playerwins = getElementData(source,"Wins") local playerdeaths = getElementData(source,"Deaths") local playerhunters = getElementData(source,"Hunters") setAccountData ( playeraccount, "money", playermoney ) setAccountData ( playeraccount, "points", playerpoints ) setAccountData ( playeraccount, "playtime", playertime ) setAccountData ( playeraccount, "wins", playerwins ) setAccountData ( playeraccount, "deaths", playerdeaths ) setAccountData ( playeraccount, "hunters", playerhunters ) setPlayerMoney( source, 0 ) end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "money" ) local playerpoints = getAccountData ( playeraccount, "points" ) local playertime = getAccountData ( playeraccount, "playtime" ) local playerwins = getAccountData ( playeraccount, "wins" ) local playerdeaths = getAccountData ( playeraccount, "deaths" ) local playerhunters = getAccountData ( playeraccount, "hunters" ) setPlayerMoney ( source, playermoney or 0 ) setElementData(source,"Points",playerpoints or 0) setElementData(source,"Playtime",playertime or 0) setElementData(source,"Wins",playerwins or 0) setElementData(source,"Deaths",playerdeaths or 0) setElementData(source,"Hunters",playerhunters or 0) end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) Try this O_o ! Link to comment
BieHDC Posted July 12, 2013 Author Share Posted July 12, 2013 maybe can help me there also: viewtopic.php?f=91&t=62015&p=591194#p591194 Link to comment
iPrestege Posted July 12, 2013 Share Posted July 12, 2013 thx man now works Not at all. 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