Yes I'm aware this has probably been posted dozens of time and its probably amateur. But I don't really care due to the fact that I've looked at all the posts I could find and even though it's "the most basic lua ever" it still doesn't work.
I'm trying to add custom sounds for players on my server when the use the Jihad (as the title implies). Currently I only have one sound added because I'm trying to get it work before I start barraging the server with more.
Here is the pointshop item code: (Idk how to make snippets for code with the black background so I'm just typing it in)
ITEM.Name = 'leeroy'
ITEM.Price = 5000
ITEM.Model = "models/Gibs/HGIBS.mdl"
function ITEM:OnEquip(ply)
ply.JihadTaunt = "taunts/taunt1.wav";
end
function ITEM:OnHolster(ply, mods)
ply.JihadTaunt = nil;
end
Here is the code I'm adding into the Jihad shared.lua in order for it to check for the item equipped and therefore replace the sound:
if (SERVER) then
timer.Simple(2, function() self:Asplode() end )
if self.Owner:PS_HasItemEquipped("leeroy") then
self.Owner:EmitSound("ttt/leeroy.wav")
else
self.Owner:EmitSound("siege/jihad,wav")
end
end
This code here when I add it into my Jihad shared.lua completely destroys the Jihad. I can't even spawn it with ULX when I replace the original function with this.
This is the code that I'm changing:
-- The rest is only done on the server
if (SERVER) then
timer.Simple(2, function() self:Asplode() end )
self.Owner:EmitSound( "ttt/leeroy.wav" )
end
end
Default is usually siege/jihad.wav or something similar(it's right above this I just was lazy and didn't look but it's right).
Here is a pastebin to the full Jihad code: [url]http://pastebin.com/7AwxYPa4[/url]
If anyone could tell me what I'm doing wrong that would be spectacular.
Change ply.Jihadtaunt to the actual sound you want the player to make, so in this case, do
[code]
function ITEM:OnEquip(ply)
ply.JihadTaunt = "ttt/leeroy.wav"
end
[/code]
The "taunt/taunt1.wav" was just a filler for what you should actually place there.
Since you're using ply.JihadTaunt, don't do "self.Owner:PS_HasItemEquipped(whatever)". Instead, replace it with "self.Owner.JihadTaunt" and set the EmitSound to self.Owner.JihadTaunt.
Also, the default code you have looks like there's one too many "end".
[QUOTE=PigeonTroll;48158938]Change ply.Jihadtaunt to the actual sound you want the player to make, so in this case, do
[code]
function ITEM:OnEquip(ply)
ply.JihadTaunt = "ttt/leeroy.wav"
end
[/code]
The "taunt/taunt1.wav" was just a filler for what you should actually place there.
Since you're using ply.JihadTaunt, don't do "self.Owner:PS_HasItemEquipped(whatever)". Instead, replace it with "self.Owner.JihadTaunt" and set the EmitSound to self.Owner.JihadTaunt.
Also, the default code you have looks like there's one too many "end".[/QUOTE]
Changed the pointshop file thank you.
But regarding to what you're telling me to change I'm not trying to change the taunt I just used that code as a filler (like you said) from a forum post so the pointshop item would start showing up but do nothing and just be there so I could use the function.
[code]
if (SERVER) then
timer.Simple(2, function() self:Asplode() end )
if self.Owner.JihadTaunt("ttt/leeroy") then
self.Owner:EmitSound("ttt/leeroy.wav")
else
self.Owner:EmitSound("siege/jihad,wav")
end
[/code]
Is this what you're saying I should put in there?
Sorry, you need to Log In to post a reply to this thread.