Dimos7 Posted January 30, 2015 Share 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 Link to comment
3B00DG4MER Posted January 30, 2015 Share Posted January 30, 2015 What's matter with it ?! Link to comment
Dimos7 Posted January 30, 2015 Author Share Posted January 30, 2015 error line 75 then excpeted near "=" Link to comment
3B00DG4MER Posted January 30, 2015 Share Posted January 30, 2015 Give me line 75 (Write it !) Cuz i can't get the line while the script isn't full ! Link to comment
Dimos7 Posted January 30, 2015 Author Share Posted January 30, 2015 script was full but anway i fix it Link to comment
Dimos7 Posted February 17, 2015 Author Share Posted February 17, 2015 can help me with it now aprear the number of id also i want put it before name Link to comment
3B00DG4MER Posted February 17, 2015 Share 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 Link to comment
Dimos7 Posted February 17, 2015 Author Share Posted February 17, 2015 still the same and localplayer is for client no server aslo say a nill value Link to comment
n3wage Posted February 17, 2015 Share 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) Link to comment
Dimos7 Posted February 17, 2015 Author Share 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 Link to comment
n3wage Posted February 17, 2015 Share 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 Link to comment
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