I’m trying to get this unseat command to work. Its shows who unseats who, but doesn’t do anything. Any help is much appreciated. Thanks in advance!
--SERVER
-- Start unseat
TriggerEvent('es:addGroupCommand', 'unseat', "user", function(source, args, user)
if(GetPlayerName(tonumber(args[2])) or GetPlayerName(tonumber(args[3])))then
local player = tonumber(args[2])
table.remove(args, 2)
table.remove(args, 1)
TriggerEvent("es:getPlayerFromId", player, function(target)
TriggerClientEvent("mt:notify", source, "~y~You've unseated: ~b~" ..GetPlayerName(player).. ".")
TriggerClientEvent("mt:notify", player, "~r~You have been unseated by "..GetPlayerName(source).. ".")
TriggerClientEvent("Unseat", player)
end)
else
TriggerClientEvent('chatMessage', source, "", {255, 0, 0}, "You need to use the players ^3ID ^0 to unseat them.")
TriggerClientEvent('chatMessage', source, "", {255, 0, 0}, "Ex: ^3/unseat 1")
end
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, "", {255, 0, 0}, "You don't have the correct permissions.")
end)
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
-- End unseat
--CLIENT
RegisterNetEvent("mt:notify")
AddEventHandler("mt:notify", function(text, time)
ClearPrints()
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(true, false)
end)
-- Start Unseat
RegisterNetEvent("Unseat")
AddEventHandler("Unseat", function()
local lPed = GetPlayerPed(-1)
if DoesEntityExist(lPed) then
TriggerEvent('es:getPlayerFromId', tonumber(args[2]), function(target)
if(get3DDistance(target.getCoords().x, target.getCoords().y, target.getCoords().z, user.getCoords().x, user.getCoords().y, user.getCoords().z) < 7.0)then
ClearPedTasksImmediately(GetPlayerPed(-1))
end
end)
-- End unseat```