forked from NebulousCloud/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.lua
228 lines (177 loc) · 6.98 KB
/
logging.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
PLUGIN.name = "Logging"
PLUGIN.author = "Black Tea"
PLUGIN.description = "You can modfiy the logging text/lists on this plugin."
if (SERVER) then
local L = Format
ix.log.AddType("chat", function(client, ...)
local arg = {...}
return L("[%s] %s: %s", arg[1], client:Name(), arg[2])
end)
ix.log.AddType("command", function(client, ...)
local arg = {...}
if (arg[2] and #arg[2] > 0) then
return L("%s used command '%s %s'.", client:Name(), arg[1], arg[2])
else
return L("%s used command '%s'.", client:Name(), arg[1])
end
end)
ix.log.AddType("cfgSet", function(client, ...)
local arg = {...}
return L("%s set %s to '%s'.", client:Name(), arg[1], arg[2])
end, FLAG_DANGER)
ix.log.AddType("connect", function(client, ...)
return L("%s has connected.", client:SteamName())
end, FLAG_NORMAL)
ix.log.AddType("disconnect", function(client, ...)
if (client:IsTimingOut()) then
return L("%s (%s) has disconnected (timed out).", client:SteamName(), client:SteamID())
else
return L("%s (%s) has disconnected.", client:SteamName(), client:SteamID())
end
end, FLAG_NORMAL)
ix.log.AddType("charCreate", function(client, ...)
local arg = {...}
return L("%s created the character '%s'", client:SteamName(), arg[1])
end, FLAG_SERVER)
ix.log.AddType("charLoad", function(client, ...)
local arg = {...}
return L("%s loaded the character '%s'", client:SteamName(), arg[1])
end, FLAG_SERVER)
ix.log.AddType("charDelete", function(client, ...)
local arg = {...}
return L("%s (%s) deleted character '%s'", client:SteamName(), client:SteamID(), arg[1])
end, FLAG_SERVER)
ix.log.AddType("itemAction", function(client, ...)
local arg = {...}
local item = arg[2]
return L("%s ran '%s' on item '%s' (#%s)", client:Name(), arg[1], item:GetName(), item:GetID())
end, FLAG_NORMAL)
ix.log.AddType("itemDestroy", function(client, itemName, itemID)
local name = client:GetName() ~= "" and client:GetName() or client:GetClass()
return L("%s destroyed a '%s' #%d.", name, itemName, itemID)
end, FLAG_WARNING)
ix.log.AddType("shipmentTake", function(client, ...)
local arg = {...}
return L("%s took '%s' from the shipment", client:Name(), arg[1])
end, FLAG_WARNING)
ix.log.AddType("shipmentOrder", function(client, ...)
return L("%s ordered a shipment", client:Name())
end, FLAG_SUCCESS)
ix.log.AddType("buy", function(client, ...)
local arg = {...}
return L("%s purchased '%s' from the NPC", client:Name(), arg[1])
end, FLAG_SUCCESS)
ix.log.AddType("buydoor", function(client, ...)
return L("%s has purchased a door.", client:Name())
end, FLAG_SUCCESS)
ix.log.AddType("selldoor", function(client, ...)
return L("%s has sold a door.", client:Name())
end, FLAG_SUCCESS)
ix.log.AddType("playerHurt", function(client, ...)
local arg = {...}
return L("%s has taken %d damage from %s.", client:Name(), arg[1], arg[2])
end, FLAG_WARNING)
ix.log.AddType("playerDeath", function(client, ...)
local arg = {...}
return L("%s has killed %s%s.", arg[1], client:Name(), arg[2] and (" with " .. arg[2]) or "")
end, FLAG_DANGER)
ix.log.AddType("money", function(client, amount)
return L("%s has %s %s.", client:Name(), amount < 0 and "lost" or "gained", ix.currency.Get(math.abs(amount)))
end, FLAG_SUCCESS)
ix.log.AddType("inventoryAdd", function(client, characterName, itemName, itemID)
return L("%s has gained a '%s' #%d.", characterName, itemName, itemID)
end, FLAG_WARNING)
ix.log.AddType("inventoryRemove", function(client, characterName, itemName, itemID)
return L("%s has lost a '%s' #%d.", characterName, itemName, itemID)
end, FLAG_WARNING)
ix.log.AddType("storageMoneyTake", function(client, entity, amount, total)
local name = entity.GetDisplayName and entity:GetDisplayName() or entity:GetName()
return string.format("%s has taken %d %s from '%s' #%d (%d %s left).",
client:GetName(), amount, ix.currency.plural, name,
entity:GetInventory():GetID(), total, ix.currency.plural)
end)
ix.log.AddType("storageMoneyGive", function(client, entity, amount, total)
local name = entity.GetDisplayName and entity:GetDisplayName() or entity:GetName()
return string.format("%s has given %d %s to '%s' #%d (%d %s left).",
client:GetName(), amount, ix.currency.plural, name,
entity:GetInventory():GetID(), total, ix.currency.plural)
end)
ix.log.AddType("roll", function(client, value, max)
return string.format("%s rolled %d out of %d.", client:Name(), value, max)
end)
ix.log.AddType("pluginLoaded", function(client, uniqueID)
return string.format("%s has enabled the %s plugin for next restart.", client:GetName(), uniqueID)
end)
ix.log.AddType("pluginUnloaded", function(client, uniqueID)
return string.format("%s has disabled the %s plugin for next restart.", client:GetName(), uniqueID)
end)
function PLUGIN:PlayerInitialSpawn(client)
ix.log.Add(client, "connect")
end
function PLUGIN:PlayerDisconnected(client)
ix.log.Add(client, "disconnect")
end
function PLUGIN:OnCharacterCreated(client, character)
ix.log.Add(client, "charCreate", character:GetName())
end
function PLUGIN:CharacterLoaded(character)
local client = character:GetPlayer()
ix.log.Add(client, "charLoad", character:GetName())
end
function PLUGIN:PreCharacterDeleted(client, character)
ix.log.Add(client, "charDelete", character:GetName())
end
function PLUGIN:ShipmentItemTaken(client, itemClass, amount)
local itemTable = ix.item.list[itemClass]
ix.log.Add(client, "shipmentTake", itemTable:GetName())
end
function PLUGIN:CreateShipment(client, shipmentEntity)
ix.log.Add(client, "shipmentOrder")
end
function PLUGIN:CharacterVendorTraded(client, vendor, x, y, invID, price, isSell)
end
function PLUGIN:PlayerInteractItem(client, action, item)
if (isentity(item)) then
if (IsValid(item)) then
local itemID = item.ixItemID
item = ix.item.instances[itemID]
else
return
end
elseif (isnumber(item)) then
item = ix.item.instances[item]
end
if (!item) then
return
end
ix.log.Add(client, "itemAction", action, item)
end
function PLUGIN:InventoryItemAdded(oldInv, inventory, item)
if (!inventory.owner or (oldInv and oldInv.owner == inventory.owner)) then
return
end
local character = ix.char.loaded[inventory.owner]
ix.log.Add(character:GetPlayer(), "inventoryAdd", character:GetName(), item:GetName(), item:GetID())
if (item.isBag) then
local bagInventory = item:GetInventory()
if (!bagInventory) then
return
end
for k, _ in bagInventory:Iter() do
ix.log.Add(character:GetPlayer(), "inventoryAdd", character:GetName(), k:GetName(), k:GetID())
end
end
end
function PLUGIN:InventoryItemRemoved(inventory, item)
if (!inventory.owner) then
return
end
local character = ix.char.loaded[inventory.owner]
ix.log.Add(character:GetPlayer(), "inventoryRemove", character:GetName(), item:GetName(), item:GetID())
if (item.isBag) then
for k, _ in item:GetInventory():Iter() do
ix.log.Add(character:GetPlayer(), "inventoryRemove", character:GetName(), k:GetName(), k:GetID())
end
end
end
end