Bully-Board
Bully Modding Section => Script Modding => Topic started by: 3gtheepic on October 10, 2016, 11:37:04 AM
-
I was bored so I made this function you guys can use
function SetFightingMusicForPed(song,volume,ped)
if PedAttackPlayer(ped) then
SoundPlayStream(song, volume)
if PedIsDead(ped) or PedIsValid(ped) then
SoundStopStream()
end
Example of how you can use this function:
SetFightingMusicForPed('MS_FightingJohnnyVincentBossFight.rsm',1,norton)
This function is good for missions that roleplay as different characters
(ex. Norton as will smith)
-
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.
-
Thanks for pointing out the problems. I kinda knew that I didn't have the ends there I was just too lazy to edit them out.
I'm also working on a cool mission mod. I think it'll come out somewhere around halloween.
-
Sweet I'm excited to see it yo.