• NutScript - Nutty name, serious framework
    2,778 replies, posted
[QUOTE=Eldeos;41962097]In all honesty, I'd advise you stay away from HL2RP. It's so generic and overused now.[/QUOTE] Yeah, for a long time I thought that. Even before I played HL2RP I always knew it as 'That part of RP' but you know if you were to dust it off. Take a different approach, maybe it still has some zest in it. I mean, not one said I /had/ to do the whole City or Outlands expierence that everyone does.
I'm running into some issues, please tell me if you know how to fix them. These issues specifically deal with /chargiveitem and /vendoradd. Frederick O'Connor has ran command 'chargiveitem fred "Karabiner 98k"' You specified an invalid item. Frederick O'Connor has ran command 'chargiveitem fred K98k' You specified an invalid item. Frederick O'Connor has ran command 'chargiveitem fred Karabiner 98K' You specified an invalid item. Tried the Unique ID, the name, printed name, everything.. I also can't give myself CID or bricks, which are basic items included with the sample schema itself. I've tried vendors, too, and those don't work. Please help if you know what's wrong!
Post the item code here. Also, post your code for the item give command, sh_commands.lua under nutscript/gamemode. Starts at line 211, or around that point.
Seeing as someone's already working on Black Mesa RP, I'll make a 'Totally not Cider' schema. I think I'll name it Beer. [editline]25th August 2013[/editline] Maybe Coffee or Tea. Not sure. I could also name it Wine.
Currently Fixing some plugins from me in NutScript Public Git.
if (SERVER) then SWEP.Weight = 4 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false end if ( CLIENT ) then SWEP.PrintName = "Karabiner 98k" SWEP.Author = "Siminov" SWEP.Instructions = "Left click to fire." SWEP.ShowWorldModel = true end SWEP.Base = "sh_weapon" SWEP.Category = "Black Tea" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.UseHands = true SWEP.Slot = 1 // Slot in the weapon selection menu SWEP.SlotPos = 1 // Position in the slot SWEP.ViewModel = "models/weapons/b_k98_f.mdl" SWEP.WorldModel = "models/weapons/a_k98.mdl" SWEP.HoldType = "smg" SWEP.Primary.Sound = Sound( "k98_shoot" ) SWEP.Primary.ReloadSound = Sound( "k98_clipin" ) SWEP.Primary.Automatic = false SWEP.Primary.ClipSize = 6 // Size of a clip SWEP.Primary.DefaultClip = 0 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "smg1" SWEP.Primary.Delay = 0.1 SWEP.Primary.Damage = 45 SWEP.Primary.Spread = .06 nut.command.Register({ adminOnly = true, syntax = "<string name> <string item> [number amount]", onRun = function(client, arguments) local name = arguments[1] or "" local find = arguments[2] or "" local amount = math.max(tonumber(arguments[3] or "") or 1, 1) local target = nut.command.FindPlayer(client, name) if (IsValid(target)) then for k, v in pairs(nut.item.GetAll()) do if (nut.util.StringMatches(find, v.name) or nut.util.StringMatches(find, v.uniqueID)) then target:UpdateInv(v.uniqueID, amount) nut.util.Notify("You have given "..target:Name().." "..amount.." "..v.name.." item(s).", client) nut.util.Notify(target:Name().." has given you "..amount.." "..v.name.." item(s).", target) return end end nut.util.Notify("You specified an invalid item.", client) end end }, "chargiveitem")
If you have the SWEP uploaded all you need to do is fill in; [lua]ITEM.name = "Base Weapon" ITEM.uniqueID = "base_wep" ITEM.category = "Weapons" ITEM.class = "weapon_crowbar" ITEM.type = "melee" ITEM.data = { Equipped = false } ITEM.functions = {} ITEM.functions.Equip = { run = function(itemTable, client, data) if (SERVER) then if (client:HasWeapon(itemTable.class)) then nut.util.Notify("You already has this weapon equipped.", client) return false end if (nut.config.noMultipleWepSlots and IsValid(client:GetNutVar(itemTable.type))) then nut.util.Notify("You already have a weapon in the "..itemTable.type.." slot.", client) return false end local weapon = client:Give(itemTable.class) if (IsValid(weapon)) then client:SetNutVar(itemTable.type, weapon) client:SelectWeapon(itemTable.class) end local newData = table.Copy(data) newData.Equipped = true client:UpdateInv(itemTable.uniqueID, 1, newData) end end, shouldDisplay = function(itemTable, data, entity) return !data.Equipped or data.Equipped == nil end } ITEM.functions.Unequip = { run = function(itemTable, client, data) if (SERVER) then if (client:HasWeapon(itemTable.class)) then client:SetNutVar(itemTable.type, nil) client:StripWeapon(itemTable.class) end local newData = table.Copy(data) newData.Equipped = false client:UpdateInv(itemTable.uniqueID, 1, newData) return true end end, shouldDisplay = function(itemTable, data, entity) return data.Equipped == true end } local size = 16 local border = 4 local distance = size + border local tick = Material("icon16/tick.png") function ITEM:PaintIcon(w, h) if (self.data.Equipped) then surface.SetDrawColor(0, 0, 0, 50) surface.DrawRect(w - distance - 1, w - distance - 1, size + 2, size + 2) surface.SetDrawColor(255, 255, 255) surface.SetMaterial(tick) surface.DrawTexturedRect(w - distance, w - distance, size, size) end end function ITEM:CanTransfer(client, data) if (data.Equipped) then nut.util.Notify("You must unequip the item before doing that.", client) end return !data.Equipped end if (SERVER) then hook.Add("PlayerSpawn", "nut_WeaponBase", function(client) timer.Simple(0.1, function() if (!IsValid(client) or !client.character) then return end for class, items in pairs(client:GetInventory()) do local itemTable = nut.item.Get(class) if (itemTable.class) then for k, v in pairs(items) do if (v.data.Equipped) then client:Give(itemTable.class) end end end end end) end) end [/lua] Item class being what you get when you right click on the weapon in the weapons tab on GMOD and click copy to clipboard. Reply if you can't get it working.
Thanks, but the /chargiveitem command still won't work with CID and bricks, any ideas regarding that? If it doesn't work for specific items I doubt it'll work for this.
Post/PM me you sh_commands.lua file. Are you sure you're set to super admin?
Uhh, I was running a listen server, and the only error was "invalid item", so. I think so. [editline]25th August 2013[/editline] [url]http://www.mediafire.com/?40gd4x5t4rqnqyi[/url] Here's the sh_commands, sorry for the double post.
[QUOTE=Eldeos;41965489]If you have the SWEP uploaded all you need to do is fill in; -snip- Item class being what you get when you right click on the weapon in the weapons tab on GMOD and click copy to clipboard. Reply if you can't get it working.[/QUOTE] No no no, that's the weapon base class. Basically all you do is go to your schema/plugin's item folder and create a new folder called 'weapon' if it does not exist already. Then, all you item needs is this: [lua] ITEM.name = "Stunstick" ITEM.uniqueID = "wep_stunstick" ITEM.class = "weapon_stunstick" ITEM.type = "melee" [/lua] As you can see, everything from the base will be derived. This removes the need to copy and paste all the stuff from the base and simplify it into that.
This doesn't answer the question regarding why /chargiveitem won't work for the basic schema items or anything else, but it does help with the weapon itself. Any ideas regarding the actual command, Chess?
[QUOTE=hooghoog;41965699]This doesn't answer the question regarding why /chargiveitem won't work for the basic schema items or anything else, but it does help with the weapon itself. Any ideas regarding the actual command, Chess?[/QUOTE] NutScript stops load when something in your script is emitting error.
There's no given errors, only invalid item. Perhaps I should just PM one of you my gamemode and schema and you can check what's wrong? [editline]25th August 2013[/editline] Here, let's make sure I'm doing this right: ITEM.name = "Karabiner 98k" ITEM.uniqueID = "k98k" ITEM.class = "weapon_dod_sim_base" ITEM.type = "ranged" This is in the "weapons" folder of the plugins area.
Are you saying that there's a weapons folder in the plugins folder or that you have a plugin (let's call it asdf) and it looks like plugins/asdf/entities/weapons? If it's just in the plugins folder it won't load.
It's in the plugins/whatever/weapons folder. I still think the issue is with the actual command rather than the item itself, though. If you can log on steam I can give you .rars of everything and you can check it out.
Put the ITEM.type to uh-- smg? I don't think there's a "ranged" weapon type. :O
Oh? Uh, I looked at Black's code and I swore I saw something like that..
plugins/whatever/entities/weapons is actually right.
gamemodes\ww2rp\plugins\ww2rp\entities ? [editline]25th August 2013[/editline] Frederick O'Connor has ran command 'chargiveitem Frederick Karabiner 98k' You specified an invalid item. Frederick O'Connor has ran command 'chargiveitem fred Stationary Radio' You have given Frederick O'Connor 1 Stationary Radio item(s). Frederick O'Connor has given you 1 Stationary Radio item(s). So the business menu items work..but the brick, CID and weapons don't. [editline]25th August 2013[/editline] I also tried updating NS, no luck. Did you guys break /chargiveitem accidentally or something? The fact that bricks and CIDs aren't working either leads me to believe that.
[QUOTE=hooghoog;41965737]There's no given errors, only invalid item. Perhaps I should just PM one of you my gamemode and schema and you can check what's wrong? [editline]25th August 2013[/editline] Here, let's make sure I'm doing this right: ITEM.name = "Karabiner 98k" ITEM.uniqueID = "k98k" ITEM.class = "weapon_dod_sim_base" ITEM.type = "ranged" This is in the "weapons" folder of the plugins area.[/QUOTE] Do all your weapon items have the same ITEM.class ..? [code]ITEM.class = "weapon_dod_sim_base"[/code]
Yes. And it's just one weapon.
PM me your schema and I'll see if I can help.
PMed, thanks.
[QUOTE=hooghoog;41966339]PMed, thanks.[/QUOTE] So I diagnosed the issue and sent you the instructions to fix the issues. But your assumption that /chargiveitem didn't work is entirely false.
ITEM.name = "Karabiner 98k" ITEM.uniqueID = "k98k" ITEM.class = "weapon_sim_kar98k" ITEM.type = "smg" ITEM.category = "Weapons" ITEM.weight = "2" ITEM.model = "models/weapons/b_k98_f.mdl" So, for example, would this be correct? Probably not, considering this error: [ERROR] gamemodes/nutscript/gamemode/libs/sh_item.lua:344: attempt to compare string with number 1. GetInvWeight - gamemodes/nutscript/gamemode/libs/sh_item.lua:344 2. UpdateInv - gamemodes/nutscript/gamemode/libs/sh_item.lua:237 3. onRun - gamemodes/nutscript/gamemode/sh_commands.lua:223 4. RunCommand - gamemodes/nutscript/gamemode/libs/sh_commands.lua:39 5. ParseCommand - gamemodes/nutscript/gamemode/libs/sh_commands.lua:113 6. Process - gamemodes/nutscript/gamemode/libs/sh_chatbox.lua:326 7. Run - gamemodes/nutscript/gamemode/core/sv_hooks.lua:154 8. func - gamemodes/nutscript/plugins/chatbox/sh_chatbox.lua:287 9. unknown - lua/includes/modules/net.lua:31 Btw, here's how I have things formatted: [url]http://www.mediafire.com/?mtmga4eqjvfl3mh[/url] [B][I][U]Can someone provide an example of a nutscript weapon item? that would make things SO much easier.[/U][/I][/B]
[QUOTE=hooghoog;41967164]ITEM.name = "Karabiner 98k" ITEM.uniqueID = "k98k" ITEM.class = "weapon_sim_kar98k" ITEM.type = "smg" ITEM.category = "Weapons" ITEM.weight = "2" ITEM.model = "models/weapons/b_k98_f.mdl" So, for example, would this be correct? Probably not, considering this error: [ERROR] gamemodes/nutscript/gamemode/libs/sh_item.lua:344: attempt to compare string with number 1. GetInvWeight - gamemodes/nutscript/gamemode/libs/sh_item.lua:344 2. UpdateInv - gamemodes/nutscript/gamemode/libs/sh_item.lua:237 3. onRun - gamemodes/nutscript/gamemode/sh_commands.lua:223 4. RunCommand - gamemodes/nutscript/gamemode/libs/sh_commands.lua:39 5. ParseCommand - gamemodes/nutscript/gamemode/libs/sh_commands.lua:113 6. Process - gamemodes/nutscript/gamemode/libs/sh_chatbox.lua:326 7. Run - gamemodes/nutscript/gamemode/core/sv_hooks.lua:154 8. func - gamemodes/nutscript/plugins/chatbox/sh_chatbox.lua:287 9. unknown - lua/includes/modules/net.lua:31 Btw, here's how I have things formatted: [url]http://www.mediafire.com/?mtmga4eqjvfl3mh[/url] [B][I][U]Can someone provide an example of a nutscript weapon item? that would make things SO much easier.[/U][/I][/B][/QUOTE] [lua]ITEM.base = "base_wep" ITEM.name = "Electrified Baton" ITEM.uniqueID = "stickstun" ITEM.class = "weapon_stunstick" ITEM.model = Model("models/weapons/w_stunbaton.mdl") ITEM.desc = "A small metal rod held together with duct tape, the end glows deep."[/lua] easy peasy
[QUOTE=hooghoog;41967164]ITEM.name = "Karabiner 98k" ITEM.uniqueID = "k98k" ITEM.class = "weapon_sim_kar98k" ITEM.type = "smg" ITEM.category = "Weapons" [B]ITEM.weight = "2"[/B] ITEM.model = "models/weapons/b_k98_f.mdl" So, for example, would this be correct? Probably not, considering this error: [ERROR] gamemodes/nutscript/gamemode/libs/sh_item.lua:344: attempt to [B]compare string with number[/B][/QUOTE] Anything with quotes around it is a string, get rid of the quotes for weight since weight is a number. [editline]25th August 2013[/editline] You also do not need ITEM.category = "Weapons" since that is already defined in the base.
[QUOTE=a-cookie;41967942][lua]ITEM.base = "base_wep" ITEM.name = "Electrified Baton" ITEM.uniqueID = "stickstun" ITEM.class = "weapon_stunstick" ITEM.model = Model("models/weapons/w_stunbaton.mdl") ITEM.desc = "A small metal rod held together with duct tape, the end glows deep."[/lua] easy peasy[/QUOTE] Kipper? Helping ME? What? When? Where? why :suicide:
[QUOTE=hooghoog;41968068]Kipper? Helping ME? What? When? Where? why :suicide:[/QUOTE] uhh its this weird thing called forgive n forget
Sorry, you need to Log In to post a reply to this thread.