Created
August 27, 2019 18:36
-
-
Save Isigar/e7a0776f53516f41f42f5c478782a6f7 to your computer and use it in GitHub Desktop.
Discord server lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ESX = nil | |
local tasks = {} | |
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) | |
RegisterServerEvent('esx:onPlayerDeath') | |
AddEventHandler('esx:onPlayerDeath', function(data) | |
data.victim = source | |
table.insert(tasks,function(cb) | |
PerformHttpRequest('https://discordapp.com/api/webhooks/615844824779849728/HqGzGpRHvpZ4TbyzQ6qa3_u2sDstwCWQDUxbzDGDjQASgFECA9cY6IhvWArTwOE3RVlC', | |
function(err, text, headers) end, 'POST', | |
json.encode({username = GetPlayerName(data.victim).." vs "..GetPlayerName(data.killerServerId), | |
content = "Hrac "..GetPlayerName(data.victim).." byl zabit hracem "..GetPlayerName(data.killerServerId).. " a byl zabit pomocí "..data.deathCause } | |
), { ['Content-Type'] = 'application/json' }) | |
cb({}) | |
end) | |
end) | |
AddEventHandler('chatMessage', function(source, name, message) | |
table.insert(tasks,function(cb) | |
PerformHttpRequest('https://discordapp.com/api/webhooks/615844824779849728/HqGzGpRHvpZ4TbyzQ6qa3_u2sDstwCWQDUxbzDGDjQASgFECA9cY6IhvWArTwOE3RVlC', function(err, text, headers) end, 'POST', json.encode({username = name, content = message}), { ['Content-Type'] = 'application/json' }) | |
cb({}) | |
end) | |
end) | |
AddEventHandler('es:playerLoaded', function(source) | |
table.insert(tasks,function(cb) | |
PerformHttpRequest('https://discordapp.com/api/webhooks/615844824779849728/HqGzGpRHvpZ4TbyzQ6qa3_u2sDstwCWQDUxbzDGDjQASgFECA9cY6IhvWArTwOE3RVlC', | |
function(err, text, headers) end, 'POST', json.encode({username = GetPlayerName(source), content = "Hrac "..GetPlayerName(source).." se připojil na server!"}), { ['Content-Type'] = 'application/json' }) | |
cb({}) | |
end) | |
end) | |
AddEventHandler('es:playerDropped', function(user) | |
table.insert(tasks,function(cb) | |
PerformHttpRequest('https://discordapp.com/api/webhooks/615844824779849728/HqGzGpRHvpZ4TbyzQ6qa3_u2sDstwCWQDUxbzDGDjQASgFECA9cY6IhvWArTwOE3RVlC', | |
function(err, text, headers) end, 'POST', json.encode({username = user.getIdentifier(), content = "Hrac "..user.getIdentifier().." se odpojil!"}), { ['Content-Type'] = 'application/json' }) | |
cb({}) | |
end) | |
end) | |
AddEventHandler('es:adminCommandFailed', function(source, command_args, user) | |
table.insert(tasks,function(cb) | |
PerformHttpRequest('https://discordapp.com/api/webhooks/615844824779849728/HqGzGpRHvpZ4TbyzQ6qa3_u2sDstwCWQDUxbzDGDjQASgFECA9cY6IhvWArTwOE3RVlC', | |
function(err, text, headers) end, 'POST', json.encode({username = GetPlayerName(user), content = "Hrac "..GetPlayerName(user).." se snaží použit admin příkaz a nemá na to práva! Args: "..command_args}), { ['Content-Type'] = 'application/json' }) | |
cb({}) | |
end) | |
end) | |
Citizen.CreateThread(function() | |
while true do | |
Async.parallel(tasks,function() | |
table.remove(tasks) | |
end) | |
Citizens.Wait(1000) | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment