Brolis Posted August 9, 2012 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
Castillo Posted August 10, 2012 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted August 10, 2012 Posted August 10, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted August 11, 2012 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??? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted August 11, 2012 Posted August 11, 2012 I don't understand your question, please explain yourself further. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted August 11, 2012 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? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted August 11, 2012 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted August 11, 2012 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!! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
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