littlejth Posted April 18, 2009 Share Posted April 18, 2009 Does someone know why this may not be working, this is the example from the wiki that I am trying to use: function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getPlayerMoney ( source ) setAccountData ( playeraccount, "money", playermoney ) end end function onPlayerJoin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "money" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end ............. addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) Link to comment
Thehookerkiller01 Posted April 18, 2009 Share Posted April 18, 2009 Does someone know why this may not be working, this is the example from the wiki that I am trying to use: function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getPlayerMoney ( source ) setAccountData ( playeraccount, "money", playermoney ) end end function onPlayerJoin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "money" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end ............. addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin ) You just should have to save setAccountData ( playeraccount, "money", playermoney ) in another file. And for the onPlayerJoin part the sever have to know who the player is. And how many money he or she has. Maybe try getClientName or something. Link to comment
robhol Posted April 18, 2009 Share Posted April 18, 2009 Hookerkiller, you obviously haven't got the foggiest idea of what you're saying. Shut up until you know what you're talking about. As for you, littlejth, 1) Don't listen to thehookerkiller 2) You need to give us more info. Error messages and warnings (the entire message) and the lines they indicate. Link to comment
Gamesnert Posted April 18, 2009 Share Posted April 18, 2009 I think this part is giving you trouble... function onPlayerJoin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "money" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end Because most probably, when a player joins, he still is on a guest account. (which doesn't have any account data) I guess this might make it work, not sure, but worth a try I guess... (I think you can remove onPlayerJoin if you use this) function onClientLogin ( previous, new ) if new and not isGuestAccount ( new ) then -- Just added this to be sure local playermoney = getAccountData ( new, "money" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end end end addEventHandler ( "onClientLogin", getRootElement ( ), onClientLogin ) Link to comment
robhol Posted April 18, 2009 Share Posted April 18, 2009 Wow. I shouldv'e seen that. ._. Anyways, I think you should rename the function itself (I'm not sure, but I think I've heard that having functions the same names as av event isn't good.) Link to comment
lil Toady Posted April 18, 2009 Share Posted April 18, 2009 Anyways, I think you should rename the function itself (I'm not sure, but I think I've heard that having functions the same names as av event isn't good.) Nah, nothing bad about it Link to comment
robhol Posted April 18, 2009 Share Posted April 18, 2009 Anyways, I think you should rename the function itself (I'm not sure, but I think I've heard that having functions the same names as av event isn't good.) Nah, nothing bad about it Good to know, thanks. 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