mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
edit format
This commit is contained in:
parent
b20e453e7e
commit
e72fbef924
1
lua/gmod_integration/client/cl__api_format.lua
Normal file
1
lua/gmod_integration/client/cl__api_format.lua
Normal file
|
@ -0,0 +1 @@
|
|||
//
|
|
@ -1,4 +1,4 @@
|
|||
function gmInte.playerFormat(ply)
|
||||
function gmInte.getPlayerFormat(ply)
|
||||
return {
|
||||
["steamID"] = ply:SteamID(),
|
||||
["steamID64"] = ply:SteamID64(),
|
||||
|
@ -11,4 +11,56 @@ function gmInte.playerFormat(ply)
|
|||
["customValues"] = ply:gmIntGetCustomValues(),
|
||||
["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
|
|
@ -2,45 +2,6 @@
|
|||
// 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()
|
||||
return !gmInte.config.sendLog
|
||||
end
|
||||
|
@ -65,7 +26,7 @@ function gmInte.postLogPlayerSay(ply, text, teamChat)
|
|||
|
||||
gmInte.http.post("/logs/playerSay",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply),
|
||||
["ply"] = gmInte.getPlayerFormat(ply),
|
||||
["text"] = text,
|
||||
["teamChat"] = teamChat
|
||||
}
|
||||
|
@ -77,9 +38,9 @@ function gmInte.postLogPlayerDeath(ply, inflictor, attacker)
|
|||
|
||||
gmInte.http.post("/logs/playerDeath",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply),
|
||||
["inflictor"] = logFormatEntity(inflictor),
|
||||
["attacker"] = gmInte.playerFormat(attacker)
|
||||
["ply"] = gmInte.getPlayerFormat(ply),
|
||||
["inflictor"] = gmInte.getEntityFormat(inflictor),
|
||||
["attacker"] = gmInte.getPlayerFormat(attacker)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
@ -89,7 +50,7 @@ function gmInte.postLogPlayerInitialSpawn(ply)
|
|||
|
||||
gmInte.http.post("/logs/playerInitialSpawn",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply)
|
||||
["ply"] = gmInte.getPlayerFormat(ply)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
@ -111,8 +72,8 @@ function gmInte.postLogPlayerHurt(ply, attacker, healthRemaining, damageTaken)
|
|||
|
||||
gmInte.http.post("/logs/playerHurt",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply),
|
||||
["attacker"] = gmInte.playerFormat(attacker),
|
||||
["ply"] = gmInte.getPlayerFormat(ply),
|
||||
["attacker"] = gmInte.getPlayerFormat(attacker),
|
||||
["healthRemaining"] = healthRemaining,
|
||||
["damageTaken"] = ply.gmodInteTotalDamage
|
||||
}
|
||||
|
@ -126,8 +87,8 @@ function gmInte.postLogPlayerSpawnedSomething(object, ply, ent, model)
|
|||
gmInte.http.post("/logs/playerSpawnedSomething",
|
||||
{
|
||||
["object"] = object,
|
||||
["ply"] = gmInte.playerFormat(ply),
|
||||
["ent"] = logFormatEntity(ent),
|
||||
["ply"] = gmInte.getPlayerFormat(ply),
|
||||
["ent"] = gmInte.getEntityFormat(ent),
|
||||
["model"] = model || ""
|
||||
}
|
||||
)
|
||||
|
@ -138,7 +99,7 @@ function gmInte.postLogPlayerSpawn(ply)
|
|||
|
||||
gmInte.http.post("/logs/playerSpawn",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply)
|
||||
["ply"] = gmInte.getPlayerFormat(ply)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
@ -148,7 +109,7 @@ function gmInte.postLogPlayerDisconnect(ply)
|
|||
|
||||
gmInte.http.post("/logs/playerDisconnect",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply)
|
||||
["ply"] = gmInte.getPlayerFormat(ply)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
@ -171,7 +132,7 @@ function gmInte.postLogPlayerGivet(ply, class, swep)
|
|||
|
||||
gmInte.http.post("/logs/playerGive",
|
||||
{
|
||||
["ply"] = gmInte.playerFormat(ply),
|
||||
["ply"] = gmInte.getPlayerFormat(ply),
|
||||
["class"] = class,
|
||||
["swep"] = swep
|
||||
}
|
||||
|
|
|
@ -123,11 +123,7 @@ function gmInte.userFinishConnect(ply)
|
|||
// Send Public Config
|
||||
gmInte.publicGetConfig(ply)
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/finish-connect",
|
||||
{
|
||||
["player"] = gmInte.playerFormat(ply),
|
||||
}
|
||||
)
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/finish-connect", gmInte.getPlayerFormat(ply))
|
||||
|
||||
if (!gmInte.config.forcePlayerLink) then return end
|
||||
gmInte.verifyPlayer(ply)
|
||||
|
@ -138,7 +134,7 @@ function gmInte.playerDisconnected(ply)
|
|||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/disconnect",
|
||||
{
|
||||
["player"] = gmInte.playerFormat(ply),
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
}
|
||||
)
|
||||
end
|
||||
|
|
|
@ -2,25 +2,12 @@
|
|||
// 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()
|
||||
gmInte.http.post("/status", getServerFormat())
|
||||
gmInte.http.post("/status", gmInte.getServerFormat())
|
||||
end
|
||||
|
||||
-- function gmInte.serverStart()
|
||||
-- gmInte.http.post("/start", getServerFormat())
|
||||
-- gmInte.http.post("/start", gmInte.getServerFormat())
|
||||
-- end
|
||||
|
||||
function gmInte.serverShutDown()
|
||||
|
|
|
@ -15,7 +15,7 @@ function gmInte.playerSay(ply, text, team)
|
|||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/say",
|
||||
{
|
||||
["player"] = gmInte.playerFormat(ply),
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["text"] = text,
|
||||
["team"] = team,
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ function gmInte.playerChangeName(ply, oldName, newName)
|
|||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/name",
|
||||
{
|
||||
["player"] = gmInte.playerFormat(ply),
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["oldName"] = oldName,
|
||||
["newName"] = newName,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user