[ZSCRIPT] Dynamically change player soundclass

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ZSCRIPT] Dynamically change player soundclass

Re: [ZSCRIPT] Dynamically change player soundclass

by TheGameratorT » Sat Nov 10, 2018 5:53 am

Thanks for the help, I didn't knew it was as simple as removing the "Player." part. :)

Re: [ZSCRIPT] Dynamically change player soundclass

by Player701 » Sat Nov 10, 2018 1:26 am

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

by Blue Shadow » Fri Nov 09, 2018 4:57 pm

Where are you calling that code from, from what actor class? SoundClass is a field of the PlayerPawn class and derivatives only.

[ZSCRIPT] Dynamically change player soundclass

by TheGameratorT » Fri Nov 09, 2018 3:37 pm

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.

:|

Top