UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: alaurenc9 on October 27, 2015, 09:45:24 pm

Title: Easy Client Scripted FX/Sound
Post by: alaurenc9 on October 27, 2015, 09:45:24 pm
Hi guys, welcome to a unique release that I hope people find interest in.
Today I am releasing my ClientScripted Fx System.
This allows you to play fx and sound in client scripts easily from GSC.
This system has also been used in WARDOGSK93's Perk System.

MEGA:
mega.nz

MediaFire:
www.mediafire.com

This system allows you to use basic functions in GSC to play sounds and fx in CSC.
CSC has easily proven itself to be better for playing sound and fx for reasons like
it saves g_spawn space, fx runs at client speed, and it can be only heard/seen by
a specific targetted player.

Init The Scripts:

Open maps\_zombiemode.gsc
in the top function main()
underneath this:
Code Snippet
Plaintext
maps\_zombiemode_auto_turret::init();
add this:
Code Snippet
Plaintext
maps\_xS78_fx_system::init();
Save & Close.
Now go into clientscripts\{MAPNAME}.csc
in the top function main()
underneath this:
Code Snippet
Plaintext
clientscripts\_load::main();
add this:
Code Snippet
Plaintext
clientscripts\_xS78_fx_system::init();
Save & Close.

Learn The Functions:

Function: create_loop_fx_to_player( player, identifier, fx_var, origin, angles )
What It Does: play's an fx that can be saved and destroyed later
Arguments: player - the player who sees the fx played
      identifier - string to identfy the fx. you can only play one fx on
         the same identifier. trying to play another fx on an
         already used identifier will result in nothing happening.
      you can use the same identifier for two different players.
      fx_var - the key used to identify the fx to be played. whatever key you
      use in the array of level._effect is what you put in here.
      Make sure all fx is loaded in GSC and CSC with the same key.
      origin - the origin of the fx
      angles - the angles of the fx. if you don't have specific angles, put ( 0, 0, 0 )

Function: destroy_loop_fx_to_player( player, identifier )
What It Does: destroy's a loop fx created based on the identifier
Arguments: player - the player who sees the fx played
      identifier - string to identify the fx in order to destroy it.
      once destroyed, this identity is cleared and can be re-used.
      trying to destroy an fx on an identity that doesn't exist
      results in nothing happening.

Function: play_oneshot_fx_to_player( player, fx_var, origin, angles )
What It Does: play's an fx that is not saved so it cannot be destroyed.
Arguments: player - the player who sees the fx played
      fx_var - the key used to identify the fx to be played. whatever key you
      use in the array of level._effect is what you put in here.
      Make sure all fx is loaded in GSC and CSC with the same key.
      origin - the origin of the fx
      angles - the angles of the fx. if you don't have specific angles, put ( 0, 0, 0 )

Function: create_loop_sound_to_player( player, identifier, alias, origin, fade_time )
What It Does: play's a loop sound that is saved and can be stopped later.
Arguments: player - the player who hears the sound played
      identifier - string to identfy the sound. you can only play one
      sound on the same identifier. trying to play another sound on
      an already used identifier will result in nothing happening.
      you can use the same identifier for two different players.
      alias - the alias name of the sound to play
      origin - the origin of the sound
      fade_time - the fade in time of the loop sound. if you don't want a fade in, put 0.

Function: destroy_loop_sound_to_player( player, identifier, fade_time )
What It Does: destroy's a loop sound created based on the identifier
Arguments: player - the player who hears the sound played
      identifier - string to identify the sound in order to destroy it.
      once destroyed, this identity is cleared and can be re-used.
      trying to destroy an sound on an identity that doesn't exist
      results in nothing happening.
      fade_time - the fade out time of the loop sound. if you don't want a fade out, put 0.

Function: play_oneshot_sound_to_player( player, alias, origin )
What It Does: play's a one shot sound at a position
Arguments: player - the player who hears the sound played
      alias - the alias name of the sound to play
      origin - the origin of the sound

WARNINGS:
   1. This system registers a Client System. World at War is limited to only 8
      client systems max being registered, and 7 are taken up by default. So if you
      have a custom client system of your own registered and you didn't de-register
      any other's already in world at war, this wont work because you are hitting
      the limit. There are some unused systems I'm sure you can safely unregister to
      make room, but I haven't looked into this myself. Otherwise, you should be good.

   2. This system has absolutely NO failsafes put in, so everything must be done correctly.
      Remember to follow all the steps and make sure you put in each argument for the
      functions used correctly. Make sure that nothing 'undefined' ever gets put in.
      As long as everything is correct, you should experience no error's.

