ItsMods

Full Version: Bar Stopped Updating
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Either it's magic or I have memory problems, the bar stopped working

init
Code:
init()
{
level.captureBarValue = 0;
}

map = getDvar("mapname");
    switch(map)
    {
        case "mp_array":
            thread captureObjectiveArray((-95, 933, 353));

captureObjectiveArray
Code:
captureObjectiveArray(org)
{
    level endon("game_ended");

    rad = 120;
        
    while(1)
    {
        for ( i = 0; i < level.players.size; i++ )
        {
            player = level.players[i];
            dis = distance(player.origin, org);
            if(dis < rad)
            {
                if(player.pers["team"] == "axis")
                    level.captureBarValue++;
                else if(player.pers["team"] == "allies")
                {
                    if(level.captureBarValue >= 0)
                        level.captureBarValue--;
                }
                wait 1;
            }
        }
        if(level.captureBarValue == 100)
        {
            thread maps\mp\gametypes\_globallogic::endGame( "axis", "Satellite-C3 was captured" );
        }
      wait .1;
    }
}

and the bar updating:
Code:
updateCustomBar()
{
    self endon("disconnect");
    v = createPrimaryProgressBar( -300 );
    v.bar.horzAlign = "LEFT";
    v.bar.vertAlign = "MIDDLE";
    v.bar.y = -100;
    v.bar.x = -410;
    v.y = -100;
    v.x = -350;
        
    while(1)
    {
        v.bar updateBar(level.captureBarValue/100); //even v updateBar(level.captureBarValue/100); fail
        v.bar.color=(0,0,1);    
      wait .1;
    }
}

Code:
onPlayerSpawned()
{
    self endon("disconnect");

    self thread showWelcomeMessage();
    self thread updateCustomBar();
    for(;;)
    {

WHY
ist updateCustomBar supposed to be in the for loop @ OnPlayerSpawned?
No, why?
(04-06-2011, 16:54)4FunPlayin Wrote: [ -> ]No, why?

I'm not sure .. but if you want to let it update it needs to be in a for() loop ..
It is in a loop
while(1)
{
v.bar updateBar(level.captureBarValue/100); //even v updateBar(level.captureBarValue/100); fail
v.bar.color=(0,0,1);
wait .1;
}
Increase the loop wait time.
I tried 0.5 and then I tried 0.9, but still nothing Sad
are you on the right team?

Code:
if(player.pers["team"] == "axis")
                    level.captureBarValue++;
                else if(player.pers["team"] == "allies")
                {
                    if(level.captureBarValue >= 0)
                        level.captureBarValue--;
                }

that^^ will only add percentage if ur on the axis team......

but if thats intended:
try making level.captureBarValue = 1; to start and see if the bar starts working from there

edit:
Code:
self thread updateCustomBar();
with the self this might be a problem but im not sure

Code:
v = createPrimaryProgressBar(...);
self.v = self createPrimaryProgressBar(...);

self.v.bar updateBar(...);
etc..
(04-06-2011, 21:42)[CoDBOMod]Nukem Wrote: [ -> ]are you on the right team?

Code:
if(player.pers["team"] == "axis")
                    level.captureBarValue++;
                else if(player.pers["team"] == "allies")
                {
                    if(level.captureBarValue >= 0)
                        level.captureBarValue--;
                }

that^^ will only add percentage if ur on the axis team......

but if thats intended:
try making level.captureBarValue = 1; to start and see if the bar starts working from there

edit:
Code:
self thread updateCustomBar();
with the self this might be a problem but im not sure

Code:
v = createPrimaryProgressBar(...);
self.v = self createPrimaryProgressBar(...);

self.v.bar updateBar(...);
etc..

I tried making level.captureBarValue = 50 and nothing, and yes I'm on the right team, if you're on the allied team the bar value decreased, if you're on the axis team bar~increase

the "self updateCustomBar" isn't the problem, updateCustomBar is creating the bar itself for the player
Code:
updateCustomBar()
{
    self endon("disconnect");
    v = createPrimaryProgressBar( -300 );
    v.bar.horzAlign = "LEFT";
    v.bar.vertAlign = "MIDDLE";
    v.bar.y = -100;
    v.bar.x = -410;
    v.y = -100;
    v.x = -350;
        
    while(1)
    {
        v.bar updateBar(level.captureBarValue/100); //even v updateBar(level.captureBarValue/100); fail
        v.bar.color=(0,0,1);    
      wait .1;
    }
}