Jonas <#C Posted December 10, 2018 Share Posted December 10, 2018 English Hello. Hello, I'm sorry for my English. Well I made this script to change the nick of the player to an ID, and it was not duplicated, it's not working as it should. Could you help with this or see something similar? OBS: I've started to script. Português (Brazil) Olá já venho desculpar meu inglês, Bom eu fiz este script para que trocasse o nick do player para um ID, E não fosse Duplicado, ele não está funcionando como deveria, Poderia ajudar com este ou ver algo semelhante ? OBS: Começei ontém a fazer script local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id",i) break end end end addEventHandler("onPlayerJoin",root,assignID) function startup() ids = {} for k, v in ipairs(getElementsByType("player")) do local id = setElementData(v,"id",k) ids[k] = v end end addEventHandler("onResourceStart",resourceRoot,startup) function freeID() local id = getElementData(source,"id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit",root,freeID) function getPlayerID ( player ) return getElementData( player, "id") end function getPlayerFromId ( theID ) if theID then local theID = tonumber(theID) local theplayer for index,player in ipairs(getElementsByType("player")) do if getElementData(player ,"id") == theID then theplayer = player end end return theplayer else return false end end Link to comment
Moderators Patrick Posted December 10, 2018 Moderators Share Posted December 10, 2018 local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id",i) break end end end addEventHandler("onPlayerJoin",root,assignID) function startup() ids = {} for _, player in ipairs(getElementsByType("player")) do local id = getElementData(player,"id") if id then ids[id] = player end end end addEventHandler("onResourceStart",resourceRoot,startup) function freeID() local id = getElementData(source,"id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit",root,freeID) function getPlayerID ( player ) return getElementData( player, "id") end function getPlayerFromId ( theID ) if theID then local theID = tonumber(theID) for _,player in ipairs(getElementsByType("player")) do if getElementData(player ,"id") == theID then return player end end return false else return false end end Link to comment
Jonas^ Posted December 10, 2018 Share Posted December 10, 2018 14 hours ago, Jonas <#C said: English Hello. Hello, I'm sorry for my English. Well I made this script to change the nick of the player to an ID, and it was not duplicated, it's not working as it should. Could you help with this or see something similar? OBS: I've started to script. Português (Brazil) Olá já venho desculpar meu inglês, Bom eu fiz este script para que trocasse o nick do player para um ID, E não fosse Duplicado, ele não está funcionando como deveria, Poderia ajudar com este ou ver algo semelhante ? OBS: Começei ontém a fazer script local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id",i) break end end end addEventHandler("onPlayerJoin",root,assignID) function startup() ids = {} for k, v in ipairs(getElementsByType("player")) do local id = setElementData(v,"id",k) ids[k] = v end end addEventHandler("onResourceStart",resourceRoot,startup) function freeID() local id = getElementData(source,"id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit",root,freeID) function getPlayerID ( player ) return getElementData( player, "id") end function getPlayerFromId ( theID ) if theID then local theID = tonumber(theID) local theplayer for index,player in ipairs(getElementsByType("player")) do if getElementData(player ,"id") == theID then theplayer = player end end return theplayer else return false end end Se você é português poste na seção portuguesa do fórum. Link to comment
Jonas <#C Posted December 10, 2018 Author Share Posted December 10, 2018 Ok obrigada irei fazer, é que pensei que americanos poderiam resolver mais rápido mais me enganei irei postar lá obrigado pelo dica. <# 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