Jump to content

Guest function


Memory

Recommended Posts

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
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
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

@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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...