TheGuyNL Posted March 22, 2012 Posted March 22, 2012 Is there an event for when a new map loads? I need my cash in the scoreboard to update after a new map loads, how do I do this? Here is my script: exports["scoreboard"]:scoreboardAddColumn("Cash") exports["scoreboard"]:scoreboardAddColumn("Points") function setStats(player) local account = getPlayerAccount(player) if (account) then local cash = getAccountData(account, "cash") local points = getAccountData(account, "points") setElementData ( player, "Cash", "$" ..cash.. "" ) setElementData ( player, "Points", points ) else setElementData ( player, "Cash", "guest" ) setElementData ( player, "Points", "guest" ) end end function timer() setTimer( setStats, 1000, 1, source ) end addEventHandler("onPlayerLogin", getRootElement(), timer) addEventHandler("onPlayerJoin", getRootElement(), timer) Owner of:
Wei Posted March 22, 2012 Posted March 22, 2012 exports.scoreboard:addScoreboardColumn('Cash') function fCashShow ( ) setElementData( source,"Cash",getPlayerMoney( source ) ) end addEventHandler( 'onPlayerJoin', root, fCashShow ) This is my for cash if it helps you. Diet with russian vodka, lose 3 days in one week !
Castillo Posted March 22, 2012 Posted March 22, 2012 exports[ "scoreboard" ]:scoreboardAddColumn ( "Cash" ) exports[ "scoreboard" ]:scoreboardAddColumn ( "Points" ) function setStats ( player ) if ( not player or not isElement ( player ) ) then return end local account = getPlayerAccount ( player ) if ( account and not isGuestAccount ( account ) ) then local cash = getAccountData ( account, "cash" ) local points = getAccountData ( account, "points" ) setElementData ( player, "Cash", "$" .. cash or 0 ) setElementData ( player, "Points", points or 0 ) else setElementData ( player, "Cash", "guest" ) setElementData ( player, "Points", "guest" ) end end function timer() setTimer( setStats, 1000, 1, source ) end addEventHandler("onPlayerLogin", getRootElement(), timer) addEventHandler("onPlayerJoin", getRootElement(), timer) addEvent ( "onMapStarting", true ) addEventHandler ( "onMapStarting", root, function ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do setStats ( player ) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TheGuyNL Posted March 22, 2012 Author Posted March 22, 2012 exports[ "scoreboard" ]:scoreboardAddColumn ( "Cash" ) exports[ "scoreboard" ]:scoreboardAddColumn ( "Points" ) function setStats ( player ) if ( not player or not isElement ( player ) ) then return end local account = getPlayerAccount ( player ) if ( account and not isGuestAccount ( account ) ) then local cash = getAccountData ( account, "cash" ) local points = getAccountData ( account, "points" ) setElementData ( player, "Cash", "$" .. cash or 0 ) setElementData ( player, "Points", points or 0 ) else setElementData ( player, "Cash", "guest" ) setElementData ( player, "Points", "guest" ) end end function timer() setTimer( setStats, 1000, 1, source ) end addEventHandler("onPlayerLogin", getRootElement(), timer) addEventHandler("onPlayerJoin", getRootElement(), timer) addEvent ( "onMapStarting", true ) addEventHandler ( "onMapStarting", root, function ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do setStats ( player ) end end ) Thanks! This works great. Owner of:
Castillo Posted March 22, 2012 Posted March 22, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TheGuyNL Posted March 22, 2012 Author Posted March 22, 2012 Something else, what is the function to restart a map? to make a command like /redo Owner of:
Castillo Posted March 22, 2012 Posted March 22, 2012 You can get the current map with: exports.mapmanager:getRunningGamemodeMap() and change it with this: exports.mapmanager:changeGamemodeMap() San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
TheGuyNL Posted March 22, 2012 Author Posted March 22, 2012 You can get the current map with: exports.mapmanager:getRunningGamemodeMap() and change it with this: exports.mapmanager:changeGamemodeMap Again, thanks alot. Owner of:
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