[QUOTE=Chessnut;42002219]Since the data.inv is a string, you could try string.find(data.inv, "flashlight")[/QUOTE]
you stored the inventory in a string, why not use a table holding strings
It is a table encoded using vON so it can be a string and be put into the database.
Or just decode the string and then search for it and then re-encode it (makes more sense).
Wait I made a mistake, data.inv is not an actual string until it gets encoded into the database. You can check if the inventory contains an item by using:
[lua]
function SCHEMA:GetDefaultInv(inventory, client, data)
-- Can only use uniqueID as a replacement for cid
if (data.inv.buffer.cid) then
-- whatever
end
end
[/lua]
Also pilot, GetDefaultInv only works on the server since that is what it the inventory is when inserted into the database. And the client does not and should not have access to the database.
I am using a external MySql Database and when you create a character and rejoin it does not display you old character until you create another one.
What can i do to fix this?
[QUOTE=Chessnut;42004191]Wait I made a mistake, data.inv is not an actual string until it gets encoded into the database. You can check if the inventory contains an item by using:
[lua]
function SCHEMA:GetDefaultInv(inventory, client, data)
-- Can only use uniqueID as a replacement for cid
if (data.inv.buffer.cid) then
-- whatever
end
end
[/lua]
Also pilot, GetDefaultInv only works on the server since that is what it the inventory is when inserted into the database. And the client does not and should not have access to the database.[/QUOTE]
Alright, thank you. But, that said with GetDefaultInv for the server. Would it affect how something() (the derma function) would be run let's just say if I put it in:
[CODE]
if (SERVER) then
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
something()
end
end
[/CODE]
[QUOTE=hooghoog;42003370]are you saying you did that on purpose
anyways
[code]ITEM.name = "Karabiner 98k"
ITEM.uniqueID = "k98k"
ITEM.class = "weapon_sim_kar98k"
ITEM.model = Model("models/weapons/b_k98_f.mdl")
ITEM.desc = "A bolt-action rifle with a wooden stock and a rather plain design."
ITEM.loweredOrigin = Vector(3, 0, -4)
ITEM.loweredAngles = Angle(0, 45, 0)
ITEM.attachmentBone = "ValveBiped.Bip01_Spine"
ITEM.attachmentOffsetAngles = Angle(0, 0, 0)
ITEM.attachmentOffsetVector = Vector(-2, 5, 4)[/code][/QUOTE]
[code]
ITEM.base = "base_wep"
ITEM.name = "Karabiner 98k"
ITEM.uniqueID = "k98k"
ITEM.class = "weapon_sim_kar98k"
ITEM.model = Model("models/weapons/b_k98_f.mdl")
ITEM.desc = "A bolt-action rifle with a wooden stock and a rather plain design."
ITEM.loweredOrigin = Vector(3, 0, -4)
ITEM.loweredAngles = Angle(0, 45, 0)
ITEM.attachmentBone = "ValveBiped.Bip01_Spine"
ITEM.attachmentOffsetAngles = Angle(0, 0, 0)
ITEM.attachmentOffsetVector = Vector(-2, 5, 4)[/code]
I tried testing this out excessively and I don't think this:
[CODE]function SCHEMA:GetDefaultInv(inventory, client, data)
-- Can only use uniqueID as a replacement for cid
if (data.inv.buffer.cid) then
-- whatever
end
end[/CODE]
works.
So, first I tried putting it into my item like this:
[CODE]
ITEM.functions.Use = {
run = function()
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
something()
end
end
}[/CODE]
This did not work. Then I tried putting:
[CODE]ITEM.functions.Use = {
run = function()
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
if (CLIENT) then
something()
end
end
end
}[/CODE]
This too, did not work.
Then I thought, "Okay let's just see if this can work at all." So I went into sv_hooks and did.
[CODE]function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
client:ChatPrint( "It worked" )
end
end[/CODE]
This did not work either.
Then, I thought "Maybe I can try to make it work in a plugin." So I went into the plugins folder in my schema with a simple sh_doesitwork file with the code:
[CODE]PLUGIN.name = "Does it work?"
PLUGIN.author = "Pilot"
PLUGIN.desc = "If it works it won't give me a tough time."
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
client:ChatPrint( "It worked" )
end
end[/CODE]
This didn't work, so then I gave it a last try with:
[CODE]PLUGIN.name = "Does it work?"
PLUGIN.author = "Pilot"
PLUGIN.desc = "If it works it won't give me a tough time."
function PLUGIN:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
client:ChatPrint( "It worked" )
end
end[/CODE]
And this is when I thought something is definatly up. That said, any fix or something looks off in what I did? As much as I'm trying to help my script, I think this can help other people in the future which is why I'm complaining so much.
[QUOTE=pilot;42006478]I tried testing this out excessively and I don't think this:
[CODE]function SCHEMA:GetDefaultInv(inventory, client, data)
-- Can only use uniqueID as a replacement for cid
if (data.inv.buffer.cid) then
-- whatever
end
end[/CODE]
works.
So, first I tried putting it into my item like this:
[CODE]
ITEM.functions.Use = {
run = function()
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
something()
end
end
}[/CODE]
This did not work. Then I tried putting:
[CODE]ITEM.functions.Use = {
run = function()
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
if (CLIENT) then
something()
end
end
end
}[/CODE]
This too, did not work.
Then I thought, "Okay let's just see if this can work at all." So I went into sv_hooks and did.
[CODE]function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
client:ChatPrint( "It worked" )
end
end[/CODE]
This did not work either.
Then, I thought "Maybe I can try to make it work in a plugin." So I went into the plugins folder in my schema with a simple sh_doesitwork file with the code:
[CODE]PLUGIN.name = "Does it work?"
PLUGIN.author = "Pilot"
PLUGIN.desc = "If it works it won't give me a tough time."
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
client:ChatPrint( "It worked" )
end
end[/CODE]
This didn't work, so then I gave it a last try with:
[CODE]PLUGIN.name = "Does it work?"
PLUGIN.author = "Pilot"
PLUGIN.desc = "If it works it won't give me a tough time."
function PLUGIN:GetDefaultInv(inventory, client, data)
if (data.inv.buffer.cid) then
client:ChatPrint( "It worked" )
end
end[/CODE]
And this is when I thought something is definatly up. That said, any fix or something looks off in what I did? As much as I'm trying to help my script, I think this can help other people in the future which is why I'm complaining so much.[/QUOTE]
Wouldn't know since not done it myself, but should you really be referencing the buffer?
[QUOTE=Ylsid;42006632]Wouldn't know since not done it myself, but should you really be referencing the buffer?[/QUOTE]
I think it has to be there, I tried removing it, but then it does nothing. What I'm wondering is if I should add string.find somehow.
my eyes
[QUOTE=M60warrior;42005423]I am using a external MySql Database and when you create a character and rejoin it does not display you old character until you create another one.
What can i do to fix this?[/QUOTE]
One of the recent commits fixed that.
[editline]29th August 2013[/editline]
Pilot, the issue is the inventory has not been fully built yet. I can add a hook that gets called after the default inventory is created.
[QUOTE=Chessnut;42008576]One of the recent commits fixed that.
[editline]29th August 2013[/editline]
Pilot, the issue is the inventory has not been fully built yet. I can add a hook that gets called after the default inventory is created.[/QUOTE]
Alright then, anything that can get this working in the future would be awesome. In other news, we do still need a ammunition base.
Actually, even when I do something like this, it doesn't work:
[CODE]run = function()
if (SERVER) then
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.charname, "TEST") then
something()
end
end
end
end[/CODE]
(DOUBLE POST WOOPS)
That's not how schema hooks work. Why exactly are you trying to use GetDefaultInv for?
[QUOTE=Chessnut;42011481]That's not how schema hooks work. Why exactly are you trying to use GetDefaultInv for?[/QUOTE]
I was trying to replicate:
[CODE]function SCHEMA:GetDefaultInv(inventory, client, data)
-- To see what the character data contains, uncomment the line below by removing the -- prefix.
-- PrintTable(data)
if (string.find(data.charname, "Bright")) then
inventory:Add("flashlight")
end
end[/CODE]
From [url]http://ns.chessnut.info/Hooks/GetDefaultInv[/url]
To see if I can compensate for the inventory not working so correctly with what I was trying to do before.
Here's how GetDefaultInv was used in the sample schema: [url]https://github.com/Chessnut/sample-schema/blob/master/gamemode/schema/sv_hooks.lua[/url]
So could I do:
[CODE]run = function()
if (SERVER) then
function SCHEMA:GetDefaultInv(inventory, client, data)
if (data.faction == FACTION_CITIZEN) then
something()
else return
end
end
end
end[/CODE]
P.S: New Nutscript fix broke Nutscript. With error:
[CODE][ERROR] gamemodes/nutscript/gamemode/libs/sh_faction.lua:22: attempt to call field 'Query' (a nil value)
1. InitializeData - gamemodes/nutscript/gamemode/libs/sh_faction.lua:22
2. unknown - gamemodes/nutscript/gamemode/core/sv_hooks.lua:36
Timer Failed! [Simple][@gamemodes/nutscript/gamemode/core/sv_hooks.lua (line 25)]
==sending Beam data to Player [1][Pilot] ==
[/CODE]
I accidently set the module from sqlite to tmysql4, which should be fixed.
And I changed the menu to match the character menu: [url]http://i.imgur.com/TcNqTZU.jpg[/url]
[QUOTE=Chessnut;42013526]I accidently set the module from sqlite to tmysql4, which should be fixed.
And I changed the menu to match the character menu: [url]http://i.imgur.com/TcNqTZU.jpg[/url][/QUOTE]
Perfect, does this update also come with the...find item in inventory thing?
[editline]29th August 2013[/editline]
I found that all the items that I made in my schema folder didn't appear to work in the server. Not in the vendor tab or in the buisness tab. Could be a new glitch?
oh god not this again
mate we solved this like 4 pages ago
[QUOTE=hooghoog;42014095]oh god not this again
mate we solved this like 4 pages ago[/QUOTE]
This error occured with the installation of the new nutscript update. Nothing changed on my part. And when I install the old nutscript folder it works.
that's because the modules won't upload with the latest update for some reason.
go into sh or sv_config and change tmysql4 to sqlite, just use ctrl + f to find that line. not sure if it's sv or sh, probably sh. tell me if that works, that's the issue i just had and solved with chessnut's help
[QUOTE=hooghoog;42015728]that's because the modules won't upload with the latest update for some reason.
go into sh or sv_config and change tmysql4 to sqlite, just use ctrl + f to find that line. not sure if it's sv or sh, probably sh. tell me if that works, that's the issue i just had and solved with chessnut's help[/QUOTE]
Hm, strange apparently sqlite is already set. I'm going to test one more time.
Nope, items still not working. And I made sure sv_config was in sqlite and sh_config didn't have an option for sqlite or tmysql4
(Gah I keep expecting the post to go under the one on top under Edit:)
I'm looking forward to NutScript. It seems a band of lesser known figures have come along, and made something a little similiar to ClockWork... And made it good.
And as this is a frame, I guess this would also mean I could use this for my... Upcoming serious RP gamemode. Gonna keep it a surprise.
And if there is a crafting side to this frame, it'll be very useful for a... Specific faction.
And the next part, linking to my first sentence is that its free. You;ve donated your time, your effort to bring a free, well working, serious RP frame to Garry's Mod. While the ClockWork's crew sit on their asses making thousands for a half started, unbalanced, bug infested and poor performance frame.
I see great things coming from NutScript. Well done people, and keep it up.
[QUOTE=ShadowOfDoubt;42023517]I'm looking forward to NutScript. It seems a band of lesser known figures have come along, and made something a little similiar to ClockWork... And made it good.
And as this is a frame, [B]I guess this would also mean I could use this for my... Upcoming serious RP gamemode. Gonna keep it a surprise.[/B]
[B]And if there is a crafting side to this frame, it'll be very useful for a... Specific faction.[/B]
And the next part, linking to my first sentence is that its free. You;ve donated your time, your effort to bring a free, well working, serious RP frame to Garry's Mod. While the ClockWork's crew sit on their asses making thousands for a half started, unbalanced, bug infested and poor performance frame.
I see great things coming from NutScript. Well done people, and keep it up.[/QUOTE]
so basically you used praising the developers as an excuse to brag about an upcoming SUPER SECRET SCHEMA? fucking dumb
[QUOTE=ShadowOfDoubt;42023517]I'm looking forward to NutScript. It seems a band of lesser known figures have come along, and made something a little similiar to ClockWork... And made it good.
And as this is a frame, I guess this would also mean I could use this for my... Upcoming serious RP gamemode. Gonna keep it a surprise.
And if there is a crafting side to this frame, it'll be very useful for a... Specific faction.
And the next part, linking to my first sentence is that its free. You;ve donated your time, your effort to bring a free, well working, serious RP frame to Garry's Mod. While the ClockWork's crew sit on their asses making thousands for a half started, unbalanced, bug infested and poor performance frame.
I see great things coming from NutScript. Well done people, and keep it up.[/QUOTE]
I don't think Chessnut and Rebel are really lesser known figures in the gmod world anymore
[QUOTE=DeathByKittens;42024279]I don't think Chessnut and Rebel are really lesser known figures in the gmod world anymore[/QUOTE]
They are ages behind compared to conna and rick dark, people on facepunch definitely know about chessnut but most servers are still using clockwork.
It won't be long before it rivals CW. Just a few more incremental features and some more user friendly niceness and walla.
Sorry, you need to Log In to post a reply to this thread.