• Deathrun / Pointshop | Setting crowbar skins / models?
    20 replies, posted
I know how to add weapons to the pointshop, however I've had a couple of problems. I've wanted to add the crowbar weapon but with different models on it, like ie. a katana instead of the regular crowbar, but having it function like the regular one. I have, however, not found a way to get the crowbar lua code, disallowing me to simply 1) change the model, the weapon is using, 2) change the weapon name according to what model is used. Before anyone starts referring to TTT - that won't work. I tried that and it ended up with runners being able to team kill each others, plus it seems that there are slight differences with the regular HL2 crowbar and the TTT (but should be easily changeable). Please note that I need to have multiple models for the crowbar, and purchasing them in the shop will set your crowbar's skin. Questions / TL;DR: Any ways to get the HL2 crowbar lua code? Can I remove the ability to kill everyone from the TTT crowbar code? Can I affect the weapon_crowbar without actually having all of the code, ie. simply changing the model and leaving everything else blank? Is there a simpler way to change the crowbar's model?
You can either recreate the crowbar in Lua, or set the view model in the OnEquip hook.
[QUOTE=code_gs;48150002]You can either recreate the crowbar in Lua, or set the view model in the OnEquip hook.[/QUOTE] How would I go about changing the model with the hook? [code] ITEM.Name = 'Crowbar' ITEM.Price = 0 ITEM.Model = 'models/weapons/w_crowbar.mdl' ITEM.WeaponClass = 'weapon_crowbar' ITEM.SingleUse = false function ITEM:OnBuy(ply) ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end function ITEM:OnEquip(ply) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) end [/code]
ITEM.Model =
[QUOTE=PaperMoney;48205871]ITEM.Model =[/QUOTE] That changes the pointshop model when previewing it. Bump? Edit: So far, this is what I'm trying to do (or something like it): [code] function ITEM:OnEquip(ply) self.WeaponClass:SetMaterial("models/weapons/v_crowbar/crowbar_cyl.vtf") end [/code] I get this error though: [code][ERROR] addons/pointshop-master/lua/pointshop/items/weapons/crowbar.lua:13: attempt to index a string value with bad key ('SetMaterial' is not part of the string library) [/code]
-snip-
instead, use ply:GetWeapon( self.WeaponClass ):SetMaterial("your/material/path") make sure to check if ply:GetWeapon( self.WeaponClass ) is valid
[QUOTE=Arizard;48267676]instead, use ply:GetWeapon( self.WeaponClass ):SetMaterial("your/material/path") make sure to check if ply:GetWeapon( self.WeaponClass ) is valid[/QUOTE] Still doesn't seem to work. [code] ITEM.Name = 'Crowbar' ITEM.Price = 0 ITEM.Model = 'models/weapons/w_crowbar.mdl' ITEM.WeaponClass = 'weapon_crowbar' ITEM.SingleUse = false function ITEM:OnBuy(ply) ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end function ITEM:OnEquip(ply) if ply:GetWeapon( self.WeaponClass ):IsValid then function(ply) ply:GetWeapon( self.WeaponClass ):SetMaterial("weapons/v_crowbar/crowbar_cyl.vtf") end end end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) end [/code] [code] [ERROR] addons/pointshop-master/lua/pointshop/items/weapons/crowbar.lua:13: function arguments expected near 'then' 1. unknown - addons/pointshop-master/lua/pointshop/items/weapons/crowbar.lua:0 [/code] I believe the main cause is this: [code]Requesting texture value from var "$basetexture" which is not a texture value (material: trails/tube)[/code]
This is what you have: [code]function ITEM:OnEquip(ply) if ply:GetWeapon( self.WeaponClass ):IsValid then function(ply) ply:GetWeapon( self.WeaponClass ):SetMaterial("weapons/v_crowbar/crowbar_cyl.vtf") end end end[/code] and this is what you should try: [code]function ITEM:OnEquip(ply) if IsValid( ply:GetWeapon( self.WeaponClass ) ) then ply:GetWeapon( self.WeaponClass ):SetMaterial("weapons/v_crowbar/crowbar_cyl.vtf") end end[/code] First, you needed the correct format for the IsValid check. Some people do it this way and some people use the Class:IsValid() method, I don't really know if there's a difference so it might just be personal preference. Second, you didn't need to add the "function (ply)" inside your if statement. What this does is [i]define[/i] a function, but it doesn't [i]run[/i] anything. You just need to have the SetMaterial line inside the conditional, without the surrounding function. See what I'm saying?
[QUOTE=Arizard;48275451]-snip-[/QUOTE] Yeah, I was playing a bit around with it since it said something about the functions, so I believe I pasted the wrong code. Tried it out again with the right code, returned the same error: [code]Requesting texture value from var "$basetexture" which is not a texture value (material: trails/tube) [/code]
That error is looking for the trails/tube material, nothing to do with the crowbar afaik
[QUOTE=Chimpanzee;48275662]That error is looking for the trails/tube material, nothing to do with the crowbar afaik[/QUOTE] Appears every time I equip the crowbar. Another possibility is the pathing? Does it matter where I put it apart from having it in the /garrysmod folder? Currently have it in the addons folder, but tried moving around with it a couple of other places too.
[QUOTE=Arizard;48275451]First, you needed the correct format for the IsValid check. Some people do it this way and some people use the Class:IsValid() method, I don't really know if there's a difference so it might just be personal preference. [/QUOTE] Unrelated, but IsValid checks for nil. IsValid's "source": [lua] local function IsValid(o) return o ~= nil and o.IsValid and o:IsValid() end [/lua]
[QUOTE=Legendahkiin;48275677]Appears every time I equip the crowbar. Another possibility is the pathing? Does it matter where I put it apart from having it in the /garrysmod folder? Currently have it in the addons folder, but tried moving around with it a couple of other places too.[/QUOTE] Do you have a tube trail or some such in your pointshop? If not, go check the lua files for all your trails and look for anything that mentions "tube". Let me know
[QUOTE=Chimpanzee;48276763]Do you have a tube trail or some such in your pointshop? If not, go check the lua files for all your trails and look for anything that mentions "tube". Let me know[/QUOTE] Yeah, I have all the default trails. If you want the code: [code]ITEM.Name = 'Tube Trail' ITEM.Price = 150 ITEM.Material = 'trails/tube.vmt' function ITEM:OnEquip(ply, modifications) ply.TubeTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material) end function ITEM:OnHolster(ply) SafeRemoveEntity(ply.TubeTrail) end function ITEM:Modify(modifications) PS:ShowColorChooser(self, modifications) end function ITEM:OnModify(ply, modifications) SafeRemoveEntity(ply.TubeTrail) self:OnEquip(ply, modifications) end [/code]
I'm pretty sure the reason that error pops up is because pointshop refreshes your items or some shit like that whenever you equip something so it's checking for the tube trail material and it's not proper or something like that. Try removing the tubetrail file and see what happens
[QUOTE=Chimpanzee;48283805]I'm pretty sure the reason that error pops up is because pointshop refreshes your items or some shit like that whenever you equip something so it's checking for the tube trail material and it's not proper or something like that. Try removing the tubetrail file and see what happens[/QUOTE] Right, deleted all trails and I don't get an error anymore. The only possibility left is that I might've put the .vtf in the wrong folder or something?
Doubtful. I don't think the tubetrail uses a custom vtf or anything. You should just remove solely the tube trail if you want the rest
[QUOTE=Legendahkiin;48274023]Still doesn't seem to work. [code] ITEM.Name = 'Crowbar' ITEM.Price = 0 ITEM.Model = 'models/weapons/w_crowbar.mdl' ITEM.WeaponClass = 'weapon_crowbar' ITEM.SingleUse = false function ITEM:OnBuy(ply) ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end function ITEM:OnEquip(ply) if ply:GetWeapon( self.WeaponClass ):IsValid then function(ply) ply:GetWeapon( self.WeaponClass ):SetMaterial("weapons/v_crowbar/crowbar_cyl.vtf") end end end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) end [/code] [code] [ERROR] addons/pointshop-master/lua/pointshop/items/weapons/crowbar.lua:13: function arguments expected near 'then' 1. unknown - addons/pointshop-master/lua/pointshop/items/weapons/crowbar.lua:0 [/code] [/QUOTE] For future reference: When you get 'function arguments expected near' error, that means you used a function without setting it's arguments (ik this is obvious but still). This usually happens when people do something like [CODE]LocalPlayer:ConCommand[/CODE] when it should be [CODE]LocalPlayer():ConCommand[/CODE] Or [CODE]if ply:IsValid then[/CODE] when it should be [CODE]if ply:IsValid() then[/CODE] Sorry if this was unnecessary but a lot of new coders fall in these places, thought it might be useful
[QUOTE=Chimpanzee;48293205]Doubtful. I don't think the tubetrail uses a custom vtf or anything. You should just remove solely the tube trail if you want the rest[/QUOTE] Well, this thread isn't even about the tube trail. I still haven't been able to find a solution as to why my code doesn't work, and why it doesn't change the material of the crowbar. The path and all is correct, yet it still doesn't work.
Yes I know, but you brought up the tube trail error so I reverted my attention to that to get that out of the way. With the crowbar, just copy paste the crowbar lua file and change the ViewModel and call it ttt_lightsaber.lua or some shit, then make a pointshop file for it. In the OnEquip, call to check to see if they have the crowbar, and if they do remove it, then give them the lightsaber(the opposite in holster), then so on and so forth
Sorry, you need to Log In to post a reply to this thread.