Jump to content

[HELP] Stats Panel


MRThinker

Recommended Posts

This is not a place to request full code.. and there are far too many functions to list, it also depends on what exactly you want. Just check the GUI functions on the wiki and see what kind of elements you want to utilise. It's all documented there, the rest is straight forward.. player name? getPlayerName.. player money? getPlayerMoney... wanted level? getPlayerWantedLevel... you see the pattern yet?

Link to comment
3 minutes ago, MIKI785 said:

This is not a place to request full code.. and there are far too many functions to list, it also depends on what exactly you want. Just check the GUI functions on the wiki and see what kind of elements you want to utilise. It's all documented there, the rest is straight forward.. player name? getPlayerName.. player money? getPlayerMoney... wanted level? getPlayerWantedLevel... you see the pattern yet?

i know this functions...

i dont know gui functions !

plz give me :( 

Link to comment
Just now, Dimos7 said:

how me your code

 

exports [ "scoreboard" ]:addScoreboardColumn ( "ID", getRootElement() )   
function showID (player) 
    for index, player in ipairs ( getElementsByType "player" ) do 
		setElementData(player,"ID",getElementData(player,"id")) 
    end 
end 
addEventHandler("onPlayerJoin",getRootElement(),showID)

 

Link to comment
ID = {}
exports["scoreboard"]:addScoreboardColumn("ID", root, 20, "ID", 1)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

 

Edited by Dimos7
Link to comment
3 minutes ago, Dimos7 said:

ID = {}
exports["scoreboard"]:addScoreboardColumn("ID", root, 20, "ID", 1)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

 

worked but id dont showing on scoreboard !

Link to comment
ID = {}
exports["scoreboard"]:addScoreboardColumn("id", root, 20, "id", 2)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

Save it restart the resource and after change it 2 to 1

 

Edited by Dimos7
Link to comment
5 minutes ago, Dimos7 said:

ID = {}
exports["scoreboard"]:addScoreboardColumn("ID", root, 20, "ID", 2)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

Save it restart the resource and after change it to

This code not only shows the id before the name, it does not even show an id :( 

Link to comment
ID = {}
exports["scoreboard"]:addScoreboardColumn("id", root, 20, "id", 1)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

 

Link to comment
2 minutes ago, Dimos7 said:

ID = {}
exports["scoreboard"]:addScoreboardColumn("id", root, 20, "id", 1)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

 

id now showing or id after Name :( 

10 minutes ago, Dimos7 said:

ID = {}
exports["scoreboard"]:addScoreboardColumn("id", root, 20, "id", 1)

------------------------  [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, function()
       for i = 0 , getMaxPlayers() do
          if not ID[i] then
             ID[i] = source
             setElementData(source, "id", i)
             break
          end
      end
end)

--

addEventHandler("onPlayerQuit", root, function()
      ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, function()
       for _, v in ipairs(getElementsByType("player")) do
            for i = 0, getMaxPlayers() do
                if not ID[i]  then
                   ID[i] = v
                   setElementData(v, "id", i)
                   break
                end
            end
       end
end)

---------------------------------- [ Fnctions ] ------------------------------------

function getPlayerID(player)
  if player and isElement(player) and getElementType(player) == "player" and getElementData(player, "id") then
    return getElementData(player, "id")
  end
  return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id) and ID[tonumber(id)] then
       return ID[tonumber(id)]
    end
  return false
end

 

worked successfuly !

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