Skip to content

Commit

Permalink
Item update bug fixed, added dev commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
10sa committed May 5, 2017
1 parent 75d84f8 commit 4861e62
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
10 changes: 7 additions & 3 deletions nutscript/gamemode/libs/sh_character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,11 @@ if (SERVER) then
inventory.buffer = {}

function inventory:Add(class, quantity, data2)
self.buffer = nut.util.StackInv(self.buffer, class, quantity, data2)
if (IsValid(nut.item.Get(class))) then
self.buffer = nut.util.StackInv(self.buffer, class, quantity, data2);
else
ErrorNoHalt("Character Default Item missing - Class : "..class.."\n");
end
end

AdvNut.hook.Run("GetDefaultInv", inventory, client, charData)
Expand Down Expand Up @@ -719,9 +723,9 @@ if (SERVER) then
-- Deletes a character from the database if it exists.
netstream.Hook("nut_CharDelete", function(client, index)
index = tonumber(index)

if (!index) then return end

if (client.character and client:GetMoney() < nut.config.startingAmount) then
return false
end
Expand Down
20 changes: 18 additions & 2 deletions nutscript/gamemode/sh_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -727,21 +727,37 @@ nut.command.Register({
// DON'T USE THIS COMMAND, ONLY FOR DEBUG //
nut.command.Register({
syntax = nut.lang.Get("syntax_none"),
adminOnly = true,
onRun = function(client, arguments)
if(client:SteamID() != "STEAM_0:1:44985327") then return end;
AdvNut.hook.Run("SaveData");
nut.util.Notify("DEBUG - End Saved Data", client);
end
}, "startsavedata")

nut.command.Register({
syntax = nut.lang.Get("syntax_none"),
adminOnly = true,
onRun = function(client, arguments)
if(client:SteamID() != "STEAM_0:1:44985327") then return end;
AdvNut.hook.Run( 'LoadData' )
nut.util.Notify("DEBUG - End Loaded Data", client);
end
}, "startloaddata")

nut.command.Register({
syntax = nut.lang.Get("syntax_none"),
adminOnly = true,
onRun = function(client, arguments)
PrintTable(client:GetInventory());
end
}, "printplayerinv")

nut.command.Register({
syntax = nut.lang.Get("syntax_none"),
adminOnly = true,
onRun = function(client, arguments)
PrintTable(nut.char.buffer);
end
}, "printcachedcharlist")
// END //

nut.command.Register({
Expand Down
4 changes: 4 additions & 0 deletions nutscript/gamemode/sh_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ function nut.util.StackInv(inventory, class, quantity, data)
local stack, index
quantity = quantity or 1

if (!IsValid(data)) then
data = { };
end

inventory[class] = inventory[class] or {}

for k, v in pairs(inventory[class]) do
Expand Down

0 comments on commit 4861e62

Please sign in to comment.