Jump to content

Need Help in Save "ID" Form player


Sehloiro

Recommended Posts

Well, i have a SYSTEM ID, but it works with the release of " IDS AVAILABLE" ,

 

I would like this ID to be fixed by player, from when it entered the server saved a unique ID for it and that when it entered again the ID would continue the same

 

 

CAN ANYONE HELP ME WITH THE LINE TO SAVING "ID" IN THIS SCRIPT

 

THIS IS THE SCRIPT:

Spoiler

local idname = get ( "idDataCaption" ) or "ID"
 
g_Players = {}
 
function table.find(t, ...)
        if type(t) ~= 'table' then
                return false
        end
        local args = { ... }
        if #args == 0 then
                for k,v in pairs(t) do
                        if v then
                                return k, v
                        end
                end
                return false
        end   
        local value = table.remove(args)
        if value == '[nil]' then
                value = nil
        end
        for k,v in pairs(t) do
                for i,index in ipairs(args) do
                        if type(index) == 'function' then
                                v = index(v)
                        else
                                if index == '[last]' then
                                        index = #v
                                end
                                v = v[index]
                        end
                end
                if v == value then
                        return k, t[k]
                end
        end
        return false
end
 
function addElem(list, elem)
        local id
        local globList
        local newtable = { elem = elem }
        if not id then
                id = 1
                while list[id] do
                        id = id +1
                end
        end
        list[id] = newtable
        setElemID(elem, id)
        return id, newtable
end
 
function removeElem(list, elem)
        local id = table.find(list, 'elem', elem)
        if id then
                list[id] = nil
                setElemID(elem, nil)
                return id
        end
end
 
function getPlayerFromID(id)
        return g_Players[id] and isElement(g_Players[id].elem) and g_Players[id].elem
end
  
function getPlayerID(player)
        return getElemID(player)
end

function getElemID(elem)
        return elem and isElement(elem) and getElementData(elem, idname)
end
 
function setElemID(elem, id) 
        if elem and isElement(elem) then
                setElementData(elem, idname, id)
        end
end
 
function onResourceStart ()
call ( getResourceFromName ( "scoreboard" ), "addScoreboardColumn", idname, root,1,0.04 ) 
for k, v in ipairs(getElementsByType("player")) do 
addElem(g_Players, v)
end
end
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart )
 
function onPlayerJoin()
    addElem(g_Players, source)
    setElementData (source, "pmb", false)
    setElementData (source, "pmm", false)
end
addEventHandler ( "onPlayerJoin", root, onPlayerJoin )

function onPlayerQuit (reason)
 
        local playerID = getElemID(source)
 
        g_Players[playerID] = nil
 
end 
addEventHandler('onPlayerQuit', root, onPlayerQuit)

--============================================================================================================================--
--[[                               ################################################
                                   #               SISTEMA COMANDOS               #                                                                
                                   ################################################
]]

                                   --=============================--
                                   ----------- ID PLAYER ------------
                                   --=============================--
function getnick(player, command, id, ...)
    if(id) then
        local playerID = tonumber(id)
    if(playerID) then
        local Player2 = getPlayerFromID(playerID)
    if(Player2) then    
        outputChatBox ( "#ff0000✘ #ffffffINFO #ff0000✘➺ #ffffff Nome do Jogador #00ff00" .. getPlayerName(Player2) .."", player, 255,255,255,true)
 else
        outputChatBox ( "#ff0000✘ #ffffffERRO #ff0000✘➺ #ffffff O Jogador(a) de ID: #FF0000( " .. id .. " ) #ffffffNão Foi Encontrado!", player, 255,255,255,true)
end 
     else
        outputChatBox ( "#ff0000✘ #ffffffERRO #ff0000✘➺ #ffffff ID: #FF0000( " .. id .. " ) #ffffffInválido!", player, 255,255,255,true)
end
     else
        outputChatBox ( "#ff0000✘ #ffffffERRO #ff0000✘➺ #ffffffUse /id #ff0000[#ffffffID#ff0000]", player, 255,255,255,true)
end
end
addCommandHandler("id", getnick)
 

 
 
 
 
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...