Page 1 of 1

Map restart

Posted: March 2nd, 2013, 8:08 pm
by darkpheonixz4x
Hey guys,

i was making a plugin for promod (as it had a .gsc file to add custom functions, like codjumper). I added a toggle fullbright script and it works great!

My problem is that this only works when the server does /fast_restart. It does not load up the function when i try /map_restart or when it actually rotates the map automatically.

Any suggestions/fixes?

Thanks,
darkpheonixz4x

Re: Map restart

Posted: March 2nd, 2013, 8:22 pm
by F |Madness| U
Sounds like you're calling the function too late in the script, which would explain why it works on fast_restart when the map stays the same. Can't really offer any more help without knowing where your script is and such.

Re: Map restart

Posted: March 2nd, 2013, 11:32 pm
by Drofder2004
Start by posting the script, maybe?

Re: Map restart

Posted: March 3rd, 2013, 5:11 am
by darkpheonixz4x
This part is in the _rank.gsc. onJoinedTeam, onJoinedSpectators and onPlayerSpawned is threaded by onPlayerConnect().

Code: Select all

onJoinedTeam()
{
        self endon("disconnect");
 
        for(;;)
        while(1)
        {
            
                self waittill("joined_team");
                self thread removeRankHUD();
                self iPrintlnBold("^2Press your ^1FRAG ^2and ^1USE ^2key TOGETHER to toggle ^7fullbright");
        }
}
 
 
onJoinedSpectators()
{
        self endon("disconnect");
 
        for(;;)
        {
                self waittill("joined_spectators");
                self thread removeRankHUD();
        }
}
          
 
onPlayerSpawned()
{
        self endon("disconnect");
 
        for(;;)
        while(1)
        {
                self waittill("spawned_player");
                self thread fullbrighttoggle();
 
                if(!isdefined(self.hud_rankscroreupdate))
                {
                        self.hud_rankscroreupdate = newClientHudElem(self);
                        self.hud_rankscroreupdate.horzAlign = "center";
                        self.hud_rankscroreupdate.vertAlign = "middle";
                        self.hud_rankscroreupdate.alignX = "center";
                        self.hud_rankscroreupdate.alignY = "middle";
                        self.hud_rankscroreupdate.x = 0;
                        self.hud_rankscroreupdate.y = -60;
                        self.hud_rankscroreupdate.font = "default";
                        self.hud_rankscroreupdate.fontscale = 2.0;
                        self.hud_rankscroreupdate.archived = false;
                        self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
                        self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
                }
        }
}
and the fullbright toggle script:

Code: Select all

FullbrightToggle() 
{
        self endon( "disconnect" );
        
        fullbright = false;
        
        while( 1 ) {
                
                wait( 0.05 );
        
                 if( self usebuttonpressed() && self fragbuttonpressed() )
 {
                        
                        
                        if( fullbright )
                                fullbright = false;
                        else
                                fullbright = true;
                        
                        
                        setFullbright( fullbright );
                        
                        
                        while( self usebuttonpressed() && self fragbuttonpressed() )
                                wait( 0.05 );
                
                }       
        }
}
 
 
setFullbright( toggle ) {
 
        
        if( toggle )
                self setClientDvar( "r_fullbright", 1 );
 
        else
                self setClientDvar( "r_fullbright", 0 );
 
}

Re: Map restart

Posted: March 3rd, 2013, 9:52 am
by Drofder2004
You said there was a gsc file to add your own commands, is that file 'rank' or is there another file?

There are no problems with the code from what I can see, and if there are no other files in the tree, then there is opssibly a load order in the core of promod that does this.

edit:

Noticed this in script, blank loop. (line 5 and line 32)

Code: Select all

 for(;;)
Not sure what it is doing there, but it certainly isn't helping.

Re: Map restart

Posted: March 3rd, 2013, 11:16 am
by darkpheonixz4x
Yes its the _rank.gsc

Re: Map restart

Posted: March 3rd, 2013, 9:51 pm
by Drofder2004
did you try deleting the pointless "for loops".

Re: Map restart

Posted: March 4th, 2013, 1:16 pm
by darkpheonixz4x
Yep, here's the updated script.

Code: Select all

onJoinedTeam()
{
        self endon("disconnect");
 
       
        while(1)
        {
           
                self waittill("joined_team");
                self thread removeRankHUD();
                self iPrintlnBold("^2Press your ^1FRAG ^2and ^1USE ^2key TOGETHER to toggle ^7fullbright");
        }
}
 
 
onJoinedSpectators()
{
        self endon("disconnect");
 
        for(;;)
        {
                self waittill("joined_spectators");
                self thread removeRankHUD();
        }
}
         
 
onPlayerSpawned()
{
        self endon("disconnect");
 
       
        while(1)
        {
                self waittill("spawned_player");
                self thread fullbrighttoggle();
 
                if(!isdefined(self.hud_rankscroreupdate))
                {
                        self.hud_rankscroreupdate = newClientHudElem(self);
                        self.hud_rankscroreupdate.horzAlign = "center";
                        self.hud_rankscroreupdate.vertAlign = "middle";
                        self.hud_rankscroreupdate.alignX = "center";
                        self.hud_rankscroreupdate.alignY = "middle";
                        self.hud_rankscroreupdate.x = 0;
                        self.hud_rankscroreupdate.y = -60;
                        self.hud_rankscroreupdate.font = "default";
                        self.hud_rankscroreupdate.fontscale = 2.0;
                        self.hud_rankscroreupdate.archived = false;
                        self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
                        self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
                }
        }
}
I'm thinking that the problem is because its the _rank.gsc. Do you think threading my function in another gsc like _globallogic would work?

Re: Map restart

Posted: March 4th, 2013, 6:22 pm
by Drofder2004
If you have access to globallogic, then I see no reason not to use it. Globallogic already has the functions you are using, you can simply insert your extra functions in them.