Skip to content

Commit

Permalink
Make business buy net message more type strict
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgrist committed Mar 7, 2021
1 parent 381afd4 commit 81e100d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion gamemode/core/derma/cl_business.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,13 @@ function PANEL:Init()
end

net.Start("ixBusinessBuy")
net.WriteTable(self.itemData)
net.WriteUInt(table.Count(self.itemData), 8)

for k, v in pairs(self.itemData) do
net.WriteString(k)
net.WriteUInt(v, 8)
end

net.SendToServer()

self.itemData = {}
Expand Down
9 changes: 7 additions & 2 deletions gamemode/core/libs/sh_business.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ if (SERVER) then
util.AddNetworkString("ixShipmentClose")

net.Receive("ixBusinessBuy", function(length, client)
local items = net.ReadTable()

if (client.ixNextBusiness and client.ixNextBusiness > CurTime()) then
client:NotifyLocalized("businessTooFast")
return
Expand All @@ -20,6 +18,13 @@ if (SERVER) then
return
end

local indicies = net.ReadUInt(8)
local items = {}

for _ = 1, indicies do
items[net.ReadString()] = net.ReadUInt(8)
end

if (table.IsEmpty(items)) then
return
end
Expand Down

0 comments on commit 81e100d

Please sign in to comment.