function SetFightingMusicForPed(song,volume,ped)
if PedAttackPlayer(ped) then
SoundPlayStream(song, volume)
if PedIsDead(ped) or PedIsValid(ped) then
SoundStopStream()
end
This function seems really broken but it's nice to see you're interested in making stuff like this.
Problem 1: You have 2 if statements and neither have an end (and if the last one has an end then the function doesn't have one). Remember every if statement needs to end with an end and so does every function, or of course you can use elseif to extend alternate conditions on it (still having an end after it all).
Problem 2: You do stuff with the ped before even checking if it is still valid, it'd be best to check if the ped is valid first.
SetFightingMusicForPed(song,volume,ped)
if not PedIsValid(ped) or PedIsDead(ped) then -- check if they are invalid or dead, if so stop the music
SoundStopStream()
elseif PedAttackPlayer(ped) then -- if the ped is valid, make them attack and set some music
SoundPlayStream(song, volume)
end
end
I think there are other problems with it but I'm not sure, maybe you found a new usage for the PedAttackPlayer function that I don't know of because it normally expects 2 arguments and is used for making a ped attack the player, but the way you use it here it looks as if you meant to check if the ped is attacking the player or not.
Anyways nice to see you share this, maybe we can see more useful shit in da future too, for anyone that can find a use for it.