Brolis Posted August 9, 2012 Share Posted August 9, 2012 (edited) Hello everyone, I am using this resource: local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side) 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 But then I press TAB, there I can't see ids and player id or whatever, is here any player id system? I am using simple default scoreboard... Edited August 16, 2012 by Guest Link to comment
Castillo Posted August 10, 2012 Share Posted August 10, 2012 local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side) 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() exports [ "scoreboard" ]:scoreboardAddColumn( "id" ) 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 That'll add a column called "id" to the scoreboard. Link to comment
Brolis Posted August 10, 2012 Author Share Posted August 10, 2012 Thanks, I'll try it! Link to comment
Lloyd Logan Posted August 11, 2012 Share Posted August 11, 2012 local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side) 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() exports [ "scoreboard" ]:scoreboardAddColumn( "id" ) 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 That'll add a column called "id" to the scoreboard. But no I'd comes up for the player??? Link to comment
Castillo Posted August 11, 2012 Share Posted August 11, 2012 I don't understand your question, please explain yourself further. Link to comment
Lloyd Logan Posted August 11, 2012 Share Posted August 11, 2012 I don't understand your question, please explain yourself further. Okay, when I press TAB, it comes up The name of the player, and the ping, when i add this resource, it adds an id column, but no ID appears, Please Help? Link to comment
Castillo Posted August 11, 2012 Share Posted August 11, 2012 Have you tried reconnecting? if the 'id' element data was set successfully, then it should show it on scoreboard as well. Link to comment
Lloyd Logan Posted August 11, 2012 Share Posted August 11, 2012 Have you tried reconnecting? if the 'id' element data was set successfully, then it should show it on scoreboard as well. Aww, Thanks, Reconnecting did the trick!! Link to comment
Supreme_Gogo7 Posted November 23, 2021 Share Posted November 23, 2021 where to write this code? 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