What is it with people reading too fast these days?Drofder2004 wrote:small modification to the above...Firstly, remember this is an INFINITE LOOP, why would you want the engine to find the entity more than once if it isn't changing? Keep it outside the loop.Code: Select all
Secondly, Loops inside loops = infinite amounts of infinite loops.
Every time the loop went round, it created a NEW fx to play, after 1 minute passing you would have 6, eventually stacking to the point where your FPS would be shot and the server would crash.
The first script I posted is fine, the second one needs to be fixed, I agree, but you didn't follow the specifications I set in example 2.
Code: Select all
main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
level._effect["light"] = loadfx ("fx/light/light.efx"); //Load myLight effect from myFxFolder
lightOrigin thread lightsMove(); //Run moving light thread while sending assigned lightOrigin
}
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
trigger = getent ("lighttrigger","targetname");
trigger waittill ("trigger");
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
while(1)
{
wait(1);
self moveZ (-1000,1,0.5,0.5);
self waittill ("movedone");
wait(10);
self moveZ (1000,1,0.5,0.5);
self waittill ("movedone");
trigger waittill ("trigger");
}
}