xeon17 Posted February 28, 2014 Share Posted February 28, 2014 The script no work tryed everything to fix but.. function kickCommand(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local target = getPlayerFromID(playerID) if(target) then local args = { ... } local reason = "" for k,v in pairs(args) do reason = reason .. ' ' .. v end if(reason ~= "") then outputChatBox ( "O jogador " .. getPlayerName(target) .. "(" .. id .. ") " .. "foi kickado por " .. getPlayerName(player) .. "(" .. (getPlayerID(player) or "???") .. ") -> (motivo:" .. reason .. ").", root, 0, 236, 255) else outputChatBox ( "O jogador " .. getPlayerName(target) .. "(" .. id .. ") " .. "foi kickado por " .. getPlayerName(player) .. "(" .. (getPlayerID(player) or "???") .. ").", root, 0, 236, 255) end kickPlayer(target, player, reason) else outputChatBox ( "[ERRO] Player (" .. id .. ") não encontrado. ", player, 255, 0, 0) end else outputChatBox ( "[ERRO] ID (" .. id .. ") invalido. ", player, 255, 0, 0) end else outputChatBox ( "[servidor] use: /ikick [id] [motivo]", player, 255, 255, 255) end end addCommandHandler("ikick", kickCommand, true) Link to comment
cheez3d Posted February 28, 2014 Share Posted February 28, 2014 function kickPlayerCommand(player,command,target,...) local reason = {...} if target then local whoToKick = getPlayerFromName(target) if whoToKick then kickPlayer(whoToKick,player,(table.concat(reason," ") ~= "" and table.concat(reason," ") or "No reason specified!")) end else outputChatBox("ERROR - No target specified!",player,255,0,0) outputChatBox("SYNTAX: /ikick [reason]",player,0,255,0) end end addCommandHandler("ikick",kickPlayerCommand,true) Try this. Link to comment
xeon17 Posted February 28, 2014 Author Share Posted February 28, 2014 I need a Kick command by ID , this allerdy i have. Link to comment
cheez3d Posted February 28, 2014 Share Posted February 28, 2014 Then you have to create your own ID system. getPlayerFromID - there is no such function I suggest setElementData and getElementData for the ID system Link to comment
xeon17 Posted February 28, 2014 Author Share Posted February 28, 2014 Allerdy i did 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.05 ) for k, v in ipairs(getElementsByType("player")) do addElem(g_Players, v) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function onPlayerJoin() addElem(g_Players, source) end addEventHandler ( "onPlayerJoin", root, onPlayerJoin ) function onPlayerQuit (reason) local playerID = getElemID(source) g_Players[playerID] = nil end addEventHandler('onPlayerQuit', root, onPlayerQuit) Link to comment
cheez3d Posted February 28, 2014 Share Posted February 28, 2014 assingIDToPlayer = function() local connectedPlayers = getElementsByType("player") local assignedID = #connectedPlayers+1 local checkIDUniqueness = function() for _,player in ipairs (connectedPlayers) do if getElementData(player,"ID") == assignedID then assignedID = assignedID+1 checkIDUniqueness() break end setElementData(source,"ID",assignedID) end end checkIDUniqueness() end addEventHandler("onPlayerJoin",root,assingIDToPlayer) kickPlayerByID = function(player,command,id,...) local reason = {...} if id then for _,target in ipairs (getElementsByType("player")) do outputChatBox(id,player) outputChatBox(getElementData(player,"ID"),player) if tostring(getElementData(player,"ID")) == id then kickPlayer(target,player,(table.concat(reason," ") ~= "" and table.concat(reason," ") or "No reason specified!")) outputChatBox("INFO - "..player.." kicked "..target..", reason - "..(table.concat(reason," ") ~= "" and table.concat(reason," ") or "No reason specified!"),root,255,255,255) end end else outputChatBox("ERROR - No ID specified!",player,255,0,0) outputChatBox("SYNTAX: /ikick [reason]",player,0,255,0) end end addCommandHandler("ikick",kickPlayerByID) 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