• Auto-Holster in Pointshop
    14 replies, posted
I am trying to make something that unequips/unholsters a gun with the same Slot/Kind in TTT when they equip a new gun. Not sure if there is a PointShop function for this but I haven't found it. [CODE] ITEM.Name = 'Tempest SMG' ITEM.Price = 0 ITEM.Model = 'models/weapons/w_rif_galil.mdl' ITEM.WeaponClass = 'tempest_smg' ITEM.Slot = 3 function ITEM:OnEquip(ply) for k,v in pairs(ply:GetWeapons()) do if(v.Kind == self.Slot) then ply:StripWeapon( v.Gun ) ply:PS_HolsterItem( v.Gun ) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end [/CODE] I can't seem to get PS_HolsterItem to work, it strips the item but does not holster it. Please let me know if there is an easier way to do this or the error in my usage of PS_HolsterItem. I do acknowledge the fact I suck at Lua so there is a large probability that there is a easier way to do this =) EDIT: The ITEM.Slot is because I couldn't find a way to pull the actual weapon slot from the item, so I decided to manually add it to the script to be used on the slot check. EDIT2: This is a repost from the Problems that don't need their own thread, but I am kind of in a hurry to get this done and it was kind of ignored on that thread so I moved it here. (Guess it does need it's own thread...)
Why is it [CODE]ITEM:OnEquip(ply)[/CODE] and not [CODE]ITEM:OnBuy(ply)[/CODE]
It's not a single use item, wouldn't OnBuy only go off on the first purchase of it?
[QUOTE=KevinnTCG;45604063]It's not a single use item, wouldn't OnBuy only go off on the first purchase of it?[/QUOTE] Oh, it's NOT a single use item, you probably should've said that :P But just wondering, if it's not a single use item what are they buying?
OnEquip is ran when the item is equipped, which means it runs when you buy the perk and whenever it is holstered and equipped. OnBuy only gets ran when you buy the item. I don't really get what you're trying to do, though. Care to explain a little further?
I am trying to holster any item from the pointshop that uses the same slot/TTT Kind upon equipping a new item from the pointshop, if the slot/kind matches. So they can equip a gun even if they have something using the same slot. The weapon strip works, it's the Holstering that doesn't. EDIT: The holster command does not throw any errors, and the Pointshop page for the item functions says it's server sided, not sure what is wrong.
If you want them to buy weapons, you need it to be a single use item, or it will just be buggy...
So this is what you're trying to do; You can choose between 2 guns. You buy the first gun and equip it. You then buy the second gun, and when you equip it, you automaticly holster the first gun?
[QUOTE=Lolm4te;45604226]So this is what you're trying to do; You can choose between 2 guns. You buy the first gun and equip it. You then buy the second gun, and when you equip it, you automaticly holster the first gun?[/QUOTE] No. He wants it so that if I am holding a H.U.G.E. and I'm buying an M16, it wouldn't bug and I would lost points but not get the gun (That is what happens without the strip N holster part)
Technically it works, but with the other gun still "unholstered" in the pointshop it will keep trying to give him both guns at the start of the round.
Is v.Gun the same as the file name of the item without the .lua?
yeah v.gun is just a variable inside the SWEP that is the classname of the gun.
I believe you have to put the lua file in PS_HolsterItem without the .lua. Let's say your item is myitem.lua in the items folder, you would do PS_HolsterItem( myitem ). This is how PS_HasItem works from what I know. Correct me if I am wrong, though.
[QUOTE=KevinnTCG;45604617]yeah v.gun is just a variable inside the SWEP that is the classname of the gun.[/QUOTE] That variable needs to have the same name as the file of the item for the holstering to work.
Would it work if I renamed the .lua file to the name of the SWEP? EDIT: Oh I see, it works if I do this =) Thanks for the help, really had no clue what the item_id meant on the pointshop lua page thing.
Sorry, you need to Log In to post a reply to this thread.