Jump to content

ID Admin


abu5lf

Recommended Posts

command : /kick id (ex. /kick 1)

function kickPlayerHandler ( sourcePlayer,cmd,id ) 
      local kicked= getPlayerFromID(id) 
    if ( hasObjectPermissionTo ( sourcePlayer, "function.kickPlayer" ) ) then 
       kickPlayer(kicked) 
    end 
end 
addCommandHandler ( "kick", kickPlayerHandler ) 
  
  
function getPlayerFromID(who) 
 for i,v in pairs">pairs(getElementsByType("player") )do 
    if  getElementData(v,"ID")==who then  
         return v  
     end 
        end 
         end 

Link to comment
local optimize = true  
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">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">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 

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...