edit format

This commit is contained in:
Linventif 2024-02-11 23:23:05 +01:00
parent b20e453e7e
commit e72fbef924
7 changed files with 72 additions and 75 deletions

View File

@ -0,0 +1 @@
//

View File

@ -1,4 +1,4 @@
function gmInte.playerFormat(ply) function gmInte.getPlayerFormat(ply)
return { return {
["steamID"] = ply:SteamID(), ["steamID"] = ply:SteamID(),
["steamID64"] = ply:SteamID64(), ["steamID64"] = ply:SteamID64(),
@ -11,4 +11,56 @@ function gmInte.playerFormat(ply)
["customValues"] = ply:gmIntGetCustomValues(), ["customValues"] = ply:gmIntGetCustomValues(),
["connectTime"] = math.Round(RealTime() - ply:gmIntGetConnectTime()), ["connectTime"] = math.Round(RealTime() - ply:gmIntGetConnectTime()),
} }
end
function gmInte.getServerFormat()
return {
["hostname"] = GetHostName(),
["ip"] = game.GetIPAddress(),
["port"] = GetConVar("hostport"):GetInt(),
["map"] = game.GetMap(),
["players"] = #player.GetAll(),
["maxPlayers"] = game.MaxPlayers(),
["gameMode"] = engine.ActiveGamemode(),
["uptime"] = math.Round(RealTime() / 60)
}
end
function gmInte.getWeaponFormat(weapon)
return {
["class"] = weapon:GetClass(),
["printName"] = weapon:GetPrintName()
}
end
function gmInte.getEntityFormat(ent)
return {
["class"] = ent:GetClass(),
["model"] = ent:GetModel(),
["pos"] = gmInte.getVectorFormat(ent:GetPos()),
["ang"] = gmInte.getAngleFormat(ent:GetAngles())
}
end
function gmInte.getVectorFormat(vec)
return {
["x"] = vec.x,
["y"] = vec.y,
["z"] = vec.z
}
end
function gmInte.getAngleFormat(ang)
return {
["p"] = ang.p,
["y"] = ang.y,
["r"] = ang.r
}
end
local function gmInte.getTeamFormat(teamID)
return {
["id"] = teamID,
["name"] = team.GetName(teamID)
}
end end

View File

