fix: add verification for api format

This commit is contained in:
Linventif 2024-03-13 21:43:56 +01:00
parent 75001c3ddc
commit c53952f163
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24

View File

@ -1,4 +1,5 @@
function gmInte.getPlayerFormat(ply) function gmInte.getPlayerFormat(ply)
if (!IsValid(ply) || !ply:IsPlayer()) then return end
return { return {
["steamID"] = ply:SteamID(), ["steamID"] = ply:SteamID(),
["steamID64"] = ply:SteamID64(), ["steamID64"] = ply:SteamID64(),
@ -29,6 +30,7 @@ function gmInte.getServerFormat()
end end
function gmInte.getWeaponFormat(weapon) function gmInte.getWeaponFormat(weapon)
if (!IsValid(weapon) || !weapon:IsWeapon()) then return end
return { return {
["class"] = weapon:GetClass(), ["class"] = weapon:GetClass(),
["printName"] = weapon:GetPrintName() ["printName"] = weapon:GetPrintName()
@ -36,6 +38,7 @@ function gmInte.getWeaponFormat(weapon)
end end
function gmInte.getEntityFormat(ent) function gmInte.getEntityFormat(ent)
if (!IsValid(ent)) then return end
return { return {
["class"] = ent:GetClass(), ["class"] = ent:GetClass(),
["model"] = ent:GetModel(), ["model"] = ent:GetModel(),
@ -45,6 +48,7 @@ function gmInte.getEntityFormat(ent)
end end
function gmInte.getVectorFormat(vec) function gmInte.getVectorFormat(vec)
if (!isvector(vec)) then return end
return { return {
["x"] = vec.x, ["x"] = vec.x,
["y"] = vec.y, ["y"] = vec.y,
@ -53,6 +57,7 @@ function gmInte.getVectorFormat(vec)
end end
function gmInte.getAngleFormat(ang) function gmInte.getAngleFormat(ang)
if (!isangle(ang)) then return end
return { return {
["p"] = ang.p, ["p"] = ang.p,
["y"] = ang.y, ["y"] = ang.y,
@ -61,6 +66,7 @@ function gmInte.getAngleFormat(ang)
end end
function gmInte.getTeamFormat(teamID) function gmInte.getTeamFormat(teamID)
if (!isnumber(teamID)) then return end
return { return {
["id"] = teamID, ["id"] = teamID,
["name"] = team.GetName(teamID) ["name"] = team.GetName(teamID)