• Trying to use weapons.Register~ no success in registry
    3 replies, posted
[lua] // passed item model is models/healthvial.mdl // passed item name is item_health_vial weapons.Register({ Base = "weapon_base", Author = "SourceTribe Development Team", Contact = "sourcetribe.co.uk", Purpose = "", Instructions = "", ViewModel = item.model, WorldModel = item.model, Slot = 3, SlotPos = 2, PrimaryAttack = function(self) if SERVER && item.removeOnUse then self.Owner:StripWeapon("weapon_iWep_" .. item.name); print("used item"); end item.onUse(); end, SecondaryAttack = function(self) if SERVER then self.Owner:StripWeapon("weapon_iWep_" .. item.name); local inv = InvObject:setup(); inv:assignPlayer(self.Owner); inv:addItem(item.name); print("put into backpack"); end end, },"weapon_iWep_" .. item.name,false); [/lua] The following code prints a pointer to a table. [lua] print(weapons.Stored("weapon_iWep_item_health_vial")); [/lua] The following code prints "Attempted to create unknown entity type" [lua] players.GetAll()[1]:Give("weapon_iWep_item_health_vial") [/lua] Any clue whats wrong or what to try to fix it?
Why are you using [B]weapons.Register()[/B]? Why can't you create a swep folder with a shared script inside?
I don't want to have to create multiple weapons like that, that will all be so similar.
Okay, I can't guarentee the SWEP itself will work, but to register a weapon like that i usually do it in this format: [lua] local SWEP = weapons.Get("weapon_base") --Or any other base --Create SWEP as you would in shared.lua here SWEP.PrintName = "Name" --Other shared stuff if SERVER then SWEP.Weight = 5 --Other serverside stuff elseif CLIENT then SWEP.DrawCrosshair = true --Other clientside stuff end function SWEP:PrimaryAttack() end -- etc -- weapons.Register(SWEP, "weapon_name", true) [/lua]
Sorry, you need to Log In to post a reply to this thread.