Hello,
I am trying to create a simple mutator that takes a wav file and plays the sound byte when a user types a certain word in the chat. For example when a player types "hello" in chat it plays a sound byte.
I'm importing my wav file like this:
#exec AUDIO IMPORT FILE="Sounds\hi_0.wav" NAME="hi_0" GROUP="Taunts"
But i can't figure out how to actually get it to play when the user types "hi" or "hello". I'm new to unreal script and I have searched all over the internet for assistance but nothing that I can find that relates to this. I know this is possible, I have the MOZMessages mutator but I'm trying to create my own sounds.
Any help is greatly appreciated. Thanks so much!
Creating message mutator
-
- Godlike
- Posts: 3776
- Joined: Fri Jan 14, 2011 1:53 pm
- Personal rank: -Retired-
Re: Creating message mutator
Post over at House of Fool's forum: https://hofgamingclan.com/forums/
The head guy there is a voice pack fanatic and they use 'zounds' type sound mods on their servers. I wouldn't be surprised if they weren't written by him.
The head guy there is a voice pack fanatic and they use 'zounds' type sound mods on their servers. I wouldn't be surprised if they weren't written by him.
So long, and thanks for all the fish
-
- Godlike
- Posts: 1205
- Joined: Mon Aug 31, 2015 10:31 pm
Re: Creating message mutator
You just have to create a mutator class that listens to messages by registering it as a MessageMutator, GameInfo.uc contains this function "RegisterMessageMutator(Mutator M)", call it from the mutator in PostBeginPlay() using "self" as parameter. Then, everytime a player chats, one or more of these callbacks will be called: "MutatorTeamMessage(...)"/"MutatorBroadcastMessage(...)"/"MutatorBroadcastLocalizedMessage(...)", which are functions in Mutator.uc that you just need to redefine (also remember to add super.NameOfTheFunction(...).piazon79 wrote:Hello,
I am trying to create a simple mutator that takes a wav file and plays the sound byte when a user types a certain word in the chat. For example when a player types "hello" in chat it plays a sound byte.
I'm importing my wav file like this:
#exec AUDIO IMPORT FILE="Sounds\hi_0.wav" NAME="hi_0" GROUP="Taunts"
But i can't figure out how to actually get it to play when the user types "hi" or "hello". I'm new to unreal script and I have searched all over the internet for assistance but nothing that I can find that relates to this. I know this is possible, I have the MOZMessages mutator but I'm trying to create my own sounds.
Any help is greatly appreciated. Thanks so much!
Since you have the hi_0 file, do a check on the string and if the string contains "hello" (you can check it by using InStr) use a "for" on Level.PawnList, check if the pawn is a PlayerPawn and then play the sound as playerPawn.ClientPlaySound(...) (which is a function in PlayerPawn.uc).
Maybe there's a way to broadcast a sound but I'm not sure how.
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
-
- Novice
- Posts: 3
- Joined: Fri Apr 05, 2019 6:31 pm
Re: Creating message mutator
Thanks for the suggestions! I'll give this a try, may take me a while to figure it out since im newer to unreal script but i really appreciate the help!
-
- Godlike
- Posts: 1205
- Joined: Mon Aug 31, 2015 10:31 pm
Re: Creating message mutator
Something like this:piazon79 wrote:Thanks for the suggestions! I'll give this a try, may take me a while to figure it out since im newer to unreal script but i really appreciate the help!
Code: Select all
class CustomMutator extends Mutator;
event PostBeginPlay() {
Level.Game.RegisterMessageMutator(self);
}
function bool MutatorBroadcastMessage(Actor Sender, Pawn Receiver, out coerce string Msg, optional bool bBeep, out optional name Type) {
//Should check if (Sender.isA('PlayerPawn')) ?
if (inStr(Msg, "hello") != -1) {
for (pawn = level.pawnList; (pawn != None) && (pawn.isA('PlayerPawn')); pawn = pawn.nextPawn) {
pawn.ClientPlaySound(SOUND_GOES_HERE);
}
}
}
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
-
- Godlike
- Posts: 2995
- Joined: Fri Sep 25, 2015 9:01 pm
- Location: moved without proper hashing
Re: Creating message mutator
Because second argument of the for-loop is the loop condition and not every pawn in level.pawnList is a PlayerPawn, that loop will not iterate over all items in the list necessarily.PrinceOfFunky wrote:Code: Select all
for (pawn = level.pawnList; (pawn != None) && (pawn.isA('PlayerPawn')); pawn = pawn.nextPawn) { pawn.ClientPlaySound(SOUND_GOES_HERE); }
Better use something like this:
Code: Select all
for (pawn = level.pawnList; pawn != None; pawn = pawn.nextPawn)
if (PlayerPawn(pawn) != None)
PlayerPawn(pawn).ClientPlaySound(SOUND_GOES_HERE);
"If Origin not in center it be not in center." --Buggie
-
- Novice
- Posts: 3
- Joined: Fri Apr 05, 2019 6:31 pm
Re: Creating message mutator
Awesome! I'll try this out. Questions though, where does it check for what the playing is typing in order to play the sound? Like typing "hello" in chat will play that sound?
-
- Godlike
- Posts: 2995
- Joined: Fri Sep 25, 2015 9:01 pm
- Location: moved without proper hashing
Re: Creating message mutator
piazon79 wrote:where does it check for what the playing is typing in order to play the sound?
Code: Select all
if (inStr(Msg, "hello") != -1)
Close - typing it is not enough, the player has to send the text (press Enter) also. Also notice that "inStr" compares case sensitive .piazon79 wrote:Like typing "hello" in chat will play that sound?
"If Origin not in center it be not in center." --Buggie
-
- Godlike
- Posts: 1205
- Joined: Mon Aug 31, 2015 10:31 pm
Re: Creating message mutator
You're right, it's been a long time that I don't code in unrealscript anymore .Barbie wrote:Because second argument of the for-loop is the loop condition and not every pawn in level.pawnList is a PlayerPawn, that loop will not iterate over all items in the list necessarily.PrinceOfFunky wrote:Code: Select all
for (pawn = level.pawnList; (pawn != None) && (pawn.isA('PlayerPawn')); pawn = pawn.nextPawn) { pawn.ClientPlaySound(SOUND_GOES_HERE); }
Better use something like this:Code: Select all
for (pawn = level.pawnList; pawn != None; pawn = pawn.nextPawn) if (PlayerPawn(pawn) != None) PlayerPawn(pawn).ClientPlaySound(SOUND_GOES_HERE);
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2