@@ -24,11 +24,13 @@ AddEventHandler('chatMessage', function(source, name, message)
2424end )
2525
2626AddEventHandler (' playerConnecting' , function ()
27- PerformHttpRequest (DISCORD_WEBHOOK , function (err , text , headers ) end , ' POST' , json .encode ({username = DISCORD_NAME , content = " ```CSS\n " .. GetPlayerName (source ) .. " connecting\n ```" , avatar_url = DISCORD_IMAGE }), { [' Content-Type' ] = ' application/json' })
27+ -- PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```CSS\n".. GetPlayerName(source) .. " connecting\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
28+ sendToDiscord (" Server Login" , GetPlayerName (source ) " is connecting to the server." )
2829end )
2930
3031AddEventHandler (' playerDropped' , function (reason )
31- PerformHttpRequest (DISCORD_WEBHOOK , function (err , text , headers ) end , ' POST' , json .encode ({username = DISCORD_NAME , content = " ```fix\n " .. GetPlayerName (source ) .. " left ( " .. reason .. " )\n ```" , avatar_url = DISCORD_IMAGE }), { [' Content-Type' ] = ' application/json' })
32+ -- PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end, 'POST', json.encode({username = DISCORD_NAME, content = "```fix\n".. GetPlayerName(source) .. " left ( ".. reason .. " )\n```", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
33+ sendToDiscord (" Server Logout" , GetPlayerName (source ) " has disconnected from the server." )
3234end )
3335
3436RegisterServerEvent (' playerDied' )
@@ -70,4 +72,18 @@ function stringsplit(input, seperator)
7072 end
7173
7274 return t
75+ end
76+
77+ function sendToDiscord (name , message )
78+ local connect = {
79+ {
80+ [" color" ] = " 8663711" ,
81+ [" title" ] = " **" .. name .. " **" ,
82+ [" description" ] = message ,
83+ [" footer" ] = {
84+ [" text" ] = " Made by Tazio" ,
85+ },
86+ }
87+ }
88+ PerformHttpRequest (DISCORD_WEBHOOK , function (err , text , headers ) end , ' POST' , json .encode ({username = DISCORD_NAME , embeds = connect , avatar_url = DISCORD_IMAGE }), { [' Content-Type' ] = ' application/json' })
7389end
0 commit comments