@ -2,45 +2,6 @@
// Functions // Functions
// //
local function logFormatWeapon(weapon, data)
data = data or {}
data.class = weapon:GetClass()
data.printName = weapon:GetPrintName()
return data
end
local function logFormatEntity(ent, data)
data = data or {}
data.class = ent:GetClass()
data.model = ent:GetModel()
data.pos = ent:GetPos()
data.ang = ent:GetAngles()
return data
end
local function logFormatVector(vec, data)
data = data or {}
data.x = vec.x
data.y = vec.y
data.z = vec.z
return data
end
local function logFormatAngle(ang, data)
data = data or {}
data.p = ang.p
data.y = ang.y
data.r = ang.r
return data
end
local function logFormatTeam(teamID, data)
data = data or {}
data.id = teamID
data.name = team.GetName(teamID)
return data
end
local function logDisable() local function logDisable()
return !gmInte.config.sendLog return !gmInte.config.sendLog
end end
@ -65,7 +26,7 @@ function gmInte.postLogPlayerSay(ply, text, teamChat)
gmInte.http.post("/logs/playerSay", gmInte.http.post("/logs/playerSay",
{ {
["ply"] = gmInte.playerFormat(ply), ["ply"] = gmInte.getPlayerFormat(ply),
["text"] = text, ["text"] = text,
["teamChat"] = teamChat ["teamChat"] = teamChat
} }
@ -77,9 +38,9 @@ function gmInte.postLogPlayerDeath(ply, inflictor, attacker)
gmInte.http.post("/logs/playerDeath", gmInte.http.post("/logs/playerDeath",
{ {
["ply"] = gmInte.playerFormat(ply), ["ply"] = gmInte.getPlayerFormat(ply),
["inflictor"] = logFormatEntity(inflictor), ["inflictor"] = gmInte.getEntityFormat(inflictor),
["attacker"] = gmInte.playerFormat(attacker) ["attacker"] = gmInte.getPlayerFormat(attacker)
} }
) )
end end
@ -89,7 +50,7 @@ function gmInte.postLogPlayerInitialSpawn(ply)
gmInte.http.post("/logs/playerInitialSpawn", gmInte.http.post("/logs/playerInitialSpawn",
{ {
["ply"] = gmInte.playerFormat(ply) ["ply"] = gmInte.getPlayerFormat(ply)
} }
) )
end end
@ -111,8 +72,8 @@ function gmInte.postLogPlayerHurt(ply, attacker, healthRemaining, damageTaken)
gmInte.http.post("/logs/playerHurt", gmInte.http.post("/logs/playerHurt",
{ {
["ply"] = gmInte.playerFormat(ply), ["ply"] = gmInte.getPlayerFormat(ply),
["attacker"] = gmInte.playerFormat(attacker), ["attacker"] = gmInte.getPlayerFormat(attacker),
["healthRemaining"] = healthRemaining, ["healthRemaining"] = healthRemaining,
["damageTaken"] = ply.gmodInteTotalDamage ["damageTaken"] = ply.gmodInteTotalDamage
} }
@ -126,8 +87,8 @@ function gmInte.postLogPlayerSpawnedSomething(object, ply, ent, model)
gmInte.http.post("/logs/playerSpawnedSomething", gmInte.http.post("/logs/playerSpawnedSomething",
{ {
["object"] = object, ["object"] = object,
["ply"] = gmInte.playerFormat(ply), ["ply"] = gmInte.getPlayerFormat(ply),
["ent"] = logFormatEntity(ent), ["ent"] = gmInte.getEntityFormat(ent),
["model"] = model || "" ["model"] = model || ""
} }
) )
@ -138,7 +99,7 @@ function gmInte.postLogPlayerSpawn(ply)
gmInte.http.post("/logs/playerSpawn", gmInte.http.post("/logs/playerSpawn",
{ {
["ply"] = gmInte.playerFormat(ply) ["ply"] = gmInte.getPlayerFormat(ply)
} }
) )
end end
@ -148,7 +109,7 @@ function gmInte.postLogPlayerDisconnect(ply)
gmInte.http.post("/logs/playerDisconnect", gmInte.http.post("/logs/playerDisconnect",
{ {
["ply"] = gmInte.playerFormat(ply) ["ply"] = gmInte.getPlayerFormat(ply)
} }
) )
end end
@ -171,7 +132,7 @@ function gmInte.postLogPlayerGivet(ply, class, swep)
gmInte.http.post("/logs/playerGive", gmInte.http.post("/logs/playerGive",
{ {
["ply"] = gmInte.playerFormat(ply), ["ply"] = gmInte.getPlayerFormat(ply),
["class"] = class, ["class"] = class,
["swep"] = swep ["swep"] = swep
} }

View File

@ -123,11 +123,7 @@ function gmInte.userFinishConnect(ply)
// Send Public Config // Send Public Config
gmInte.publicGetConfig(ply) gmInte.publicGetConfig(ply)
gmInte.http.post("/players/" .. ply:SteamID64() .. "/finish-connect", gmInte.http.post("/players/" .. ply:SteamID64() .. "/finish-connect", gmInte.getPlayerFormat(ply))
{
["player"] = gmInte.playerFormat(ply),
}
)
if (!gmInte.config.forcePlayerLink) then return end if (!gmInte.config.forcePlayerLink) then return end
gmInte.verifyPlayer(ply) gmInte.verifyPlayer(ply)
@ -138,7 +134,7 @@ function gmInte.playerDisconnected(ply)
gmInte.http.post("/players/" .. ply:SteamID64() .. "/disconnect", gmInte.http.post("/players/" .. ply:SteamID64() .. "/disconnect",
{ {
["player"] = gmInte.playerFormat(ply), ["player"] = gmInte.getPlayerFormat(ply),
} }
) )
end end

View File

@ -2,25 +2,12 @@
// Methods // Methods
// //
local function getServerFormat()
return {
["hostname"] = GetHostName(),
["ip"] = game.GetIPAddress(),
["port"] = GetConVar("hostport"):GetInt(),
["map"] = game.GetMap(),
["players"] = #player.GetAll(),
["maxplayers"] = game.MaxPlayers(),
["gamemode"] = engine.ActiveGamemode(),
["uptime"] = math.Round(RealTime() / 60)
}
end
function gmInte.sendStatus() function gmInte.sendStatus()
gmInte.http.post("/status", getServerFormat()) gmInte.http.post("/status", gmInte.getServerFormat())
end end
-- function gmInte.serverStart() -- function gmInte.serverStart()
-- gmInte.http.post("/start", getServerFormat()) -- gmInte.http.post("/start", gmInte.getServerFormat())
-- end -- end
function gmInte.serverShutDown() function gmInte.serverShutDown()

View File

@ -15,7 +15,7 @@ function gmInte.playerSay(ply, text, team)
gmInte.http.post("/players/" .. ply:SteamID64() .. "/say", gmInte.http.post("/players/" .. ply:SteamID64() .. "/say",
{ {
["player"] = gmInte.playerFormat(ply), ["player"] = gmInte.getPlayerFormat(ply),
["text"] = text, ["text"] = text,
["team"] = team, ["team"] = team,
} }

View File

@ -17,7 +17,7 @@ function gmInte.playerChangeName(ply, oldName, newName)
gmInte.http.post("/players/" .. ply:SteamID64() .. "/name", gmInte.http.post("/players/" .. ply:SteamID64() .. "/name",
{ {
["player"] = gmInte.playerFormat(ply), ["player"] = gmInte.getPlayerFormat(ply),
["oldName"] = oldName, ["oldName"] = oldName,
["newName"] = newName, ["newName"] = newName,
} }