This script was 100% created by me, and took alot
of time and effort to get right, so make sure to credit me.
If there is anything else that should be added to
the system, let me know. Thanks and Peace.
Title: Re: Easy Client Scripted FX/Sound
Post by: fiveseven hd on October 29, 2015, 07:47:01 am
i really like the idea of this, unfortunately I dont quite understand how to set this up. I understand and really like how you explain each fucntion. I just dont know what I need to do in radiant/set up for the scripting part.  Im trying to learn this whole scripting thing as best I can on my own but its hard as shit. When I progress a bit more i'll def come back to this tho. Looks pretty amazing man.
Title: Re: Easy Client Scripted FX/Sound
Post by: DeletedUser on October 29, 2015, 08:39:03 am
i really like the idea of this, unfortunately I dont quite understand how to set this up. I understand and really like how you explain each fucntion. I just dont know what I need to do in radiant/set up for the scripting part.  Im trying to learn this whole scripting thing as best I can on my own but its hard as shit. When I progress a bit more i'll def come back to this tho. Looks pretty amazing man.
you dont need to do anything in Raiant for this you just call 2 init functions after that you just call the functions explained above to do things (fx / sounds) per player

Code Snippet
Plaintext
// Called in maps\_zombiemode::main() after maps\_zombiemode_auto_turret::init()
maps\_xS78_fx_system::init();

// Called in clientscripts\{MAPNAME}::main() after clientscripts\_load::main()
clientscripts\_xS78_fx_system::init();

EDIT:

Just note that if you want to playFx using this you need to load the fx both in GSC and CSC
Title: Re: Easy Client Scripted FX/Sound
Post by: alaurenc9 on October 30, 2015, 10:47:10 pm
Fixed loop sounds not being able to fade out. Before, even if you added a fade out time greater than 0, it would just stop immediately. now its fixed.
Title: Re: Easy Client Scripted FX/Sound
Post by: fiveseven hd on October 31, 2015, 06:36:09 am
I was actually looking for somthing like this...great job man. Im playing around with it right now .
Title: Re: Easy Client Scripted FX/Sound
Post by: alaurenc9 on October 31, 2015, 07:30:39 pm
I was actually looking for somthing like this...great job man. Im playing around with it right now .

thank you very much.

i have re-updated this post now with 100% confirmed and working loop sound fade out.
Title: Re: Easy Client Scripted FX/Sound
Post by: jei9363 on November 09, 2015, 11:05:51 am
what did i do wrong?

Code Snippet
Plaintext
maps\_xS78_fx_system::create_loop_fx_to_player(players[i], "snow" + players[i].entity_num, "snow_thick", players[i].origin, (0,0,0));

Code Snippet
Plaintext
level._effect["snow_thick"]	= LoadFx( "env/weather/fx_snow_blizzard_intense" );

is in both gsc and csc

and i have


Code Snippet
Plaintext
fx,env/weather/fx_snow_blizzard_intense

Double Post Merge: November 09, 2015, 11:20:55 am
also tried

maps\_xS78_fx_system::play_oneshot_fx_to_player(self, "snow_thick", self.origin, (0,0,0));

Double Post Merge: November 09, 2015, 11:33:06 am
nevermind, lol wasnt even calling the function.. need to go to bed

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2F3av3mgF.jpg&hash=71872d65a1507ea8a1e8fce327bc9676aca60048)

just gotta change to rain :)
Title: Re: Easy Client Scripted FX/Sound
Post by: alaurenc9 on November 09, 2015, 10:39:21 pm
what did i do wrong?

Code Snippet
Plaintext
maps\_xS78_fx_system::create_loop_fx_to_player(players[i], "snow" + players[i].entity_num, "snow_thick", players[i].origin, (0,0,0));

Code Snippet
Plaintext
level._effect["snow_thick"]	= LoadFx( "env/weather/fx_snow_blizzard_intense" );

is in both gsc and csc

and i have


Code Snippet
Plaintext
fx,env/weather/fx_snow_blizzard_intense

Double Post Merge: November 09, 2015, 11:20:55 am
also tried

maps\_xS78_fx_system::play_oneshot_fx_to_player(self, "snow_thick", self.origin, (0,0,0));

Double Post Merge: November 09, 2015, 11:33:06 am
nevermind, lol wasnt even calling the function.. need to go to bed

(http://i.imgur.com/3av3mgF.jpg)

just gotta change to rain :)

So this works 100% for you now?
Title: Re: Easy Client Scripted FX/Sound
Post by: jei9363 on November 09, 2015, 11:03:41 pm
yeah sorry, i was sleepy. works fine. not going to use it for rain, but will probably for snow in the future because right now the UGX snow I dont think uses this so you probably get a lot of snow with 4 players
Title: Re: Easy Client Scripted FX/Sound
Post by: alaurenc9 on November 18, 2015, 10:49:43 pm
- Updated

The CSC was made neater, and it no longer spawns structs to save everything.