ItsMods

Full Version: Emission code, everyone times out?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
doEmission(); is executed somewhere on the code. level.emissionincoming = false; is put under init();

Code:
doEmission()
{
    level endon("emission_cancel");
    level endon("emission_end");
    if(level.emissionincoming) return 0;
    level.emissionIncoming = true;

    level thread emissionEarthquake();

    currentEmissionClock = 0;
    emissionTimer = spawn("script_origin", (0,0,0));
    emissionTimer hide();
    while(currentEmissionClock != 10)
    {
        currentEmissionClock += 1;
        emissionTimer playSound("ui_mp_nukebomb_timer");
        if(currentEmissionClock <= 5) wait(5);
        else wait(1);
    }

    level.emissionIncoming = false;
    level.emissionInProgress = true;
    earthquake(0.25, 12, (0, -2500, 0), 100000);
    emissionTimer playSound("nuke_wave");
    //setDvar("r_todoverride","2 1.3 0.8");
    wait 2;
    foreach(player in level.players)
    {
        player thread radiationEffect();
    }
    wait 6;
    level.emissionInProgress = false;
    wait 2;
    level notify("radiation_stop");
    level notify("emission_end");
    emissionTimer destroy();
}

emissionEarthquake()
{
    level endon("emission_cancel");
    level endon("emission_end");
    while(level.emissionIncoming)
    {
        wait randomint(10);
        duration = (randomint(9) + 1);
        intensity = (randomint(5)/20);
        emissionEnt = getEntArray("mp_global_intermission", "classname");
        earthquake(intensity, duration, emissionEnt[0].origin, 100000);
        wait duration;
    }
}

radiationEffect()
{
    self.poison = 0;
    
    while(1)
    {
        if(self.issafe) continue;
        if(!isAlive(self)) continue;
        if(!level.emissioninprogress) continue;
        self.radiation ++;
        if(self.radiation == 1) {
            self ViewKick(1, self.origin);
        } else if(self.radiation == 3) {
            self shellshock("mp_radiation_low", 4);
            self ViewKick(3, self.origin);
            self doRadiationDamage(15);
        } else if(self.radiation == 4) {
            self shellshock("mp_radiation_med", 5);
            self ViewKick(15, self.origin);
            self doRadiationDamage(25);
        } else if(self.radiation == 5) {
            self shellshock("mp_radiation_high", 5);
            self ViewKick(75, self.origin);
            self doRadiationDamage(45);
        } else if(self.radiation == 6) {
            self shellshock("mp_radiation_high", 5);
            self ViewKick(127, self.origin);
            self doRadiationDamage(175);
        }
        wait(1);
    }
    wait(5);
}

doRadiationdamage(iDamage)
{
    self thread [[ level.callbackPlayerDamage ]](self,self,iDamage,0,"MOD_SUICIDE","claymore_mp",self.origin,(0,0,0) - self.origin,"none",0);
}

When the large earthquake and the sound are due to start, everyone times out except for me. This is a dedicated server.

Please only post the part of this code which needs to be fixed, and not the entire code.

thanks
lol spammer??
(01-06-2012, 17:03)alvarogt95 Wrote: [ -> ]lol spammer??

yes you are a spammer. please don't reply unless you got something useful Smile
I dont know the reason, but you should destroy the loop you make on here(after some time): radiationEffect()
(01-07-2012, 11:56)Yamato Wrote: [ -> ]I dont know the reason, but you should destroy the loop you make on here(after some time): radiationEffect()

I found the problem. It was not in that function, but it was the continue;. Continue does not stop the while, it simply tells it to go to the top and that is why it was crashing.

thanks
(01-07-2012, 14:58)xplosiff Wrote: [ -> ]
(01-07-2012, 11:56)Yamato Wrote: [ -> ]I dont know the reason, but you should destroy the loop you make on here(after some time): radiationEffect()

I found the problem. It was not in that function, but it was the continue;. Continue does not stop the while, it simply tells it to go to the top and that is why it was crashing.

thanks

To stop the loop: break;

Continue works similar to a return.
Code:
function(derp)
{
    for(i=0;i<20;i++)
    {
        doStuff1();
        if(i==5) { continue; } //This will skip the rest of the loop and increase I by 1. (So when i=5 stuff2 and stuff3 don't happen, but with every other number it does
        doStuff2();

        doStuff3();
    }
    //Using a break; in the loop will end up here (it exits the loop)
    doEvenMoreStuff();
    //using a return; in the loop will end up here (end of function, it exits the function)
}