zezim Posted May 20, 2022 Posted May 20, 2022 (edited) Hey guys, whats up! Can you help me with this id system? What is wrong in my code? I tried anyway to modify it but I couldn't. When I type the command /id to see the player's id, I can't see it. When I format the code to standard and put the low id system, I get it. If you can help me, I would really appreciate it! function genRandomID() local rnumber = "" local chars = "1234567890" for i = 1, 5 do -- Aqui você define a quantidade de digitos, aqui vai ser gerado um numero com 5 digitos local rand = math.random(#chars) rnumber = rnumber .. chars:sub(rand, rand) end return rnumber end local randomID = genRandomID() function Start_Id ( _, acc ) if eventName == "onPlayerLogin" then setElementData(source, "ID", randomID or "N/A" ) outputChatBox ( "#838B83➲ #ff0000LOGIN #838B83➲ Nick: #ff0000 ( ".. getPlayerName(source) .." #ff0000) ID: ( "..(getAccountID(acc) or "N/A") .." )", root, 255,255,255,true) elseif eventName == "onPlayerLogout" then removeElementData( source, "ID" ) outputChatBox ( "#838B83➲ #ff0000LOGIN #838B83➲ Nick: #ff0000 ( ".. getPlayerName(source) .." #ff0000) Deslogou.", root, 255,255,255,true) elseif eventName == "onResourceStart" then for _, player in pairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then setElementData(source, "ID", randomID or "N/A" ) end end end end addEventHandler("onResourceStart", resourceRoot, Start_Id) addEventHandler("onPlayerLogout", root, Start_Id) addEventHandler("onPlayerLogin", root, Start_Id) function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end --============================================================================================================================-- --=============================-- ----------- ID PLAYER ------------ --=============================-- function getnick(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local Player2 = getPlayerID(playerID) if(Player2) then outputChatBox ( "#838B83➲ #ff0000INFO #ff0000 ➲ #ff0000 Nome do Jogador #ff0000" .. getPlayerName(Player2) .."", player, 255,255,255,true) else outputChatBox ( "#838B83➲ #ff0000ERRO #ff0000 ➲ #ff0000 O Jogador(a) de ID: #ff0000( " .. id .. " ) #ff0000Não Foi Encontrado!", player, 255,255,255,true) end else outputChatBox ( "#838B83➲ #ff0000ERRO #ff0000 ➲ #ff0000 ID: #ff0000( " .. id .. " ) #ff0000Inválido!", player, 255,255,255,true) end else outputChatBox ( "#838B83➲ #ff0000 Use /id #ff0000[#ffffffID#00ff00]", player, 255,255,255,true) end end addCommandHandler("id", getnick) who can help pls i beg Edited May 20, 2022 by zezim
Moderators Tut Posted May 20, 2022 Moderators Posted May 20, 2022 Hey, I've closed this as it's best to only have 1 instance of a question up. If you have multiple threads on the same issue, people might be providing you with the same answers across the two.
Recommended Posts