Announcement
Collapse
No announcement yet.
Controller Class --> is Player ?
Collapse
X
-
Originally posted by Grzech
http://www.ataricommunity.com/forums...hreadid=386389
"I want to play sound from my mutator. I want it to be heard by every player (not localized sound)"
--
for that hud thing, i tried:
Code:class DeathRatioHUD extends ChallengeHUD; function PostRender(canvas C) { Super.PostRender(C); C.SetPos( 0, Canvas.ClipY/2 ); C.DrawColor.R = 255; C.DrawColor.G = 0; C.DrawColor.B = 0; C.Font = MyFonts.GetBigFont( C.ClipX ); C.DrawText( PlayerOwner.PlayerReplicationInfo.GetSpree(), False ); }
Code:Analyzing... Superclass ChallengeHUD of class DeathRatioHUD not found History: UMakeCommandlet::Main Exiting due to error
Comment
-
To play a sound to just one player try this:
Code:PlayerController( killer ).ClientReliablePlaySound( Sound'MyCustomSound' );
Importing a custom sound can be done in this way:
Code:#exec AUDIO IMPORT FILE="Sounds\Whatever.wav" NAME="MyCustomSound"
Comment
-
Originally posted by the Adster
To play a sound to just one player try this:
Code:PlayerController( killer ).ClientReliablePlaySound( Sound'MyCustomSound' );
Importing a custom sound can be done in this way:
Code:#exec AUDIO IMPORT FILE="Sounds\Whatever.wav" NAME="MyCustomSound"
Comment
-
umm kay. i want to do something slighty different now.
what i want is that if your team scores a frag ( being it a bot from your team or a human player from your team), everyone from that team should hear a sound.
i tried like this:
Code:class TeamGameFragsoundClass extends GameRules; function ScoreKill(Controller Killer, Controller Killed) { local Controller p; if ( !Killer.SameTeamAs(Killed) ) { for( p = Level.ControllerList; p != None; p = p.nextController ) { if( p.IsA( 'PlayerController' ) ) { if ( PlayerController(p).sameteamas(PlayerController(Killer))) { PlayerController(p).ClientReliablePlaySound(Sound'scorefrag'); } } } } if ( NextGameRules != None ) NextGameRules.ScoreKill(Killer,Killed); }
"MutTeamGameFragsound accessed 'None' Killer" ?
( being playing with bots when this occours + it works and not display that when i make a frag myself. so maybe the code above is not realy compatible with bots ? )
thx
Comment
-
Originally posted by Grzech
surely it isn't. what do you cast that poor killer to playercontroller for?
get rid of that and it will work.
Code:class TeamGameFragsoundClass extends GameRules; function ScoreKill(Controller Killer, Controller Killed) { if ( !Killer.SameTeamAs(Killed) ) { log("someone killed someone else"); } if ( NextGameRules != None ) NextGameRules.ScoreKill(Killer,Killed); }
Comment
-
This code come from one of my projects (modified to your needs):
Code:if( ( killed != killer ) && ( killer.PlayerReplicationInfo != None ) && ( killed.PlayerReplicationInfo != None ) && ( killed.PlayerReplicationInfo.Team != killed.PlayerReplicationInfo.Team ) && ( killed != None ) )
Comment
-
Originally posted by the Adster
This code come from one of my projects (modified to your needs):
Code:if( ( killed != killer ) && ( killer.PlayerReplicationInfo != None ) && ( killed.PlayerReplicationInfo != None ) && ( killed.PlayerReplicationInfo.Team != killed.PlayerReplicationInfo.Team ) && ( killed != None ) )
Comment
-
Originally posted by GuntiNDDS
doesnt playerreplicationinfo only work with human players ?
Comment
-
Originally posted by the Adster
Err, no, it works for all Controller types; how do you think CTF flags are attached to non-human players?. Why not spend the rest of the afternoon having a good look round all the standard classes you have on your machine? You may be surprised by what you find out.
Comment
-
ok. well, it works now.
my first code were indeed working, but the error i made was that in the other .uc file that extends the mutator class, i put a reference to my older Mutator ( eg MutFragSoundClass) instead of MutTeamGameFragsoundClass. now this being fixed it works wonderfull.
thanks to everyone contributing to this thread / problem.
Comment
Comment