mirror of
https://github.com/gmod-integration/lua.git
synced 2025-04-29 22:55:25 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
d6a378ec45 | |||
91e8b3d2ef | |||
499c382066 | |||
da9b9d2392 | |||
be3a44760d | |||
3ebd9c0989 |
|
@ -1,6 +1,6 @@
|
|||
if game.SinglePlayer() then return print("Gmod Integration is not supported in Singleplayer!") end
|
||||
gmInte = gmInte || {}
|
||||
gmInte.version = "0.4.8"
|
||||
gmInte.version = "0.4.9"
|
||||
gmInte.config = {}
|
||||
gmInte.materials = {}
|
||||
local function loadServerConfig()
|
||||
|
|
49
lua/gmod_integration/server/compatibility/chatm/sv_atm.lua
Normal file
49
lua/gmod_integration/server/compatibility/chatm/sv_atm.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
function gmInte.postCHATMTakeMoney(ply, amount, reason)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/ch-atm/take-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["amount"] = math.Round(amount),
|
||||
["reason"] = reason
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.postCHATMReceiveMoney(ply, amount, reason)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/ch-atm/receive-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["amount"] = math.Round(amount),
|
||||
["reason"] = reason
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.postCHATMSendMoney(ply, amount, plyReceiver)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
if !plyReceiver:IsValid() || !plyReceiver:IsPlayer(plyReceiver) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/ch-atm/send-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["receiver"] = gmInte.getPlayerFormat(plyReceiver),
|
||||
["amount"] = math.Round(amount)
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.postCHATMWithdrawMoney(ply, amount)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/ch-atm/withdraw-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["amount"] = math.Round(amount)
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.postCHATMDepositMoney(ply, amount)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/ch-atm/deposit-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["amount"] = math.Round(amount)
|
||||
})
|
||||
end
|
||||
|
||||
hook.Add("CH_ATM_bLogs_TakeMoney", "gmInte:Player:CH:ATM:TakeMoney", function(amount, ply, reason) gmInte.postCHATMTakeMoney(ply, amount, reason) end)
|
||||
hook.Add("CH_ATM_bLogs_ReceiveMoney", "gmInte:Player:CH:ATM:ReceiveMoney", function(amount, ply, reason) gmInte.postCHATMReceiveMoney(ply, amount, reason) end)
|
||||
hook.Add("CH_ATM_bLogs_SendMoney", "gmInte:Player:CH:ATM:SendMoney", function(ply, amount, plyReceiver) gmInte.postCHATMSendMoney(ply, amount, plyReceiver) end)
|
||||
hook.Add("CH_ATM_bLogs_WithdrawMoney", "gmInte:Player:CH:ATM:WithdrawMoney", function(ply, amount) gmInte.postCHATMWithdrawMoney(ply, amount) end)
|
||||
hook.Add("CH_ATM_bLogs_DepositMoney", "gmInte:Player:CH:ATM:DepositMoney", function(ply, amount) gmInte.postCHATMDepositMoney(ply, amount) end)
|
|
@ -0,0 +1,35 @@
|
|||
function gmInte.postDarkRPDroppedMoney(ply, amount, entity)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/dark-rp/drop-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["amount"] = math.Round(amount),
|
||||
["entity"] = gmInte.getEntityFormat(entity),
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.postDarkRPPickedUpMoney(ply, price, entity)
|
||||
if !ply:IsValid() || !ply:IsPlayer(ply) then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/dark-rp/picked-up-money", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["amount"] = math.Round(price),
|
||||
["entity"] = gmInte.getEntityFormat(entity),
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.postDarkRPPickedUpCheque(plyWriter, plyTarget, price, sucess, entity)
|
||||
if !plyWriter:IsValid() || !plyWriter:IsPlayer() then return end
|
||||
if !plyTarget:IsValid() || !plyTarget:IsPlayer() then return end
|
||||
if ply != plyTo then return end
|
||||
gmInte.http.postLog("/servers/:serverID/players/" .. ply:SteamID64() .. "/dark-rp/picked-up-cheque", {
|
||||
["playerChequeWriter"] = gmInte.getPlayerFormat(plyWriter),
|
||||
["playerChequeTarget"] = gmInte.getPlayerFormat(plyTarget),
|
||||
["amount"] = math.Round(price),
|
||||
["entity"] = gmInte.getEntityFormat(entity),
|
||||
})
|
||||
end
|
||||
|
||||
if DarkRP then
|
||||
hook.Add("playerDroppedMoney", "gmInte:Player:DarkRPDroppedMoney", function(ply, amount, entity) gmInte.postDarkRPDroppedMoney(ply, amount, entity) end)
|
||||
hook.Add("playerPickedUpMoney", "gmInte:Player:DarkRPPickedUpMoney", function(ply, price, entity) gmInte.postDarkRPPickedUpMoney(ply, price, entity) end)
|
||||
hook.Add("playerDroppedCheque", "gmInte:Player:DarkRPPickedUpCheque", function(plyWriter, plyTarget, price, sucess, entity) gmInte.postDarkRPPickedUpCheque(plyWriter, plyTarget, price, sucess, entity) end)
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
local conFuncs = {
|
||||
["version"] = function() gmInte.log("Version: " .. gmInte.version) end,
|
||||
["setting"] = function(args) gmInte.saveSetting(args[2], args[3]) end,
|
||||
["version"] = function() print("Version: " .. gmInte.version) end,
|
||||
["set-setting"] = function(args) gmInte.saveSetting(args[2], args[3]) end,
|
||||
["show-settings"] = function() PrintTable(gmInte.config) end,
|
||||
["try"] = function() gmInte.tryConfig() end,
|
||||
["refresh"] = function() gmInte.refreshSettings() end,
|
||||
["get-server-id"] = function() print(gmInte.config.id || "none") end,
|
||||
|
@ -12,7 +13,14 @@ local function cmdExecuted(ply, cmd, args)
|
|||
if conFuncs[args[1]] then
|
||||
conFuncs[args[1]](args)
|
||||
else
|
||||
gmInte.log("Unknown Command Argument")
|
||||
print("Unknown Command, available commands are:")
|
||||
print("version")
|
||||
print("set-setting <setting> <value>")
|
||||
print("show-settings")
|
||||
print("try")
|
||||
print("refresh")
|
||||
print("get-server-id")
|
||||
print("export-warns")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ end
|
|||
|
||||
local netReceive = {
|
||||
[0] = function(ply, data)
|
||||
if ply.gmIntIsReady then return end
|
||||
ply.branch = data.branch
|
||||
hook.Run("gmInte:PlayerReady", ply)
|
||||
end,
|
||||
|
|
|
@ -97,14 +97,16 @@ function gmInte.postLogPlayerGive(ply, class, swep)
|
|||
})
|
||||
end
|
||||
|
||||
hook.Add("gmInte:PlayerReady", "gmInte:Player:Ready", function(ply) gmInte.playerReady(ply) end)
|
||||
hook.Add("ShutDown", "gmInte:Server:Shutdown:SavePlayers", function()
|
||||
local function savePlyDisconnect()
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
gmInte.playerDisconnected(ply)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
gameevent.Listen("player_connect")
|
||||
hook.Add("ShutDown", "gmInte:Server:Shutdown:SavePlayers", savePlyDisconnect)
|
||||
hook.Add("GMI:SaveBeforeCrash", "gmInte:Server:BeforeCrash:SavePlayers", savePlyDisconnect)
|
||||
hook.Add("gmInte:PlayerReady", "gmInte:Player:Ready", function(ply) gmInte.playerReady(ply) end)
|
||||
hook.Add("player_connect", "gmInte:Player:Connect", function(data) gmInte.playerConnect(data) end)
|
||||
hook.Add("PlayerDisconnected", "gmInte:Player:Disconnect", function(ply) gmInte.playerDisconnected(ply) end)
|
||||
hook.Add("PlayerSpawn", "gmInte:Player:Spawn", function(ply) gmInte.playerSpawn(ply) end)
|
||||
|
@ -112,11 +114,14 @@ hook.Add("PlayerInitialSpawn", "gmInte:Player:InitialSpawn", function(ply) gmInt
|
|||
hook.Add("PlayerGiveSWEP", "gmInte:Player:SWEPs", function(ply, class, swep) gmInte.postLogPlayerGive(ply, class, swep) end)
|
||||
hook.Add("PlayerDeath", "gmInte:Player:Death", function(ply, inflictor, attacker) gmInte.playerDeath(ply, inflictor, attacker) end)
|
||||
hook.Add("PlayerHurt", "gmInte:Player:Hurt", function(ply, attacker, healthRemaining, damageTaken) gmInte.postLogPlayerHurt(ply, attacker, healthRemaining, damageTaken) end)
|
||||
hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam", function(ply, oldTeam, newTeam) gmInte.playerChangedTeam(ply, oldTeam, newTeam) end)
|
||||
hook.Add("PlayerSpawnedProp", "gmInte:Player:SpawnedProp", function(ply, model, ent) gmInte.postLogPlayerSpawnedSomething("prop", ply, ent, model) end)
|
||||
hook.Add("PlayerSpawnedSENT", "gmInte:Player:SpawnedSENT", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("sent", ply, ent) end)
|
||||
hook.Add("PlayerSpawnedNPC", "gmInte:Player:SpawnedNPC", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("npc", ply, ent) end)
|
||||
hook.Add("PlayerSpawnedVehicle", "gmInte:Player:SpawnedVehicle", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("vehicle", ply, ent) end)
|
||||
hook.Add("PlayerSpawnedEffect", "gmInte:Player:SpawnedEffect", function(ply, model, ent) gmInte.postLogPlayerSpawnedSomething("effect", ply, ent, model) end)
|
||||
hook.Add("PlayerSpawnedRagdoll", "gmInte:Player:SpawnedRagdoll", function(ply, model, ent) gmInte.postLogPlayerSpawnedSomething("ragdoll", ply, ent, model) end)
|
||||
hook.Add("PlayerSpawnedSWEP", "gmInte:Player:SpawnedSWEP", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("swep", ply, ent) end)
|
||||
hook.Add("PlayerSpawnedSWEP", "gmInte:Player:SpawnedSWEP", function(ply, ent) gmInte.postLogPlayerSpawnedSomething("swep", ply, ent) end)
|
||||
hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam", function(ply, oldTeam, newTeam)
|
||||
gmInte.playerChangedTeam(ply, oldTeam, newTeam)
|
||||
ply:gmInteResetTimeLastTeamChange()
|
||||
end)
|
|
@ -108,6 +108,7 @@ local function flushLogs()
|
|||
end
|
||||
|
||||
hook.Add("ShutDown", "gmInte:Server:ShutDown:FlushLogs", flushLogs)
|
||||
hook.Add("GMI:SaveBeforeCrash", "gmInte:Server:BeforeCrash:SavePlayers", flushLogs)
|
||||
timer.Create("gmInte:http:flushLogs", 3, 0, flushLogs)
|
||||
function gmInte.http.postLog(endpoint, data)
|
||||
table.insert(nextLogPacket, {
|
||||
|
|
|
@ -11,6 +11,10 @@ function ply:gmIntGetTimeLastTeamChange()
|
|||
return self.gmIntTimeLastTeamChange || RealTime()
|
||||
end
|
||||
|
||||
function ply:gmInteResetTimeLastTeamChange()
|
||||
self.gmIntTimeLastTeamChange = RealTime()
|
||||
end
|
||||
|
||||
function ply:gmInteGetBranch()
|
||||
return CLIENT && BRANCH || self.branch || "unknown"
|
||||
end
|
||||
|
@ -51,6 +55,8 @@ local function getCustomCompatability(ply)
|
|||
values.ps2Points = ply.PS2_Wallet.points
|
||||
values.ps2PremiumPoints = ply.PS2_Wallet.premiumPoints
|
||||
end
|
||||
|
||||
if CH_ATM && SERVER then values.bank = CH_ATM.GetMoneyBankAccount(ply) end
|
||||
return values
|
||||
end
|
||||
|
||||
|
@ -125,7 +131,7 @@ if SERVER then
|
|||
end)
|
||||
end
|
||||
|
||||
hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", function()
|
||||
local function saveTimeToLocal()
|
||||
local dataToSave = {
|
||||
["version"] = "1.0",
|
||||
["serverID"] = gmInte.config.id,
|
||||
|
@ -147,7 +153,7 @@ hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", function()
|
|||
oldData[gmInte.config.id] = dataToSave
|
||||
file.Write("gmod_integration/player_before_map_change.json", util.TableToJSON(oldData, true))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
// on team change reset the time
|
||||
hook.Add("PlayerChangedTeam", "gmInte:Player:ChangedTeam:ResetTime", function(ply) ply.gmIntTimeLastTeamChange = RealTime() end)
|
||||
hook.Add("ShutDown", "gmInte:Server:ShutDown:SavePlayer", saveTimeToLocal)
|
||||
hook.Add("GMI:SaveBeforeCrash", "gmInte:Server:BeforeCrash:SavePlayers", saveTimeToLocal)
|
Loading…
Reference in New Issue
Block a user