I've been trying to do this for a while now but I can;t figure it out. I saw alot of threads on this forum and none of them worked for me. This is my current code for one of my sweps:
[CODE]ITEM.Name = 'Frosmourne'
ITEM.Price = 200 -- Give it a price
ITEM.Model = 'models/weapons/w_frostmourne.mdl' -- This is what it will look like in the menu
ITEM.WeaponClass = 'weapon_frostmourne'
ITEM.SingleUse = false -- Is it not persistent? Do they have to buy a new one each time they want one?
function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end[/CODE]
whenever I buy it and equip nothing happens, I want it to replace the crowbar but it doesn't even show up in my weapon scrollbar.
The console also prints out:
[CODE]Attempted to create unkown entity type weapon_frostmourne!
NULL Ent in GiveNameItem![/CODE]
Well first of all, if you want it to replace the crowbar don't use ITEM:OnBuy, and regardless, don't use ITEM:OnBuy on an itme that is not a single use item.
You may wish to look at the posts I made in the [URL="http://facepunch.com/showthread.php?t=1411111&p=45609158&viewfull=1#post45609158"]Problems That Don't Need Their Own Thread[/URL] , you may find something useful in there.
Bottom line: Don't use ITEM:OnBuy if it's not a single use item, and if you want it to replace the crowbar you need to strip and holster it first.
You actually have to have a weapon called weapon_frostmourne on the server for this to work.
[CODE]ITEM.Name = 'Frostmourne'
ITEM.Price = 200
ITEM.Model = 'models/weapons/w_frostmourne.mdl'
ITEM.WeaponClass = 'weapon_frostmourne'
function ITEM:OnEquip(ply)
ply:StripWeapon('weapon_zm_improvised')
ply:Give('weapon_frostmourne')
ply:SelectWeapon('weapon_frostmourne')
end
function ITEM:OnHolster(ply)
ply:StripWeapon('weapon_frostmourne')
ply:Give('weapon_zm_improvised')
ply:SelectWeapon('weapon_zm_improvised')
end[/CODE]
Make sure the folder "weapon_frostmourne" and the shared.lua inside exists in your gamemodes/.../weapons folder. Sounds like to me it doesn't exist.
[QUOTE=Kaillus;45610238][CODE]ITEM.Name = 'Frostmourne'
ITEM.Price = 200
ITEM.Model = 'models/weapons/w_frostmourne.mdl'
ITEM.WeaponClass = 'weapon_frostmourne'
function ITEM:OnEquip(ply)
ply:StripWeapon('weapon_zm_improvised')
ply:Give('weapon_frostmourne')
ply:SelectWeapon('weapon_frostmourne')
end
function ITEM:OnHolster(ply)
ply:StripWeapon('weapon_frostmourne')
ply:Give('weapon_zm_improvised')
ply:SelectWeapon('weapon_zm_improvised')
end[/CODE]
Make sure the folder "weapon_frostmourne" and the shared.lua inside exists in your gamemodes/.../weapons folder. Sounds like to me it doesn't exist.[/QUOTE]
there is no weapons folder in my gamemode folder and how would that file look like inside? Like the code and shit?
[QUOTE=okkeh96;45610264]there is no weapons folder in my gamemode folder and how would that file look like inside? Like the code and shit?[/QUOTE]
I assume your game mode is murder
Put the shared.lua file in here:
gamemodes/deathrun/entities/weapons/weapon_frostmourne
Sorry, you need to Log In to post a reply to this thread.