UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Adding FX to a spawned weapon

broken avatar :(
Created 8 years ago
by lvlagiick
0 Members and 1 Guest are viewing this topic.
3,433 views
broken avatar :(
×
broken avatar :(
Location: nlNL
Date Registered: 3 October 2016
Last active: 8 years ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
lvlagiick's Groups
lvlagiick's Contact & Social Links
Hi there,

I spawned some weapons on the ground through GSC. Problem is that the weapons are hard to spot on the floor. Is there a way to add something like a lightbeam to the weapon? I found PlayFX, but how do I use it and how do I precache fx's?

Thanks in advance!

Ps. I'd love to use Pandora's Box's light! :)
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: au
Date Registered: 27 February 2014
Last active: 7 years ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
harveyconnor's Groups
harveyconnor's Contact & Social Links
Look in the entity browser, or even misc/prefabs (in entity browser) could have some stuff to use.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Precaching fx is simple. Add this to the top of your script under the #using lines.
Code Snippet
Plaintext
#precache("fx", "pathtofx");

then add this to your main/init function
Code Snippet
Plaintext
level._effect["whatevernameyouwant"] = "pathtofx";

an example would be this:
Code Snippet
Plaintext
#using scripts\zm\_zm;

#precache( "fx", "electric/fx_elec_sparks_directional_orange" );

function init()
{

    level._effect["whatevernameyouwant"] = "electric/fx_elec_sparks_directional_orange";

    trig = GetEnt("test_trigger", "targetname");

    PlayFX(level._effect["whatevernameyouwant"], trig.origin);
}

All FX can be found here:
root/raw/fx

If you want the FX to stay on the object make sure the FX is a looping FX otherwise it will only appear once.

I can explain how to setup a PlayFX with your model if you are still unsure what to do.
Last Edit: October 05, 2016, 06:21:57 am by reckfullies
broken avatar :(
×
broken avatar :(
Location: nlNL
Date Registered: 3 October 2016
Last active: 8 years ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
lvlagiick's Groups
lvlagiick's Contact & Social Links
Thanks for all the information! This is quite helpful!

I've got one little problem that should be easily fixed thou. I create the weapons in another function called SpawnRandomWeapons(). How would I take the weapon' container inside SpawnRandomWeapons() to use in my main or should I move the PlayFX loop to the SpawnRandomWeapons() function?

Thanks in advance
broken avatar :(
×
broken avatar :(
Location: nlNL
Date Registered: 3 October 2016
Last active: 8 years ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
lvlagiick's Groups
lvlagiick's Contact & Social Links
Uh oh. I tried adding PlayFX to the spawning function of weapons and I got a G_Spawn no free entities error..
Marked as best answer by lvlagiick 8 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Uh oh. I tried adding PlayFX to the spawning function of weapons and I got a G_Spawn no free entities error..

Probably spawned a ton of fx then, just make a new function like this:
Code Snippet
Plaintext
function randomweaponspawning()
{
    // Whatever code you already had here
    thread spawnFX(weapon);
}

function spawnFX(weapon)
{
    PlayFX(level._effect["fxname"], weapon.origin);
}

weapon would be like the variable where you define which weapon you want to spawn which I assume you are already doing, it should look like this for example:
Code Snippet
Plaintext
weapon = GetWeapon("weapon you are using");

 
Loading ...