mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 21:17:34 +00:00
add log bot and add give
This commit is contained in:
parent
0c492a56ca
commit
bfdda46882
|
@ -51,6 +51,18 @@ local possibleConfig = {
|
|||
end,
|
||||
["category"] = "Main"
|
||||
},
|
||||
["logBotActions"] = {
|
||||
["label"] = "Log Bot Actions",
|
||||
["description"] = "Activate or deactivate logs for bot actions.",
|
||||
["type"] = "checkbox",
|
||||
["value"] = function(setting, value)
|
||||
return value
|
||||
end,
|
||||
["onEdit"] = function(setting, value)
|
||||
saveConfig(setting, value == "Enabled" && true || false)
|
||||
end,
|
||||
["category"] = "Main"
|
||||
},
|
||||
["filterOnBan"] = {
|
||||
["label"] = "Block Discord Ban Player",
|
||||
["description"] = "Block players banned on the discord server.",
|
||||
|
|
|
@ -55,12 +55,21 @@ local function logDisable()
|
|||
return !gmInte.config.sendLog
|
||||
end
|
||||
|
||||
local function validLogAndPlayers(players)
|
||||
if (logDisable()) then return false end
|
||||
for _, ply in pairs(players) do
|
||||
if (!IsValid(ply)) then return false end
|
||||
if (!ply:IsBot() && !gmInte.config.logBotActions) then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
//
|
||||
// Posts
|
||||
//
|
||||
|
||||
function gmInte.postLogPlayerSay(ply, text, teamChat)
|
||||
if (logDisable() || ply:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerSay",
|
||||
{
|
||||
|
@ -72,7 +81,7 @@ function gmInte.postLogPlayerSay(ply, text, teamChat)
|
|||
end
|
||||
|
||||
function gmInte.postLogPlayerDeath(ply, inflictor, attacker)
|
||||
if (logDisable() || ply:IsBot() || attacker:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply, attacker})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerDeath",
|
||||
{
|
||||
|
@ -84,7 +93,7 @@ function gmInte.postLogPlayerDeath(ply, inflictor, attacker)
|
|||
end
|
||||
|
||||
function gmInte.postLogPlayerInitialSpawn(ply)
|
||||
if (logDisable() || ply:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerInitialSpawn",
|
||||
{
|
||||
|
@ -94,7 +103,7 @@ function gmInte.postLogPlayerInitialSpawn(ply)
|
|||
end
|
||||
|
||||
function gmInte.postLogPlayerHurt(ply, attacker, healthRemaining, damageTaken)
|
||||
if (logDisable() || ply:IsBot() || attacker:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply, attacker})) then return end
|
||||
|
||||
// Wait a second to see if the player is going to be hurt again
|
||||
ply.gmodInteLastHurt = ply.gmodInteLastHurt || {}
|
||||
|
@ -120,7 +129,7 @@ function gmInte.postLogPlayerHurt(ply, attacker, healthRemaining, damageTaken)
|
|||
end
|
||||
|
||||
function gmInte.postLogPlayerSpawnedSomething(object, ply, ent, model)
|
||||
if (logDisable() || ply:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerSpawnedSomething",
|
||||
{
|
||||
|
@ -133,7 +142,7 @@ function gmInte.postLogPlayerSpawnedSomething(object, ply, ent, model)
|
|||
end
|
||||
|
||||
function gmInte.postLogPlayerSpawn(ply)
|
||||
if (logDisable() || ply:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerSpawn",
|
||||
{
|
||||
|
@ -143,7 +152,7 @@ function gmInte.postLogPlayerSpawn(ply)
|
|||
end
|
||||
|
||||
function gmInte.postLogPlayerDisconnect(ply)
|
||||
if (logDisable() || ply:IsBot()) then return end
|
||||
if (!validLogAndPlayers({ply})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerDisconnect",
|
||||
{
|
||||
|
@ -165,6 +174,18 @@ function gmInte.postLogPlayerConnect(data)
|
|||
)
|
||||
end
|
||||
|
||||
function gmInte.postLogPlayerGivet(ply, class, swep)
|
||||
if (!validLogAndPlayers({ply})) then return end
|
||||
|
||||
gmInte.post("/server/log/playerGive",
|
||||
{
|
||||
["ply"] = logFormatPlayer(ply),
|
||||
["class"] = class,
|
||||
["swep"] = swep
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
//
|
||||
// Hooks
|
||||
//
|
||||
|
@ -184,6 +205,9 @@ end)
|
|||
hook.Add("PlayerDisconnected", "gmInte:Log:PlayerDisconnected", function(ply)
|
||||
gmInte.postLogPlayerDisconnect(ply)
|
||||
end)
|
||||
hook.Add("PlayerGiveSWEP", "gmInte:Log:PlayerSWEPs", function( ply, class, swep )
|
||||
gmInte.postLogPlayerGivet(ply, class, swep)
|
||||
end)
|
||||
|
||||
// Sandbox - Server Events
|
||||
hook.Add("player_connect", "gmInte:Log:PlayerConnect", function(data)
|
||||
|
|
|
@ -65,6 +65,7 @@ gmInte.config.chatTrigger = {
|
|||
gmInte.config.forcePlayerLink = false // If true, the addon will force the players to link their discord account to their steam account before playing
|
||||
gmInte.config.supportLink = "" // The link of your support (shown when a player do not have the requiments to join the server)
|
||||
gmInte.config.debug = false // If true, the addon will show debug informations in the console
|
||||
gmInte.config.logBotActions = false // If true, the addon will log the messages of the bot in the console
|
||||
|
||||
//
|
||||
// Syncronization
|
||||
|
|
Loading…
Reference in New Issue
Block a user