Dimos7 Posted January 30, 2015 Posted January 30, 2015 (edited) local optimize = true local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id", i, not optimize) break end end end addEventHandler("onPlayerJoin", root, assignID) function startup() for k, v in ipairs(getElementsByType("player")) do local id = getElementData(v,"id") if id then ids[id] = v end end end addEventHandler("onResourceStart", resourceRoot, startup) function getPlayerID(player) for k, v in ipairs(ids) do if v == player then return k end end end function freeID() local id = getElementData(source, "id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit", root, freeID) function getPlayerByID(id) local player = ids[id] return player or false end function showIDs (option) if option == false then gameShowIDs = false call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "ID") else gameShowIDs = true call(getResourceFromName("scoreboard"), "addScoreboardColumn", "ID") end end addEventHandler("onResourceStart", resourceRoot, showIDs) Edited February 17, 2015 by Guest
3B00DG4MER Posted January 30, 2015 Posted January 30, 2015 Give me line 75 (Write it !) Cuz i can't get the line while the script isn't full !
Dimos7 Posted February 17, 2015 Author Posted February 17, 2015 can help me with it now aprear the number of id also i want put it before name
3B00DG4MER Posted February 17, 2015 Posted February 17, 2015 local optimize = true local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id", i, not optimize) break end end end addEventHandler("onPlayerJoin", root, assignID) function startup() for k, v in ipairs(getElementsByType("player")) do local id = getElementData(v,"id") if id then ids[id] = v end end end addEventHandler("onResourceStart", resourceRoot, startup) function getPlayerID(player) for k, v in ipairs(ids) do if v == player then return k end end end function freeID() local id = getElementData(source, "id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit", root, freeID) function getPlayerByID(id) local player = ids[id] return player or false end function showIDs (option) if option == false then gameShowIDs = false call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "ID") else gameShowIDs = true call(getResourceFromName("scoreboard"), "addScoreboardColumn", "ID") scoreboardSetColumnTextFunction ( "ID", function() return getPlayerID(localPlayer) end) scoreboardSetColumnPriority ( "ID", 1) end end addEventHandler("onResourceStart", resourceRoot, showIDs) This should work,next time check https://wiki.multitheftauto.com/wiki/Dxscoreboard
Dimos7 Posted February 17, 2015 Author Posted February 17, 2015 still the same and localplayer is for client no server aslo say a nill value
n3wage Posted February 17, 2015 Posted February 17, 2015 Replace showIDs function with this one: function showIDs (option) if option == false then gameShowIDs = false exports["scoreboard"]:scoreboardRemoveColumn ( "id", root ) else gameShowIDs = true exports["scoreboard"]:scoreboardAddColumn ( "id", root, 50, "ID", 1 ) end end addEventHandler("onResourceStart", resourceRoot, showIDs)
Dimos7 Posted February 17, 2015 Author Posted February 17, 2015 local optimize = true local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id", i, not optimize) break end end end addEventHandler("onPlayerJoin", root, assignID) function startup() for k, v in ipairs(getElementsByType("player")) do local id = getElementData(v,"id") if id then ids[id] = v end end end addEventHandler("onResourceStart", resourceRoot, startup) function getPlayerID(player) for k, v in ipairs(ids) do if v == player then return k end end end function freeID() local id = getElementData(source, "id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit", root, freeID) function getPlayerByID(id) local player = ids[id] return player or false end function showIDs (option) if option == false then gameShowIDs = false exports["Scoreboard"]:scoreboardRemoveColum("id") else gameShowIDs = true exports["Scoreboard"]:scoreboardAddColumn("id", function() return getPlayerID(player) end, 20, "ID", 1) end end addEventHandler("onResourceStart", resourceRoot, showIDs) still no show the id number
n3wage Posted February 17, 2015 Posted February 17, 2015 hmm, i remade the script, try: ID = {} exports["scoreboard"]:scoreboardAddColumn ( "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) --------------------------- [ Functions ] --------------------------- 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
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