Page 1 of 1

[ZSCRIPT] Dynamically change player soundclass

Posted: Fri Nov 09, 2018 3:37 pm
by TheGameratorT
I don't know if this is possible yet but every time I do this it throws out an error:

Code:

Code: Select all

TNT1 A 0 { Player.SoundClass = "billplayer"; }
Error:

Code: Select all

Script error, "FNAF_Core.pk3:zscript.txt" line 48:
Unknown identifier 'SoundClass'
I also tried with PlayerPawn.SoundClass instead of Player.SoundClass but it says that it isn't possible to change the context:

Code: Select all

Script error, "FNAF_Core.pk3:zscript.txt" line 48:
Unable to access 'PlayerPawn.SoundClass' in a static context
Anyone knows why this throws out errors? I have searched for about an hour and I still can't find a solution.

:|

Re: [ZSCRIPT] Dynamically change player soundclass

Posted: Fri Nov 09, 2018 4:57 pm
by Blue Shadow
Where are you calling that code from, from what actor class? SoundClass is a field of the PlayerPawn class and derivatives only.

Re: [ZSCRIPT] Dynamically change player soundclass

Posted: Sat Nov 10, 2018 1:26 am
by Player701
Your code doesn't work because "Player" is a reference to the Actor.Player field, which is of type PlayerInfo, not PlayerPawn.

If you're calling this code from a PlayerPawn (i.e. your player class), then remove the "Player." part.

If you're calling it from a CustomInventory or a Weapon, then you need to cast "self" to PlayerPawn like this:

Code: Select all

let pp = PlayerPawn(self);
if (pp)
{
    pp.SoundClass = "billplayer";
}

Re: [ZSCRIPT] Dynamically change player soundclass

Posted: Sat Nov 10, 2018 5:53 am
by TheGameratorT
Thanks for the help, I didn't knew it was as simple as removing the "Player." part. :)