Jump to content

Guest function


Memory

Recommended Posts

Posted

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 ) 

Ingame name: [sV]Kostya

Name in scripts: Kostya

Posted

You must use:

isGuestAccount 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I already try use this, but didn't turn out. Can you add this function to code?

Ingame name: [sV]Kostya

Name in scripts: Kostya

Posted

Post here what you tried.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Ingame name: [sV]Kostya

Name in scripts: Kostya

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

Guest Guest4401
Posted

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

Posted (edited)

Thanks all for help, work.

I have still one question. How make command, example /resetpoints, for remove points all players?

Edited by Guest

Ingame name: [sV]Kostya

Name in scripts: Kostya

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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