Memory Posted August 23, 2012 Share Posted August 23, 2012 Hi, Please, change this code, when player is guest, export "setElementData( v, "Points", "Guest" )". exports [ 'scoreboard' ]:addScoreboardColumn ( "Points" ) function refreshData() for k, v in ipairs (getElementsByType("player")) do local data = getAccountData(getPlayerAccount( v ), "Points" ) if data then setElementData( v, "Points", data.." pts" ) end end end setTimer( refreshData, 1000, 0 ) Link to comment
Castillo Posted August 23, 2012 Share Posted August 23, 2012 You must use: isGuestAccount Link to comment
Memory Posted August 23, 2012 Author Share Posted August 23, 2012 I already try use this, but didn't turn out. Can you add this function to code? Link to comment
Castillo Posted August 23, 2012 Share Posted August 23, 2012 Post here what you tried. Link to comment
Memory Posted August 24, 2012 Author Share Posted August 24, 2012 exports [ 'scoreboard' ]:addScoreboardColumn ( "Points" ) function refreshData() for k, v in ipairs (getElementsByType("player")) do local account = getPlayerAccount( v ) if isGuestAccount(account) then setElementData( v, "Points", "Guest" ) outputChatBox("Please, log in or register for save points" , source, 255, 0, 0, true) else local data = getAccountData(getPlayerAccount( v ), "Points" ) if data then setElementData( v, "Points", data.." pts" ) end end end setTimer( refreshData, 1000, 0 ) Link to comment
Kareth Posted August 24, 2012 Share Posted August 24, 2012 exports [ 'scoreboard' ]:addScoreboardColumn ( "Points" ) function refreshData() for k, v in ipairs (getElementsByType("player")) do local account = getPlayerAccount( v ) if isGuestAccount(account) then setElementData( v, "Points", "Guest" ) outputChatBox("Please, log in or register for save points" , v, 255, 0, 0, true) else local data = getAccountData(getPlayerAccount( v ), "Points" ) if data then setElementData( v, "Points", data.." pts" ) end end end end setTimer( refreshData, 1000, 0 ) You were using source instead of v in your outputChatBox Edit: there was also a missing end, try my code Edit2: try to make your code organized taking care of if, else, functions, ends... as easier you make it to read, better for you and for people who will try to help you: exports [ 'scoreboard' ]:addScoreboardColumn ( "Points" ) setTimer ( function () for k, v in ipairs (getElementsByType("player")) do local account = getPlayerAccount( v ) if isGuestAccount(account) then setElementData( v, "Points", "Guest" ) outputChatBox("Please, log in or register for save points" , v, 255, 0, 0, true) else local data = getAccountData(getPlayerAccount( v ), "Points" ) if data then setElementData( v, "Points", data.." pts" ) end end end end, 1000, 0) Link to comment
Guest Guest4401 Posted August 24, 2012 Share Posted August 24, 2012 @Memory/Kareth outputChatBox("Please, log in or register for save points" , source, 255, 0, 0, true) I doubt if anyone would like to read that message EVERY second. Link to comment
GTX Posted August 24, 2012 Share Posted August 24, 2012 https://wiki.multitheftauto.com/wiki/OnPlayerLogin Link to comment
Kareth Posted August 24, 2012 Share Posted August 24, 2012 @karthik_184 Well thats true, i just made the script work as he had it. Link to comment
Memory Posted August 29, 2012 Author Share Posted August 29, 2012 (edited) Thanks all for help, work. I have still one question. How make command, example /resetpoints, for remove points all players? Edited August 29, 2012 by Guest Link to comment
Castillo Posted August 29, 2012 Share Posted August 29, 2012 addCommandHandler ( "resetpoints", function ( ) for _, player in ipairs ( getElementsByType ( "player" ) ) do setElementData ( player, "Points", 0 ) local account = getPlayerAccount ( player ) if isGuestAccount ( account ) then setAccountData ( account, "Points", 0 ) end end end ) 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