MRThinker

[HELP] Stats Panel

Recommended Posts

hi guys

 

i wank make a stats panel !

like : press F1 and show GUI and show player name, show player money, show player wanted level and more ...

 

plz give me code or functions ❤️ 

 

@MIKI785

Share this post


Link to post

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?

Share this post


Link to post
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 :( 

Share this post


Link to post
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)

 

Share this post


Link to post
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

Share this post


Link to post
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 !

Share this post


Link to post

replace this exports["scoreboard"]:addScoreboardColumn("ID", root, 20, "ID", 1)

with this

exports["scoreboard"]:addScoreboardColumn("id", root, 20, "id", 1)

Share this post


Link to post
2 minutes ago, #STARK said:

replace this exports["scoreboard"]:addScoreboardColumn("ID", root, 20, "ID", 1)

with this

exports["scoreboard"]:addScoreboardColumn("id", root, 20, "id", 1)

worked but ID showing after Name

how to show ID before Name ?

Share this post


Link to post
18 minutes ago, MRThinker said:

worked but ID showing after Name

how to show ID before Name ?

That is impossible for me that code put the id before name 

Share this post


Link to post
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

Share this post


Link to post
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 :( 

Share this post


Link to post
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

 

Share this post


Link to post
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 !

Share this post


Link to post

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.