Jump to content

Duvida ID


Recommended Posts

local discordInfo = {}
local discordCommands = {
    -- Funções/Comandos que serão executados pelo BOT
    ["settime"] = function(admin, args)
        local hour, minute = args[1], args[2]
        local success = setTime(hour, minute)
        
        if success then
            outputMessage(admin .. " #ffffffalterou o horário do servidor para " .. hour .. ":" .. minute .. "!")
            return "você alterou o horário no servidor."
        else
            return "algo deu errado. Use o comando novamente usando-o corretamente. "
        end
    end,
    ["text"] = function(admin, args)
        outputMessage(admin .. " #ffffffdisse: " .. args[1])
        return "sua mensagem ``" .. args[1] .. "`` foi enviada."
    end,
    ["status"] = function(admin, args)
        local online = getPlayerCount()
        local maxPlayers = getMaxPlayers()
        local serverName = getServerName()
        local serverIp = getServerConfigSetting("serverip")
        local serverPort = getServerPort()

        return {
            online = online,
            maxPlayers = maxPlayers,
            serverName = serverName,
            serverIp = serverIp,
            serverPort = serverPort
        }
    end,
    ["mute"] = function(admin, args)
        local player = getPlayerFromName(args[1])
        
        if isElement(player) then
            local playerName = getPlayerName(player)

            setPlayerMuted(player, true)
            outputMessage(admin .. " #ffffffmutou " .. playerName .. "!")
            return "**" .. playerName .. "** foi mutado(a)!"
        else
            return "**" .. args[1] .. "** está inválido."
        end
    end,
    ["givemoney"] = function(admin, args)
        local player = getPlayerFromName(args[1])
        local amount = tonumber(args[2])

        if not isElement(player) then
            return "**" .. args[1] .. "** está inválido."
        end
        if not amount or amount <= 0 then
            return "insira um valor válido e maior que 0."
        end

        local playerName = getPlayerName(player)

        givePlayerMoney(player, amount)
        outputMessage(admin .. " #ffffffdeu #008500R$" .. amount .. " #ffffffpara " .. playerName .. "!")
        return "**" .. playerName .. "** recebeu ``R$" .. amount .. "``."
    end,
    ["cgroup"] = function(admin, args)
        local groupName = args[1]

        if groupName then
            local checkGroup = aclGetGroup(groupName)
            if checkGroup then
                return "um grupo com esse nome já existe."
            end

            local newGroup = aclCreateGroup(groupName)
            if not newGroup then
                return "ocorreu um erro ao tentar criar o novo grupo."
            end

            return "grupo com o nome ``" .. groupName .. "`` foi adicionado à ACL."
        end
    end,
    ["uuu"] = function(admin, args)
        if admin == "Console" then
            discordInfo.members = args[1]
            discordInfo.inviteCode = args[2]
            discordInfo.guildName = args[3]

            updateInfo()
        end
    end
    
}

function discordRequest(command, admin, ...)
    if not discordCommands[command] then
        return "o comando não existe no servidor MTA."
    end

    local args = {...}
    return discordCommands[command](admin, args)
end

function updateInfo()
    triggerClientEvent("discordapp.update", resourceRoot, discordInfo)
end

function outputMessage(message)
    return outputChatBox("#cccccc[DISCORD] #ffffff" .. message, root, 255, 255, 255, true)
end

 

Ao invés de executar os comandos a partir do nome do player, queria que executasse pelo id do player e não sei como eu poderia fazer isso                                                                                                                    

 

 [SISTEMA DE ID QUE USO]

function Start_Id ( _, acc )
	if eventName == "onPlayerLogin" then
		setElementData ( source, "ID", getAccountID(acc) or "N/A" )
	elseif eventName == "onPlayerLogout" then
		removeElementData( source, "ID" )
	elseif eventName == "onResourceStart" then
		for _, player in pairs(getElementsByType("player")) do
			local acc = getPlayerAccount(player)
			if not isGuestAccount(acc) then
				setElementData( source, "ID", getAccountID(acc) 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 ( "#106FE7 #ffffffINFO #106FE7➺ #ffffff Nome do Jogador #106FE7" .. getPlayerName(Player2) .."", player, 255,255,255,true)
			else
				outputChatBox ( "#106FE7 #ffffffERRO #106FE7➺ #ffffff O Jogador(a) de ID: #106FE7( " .. id .. " ) #ffffffNão Foi Encontrado!", player, 255,255,255,true)
			end 
		else
			outputChatBox ( "#106FE7 #ffffffERRO #106FE7➺ #ffffff ID: #106FE7( " .. id .. " ) #ffffffInválido!", player, 255,255,255,true)
		end
	else
		outputChatBox ( "#106FE7 #ffffffERRO #106FE7➺ #ffffffUse /id #106FE7[#ffffffID#106FE7]", player, 255,255,255,true)
	end
end
addCommandHandler("id", getnick)

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

 

Link to comment
  • 6 months later...

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