What's new

Solved Any way to change the challenge code?

Status
Not open for further replies.
E

Ells

#yoloswag
VIP
Retired
Messages
7,756
Reaction score
3,121
Hey guys.

I want to change the following challenge code (just took from a recent post from Trammell) so that I can make my patch do different things.

Code:
completeAllChallenges()
{
self endon( "disconnect" ); //Tells the code to end for that player when they disconnect from the game
self notifyOnPlayerCommand( "dpad_down", "+actionslot 2" ); //Will recognize the thread after "+actionslot 2" is pressed
chalProgress = 0; //The initial variable for the challenge meter
self waittill( "dpad_down" ); //Activate all code in the script after "dpad_down" is pressed
useBar = createPrimaryProgressBar( 25 ); // This defines the variable for the progress bar telling it what useBar ='s later on in the script
useBarText = createPrimaryProgressBarText( 25 ); // This defines the variable for the text of the progress bar
foreach ( challengeRef, challengeData in level.challengeInfo ) //This tells the script to do this for every challenge in the challenge table
{
finalTarget = 0; // This is the variable we want the locked challenge to have
finalTier = 0; // This is what we want the Tier of challenges to be
for ( tierId = 1; isDefined( challengeData["targetval"][tierId] ); tierId++ )
{
finalTarget = challengeData["targetval"][tierId];
finalTier = tierId + 1;
}
if ( self isItemUnlocked( challengeRef ) ) //If the challenge is locked execute the code below
{
self setPlayerData( "challengeProgress", challengeRef, finalTarget );
self setPlayerData( "challengeState", challengeRef, finalTier );
}

chalProgress++;
chalPercent = ceil( ((chalProgress/480)*100) ); //This is the equation for the progress bar to run on
useBarText setText( chalPercent + " percent done" ); //This is the text for the variable we defined earlier in the script its telling it to take the equation from line above and add the text percent done to the end of it
useBar updateBar( chalPercent / 100 ); //This so that the progress bar will go up as the challenges unlock

wait ( 0.04 ); // Wait 0.04 seconds before executing the next part of the script
}
useBar destroyElem(); //destroy the useBar element
useBarText destroyElem(); //destroy the useBarText element
}

I want it so that before you do the challenges, your status of completion is 0 and while its doing its 1 and after its done its 2 (hope that makes sense lol)

And then I wanted it so something like, "if ChallengeStatus, 0" a certain piece of text is displayed on your screen.

If anyone could help I would love you forever. Searched a little bit and couldn't find anything, so don't say "search" or "search harder" I just want a helpful responce.

Thanks. :smile:
 
G

Gunz

Gunz Iz Teh Hax
Messages
958
Reaction score
326
Piece of cake think of something a bit harder next time. :wink:

If you want to set a status no matter what it may be you use this.
Code:
self.status = "UNAUTHORISED";
You can rename it to anything you want EX:
Code:
self.Chalstatus = "done";
Then use this code to initiate a thread on status
Code:
if(self.Chalstatus == "Status Here")
{
//Threads
}

So to complete here is the thread you asked for:
Code:
onPlayerSpawned()
{
self endon( "disconnect" );

for(;;) 
{
self waittill( "spawned_player" );
self.Chalstatus = "0";
}
}

Code:
completeAllChallenges()
{
self endon( "disconnect" );
self notifyOnPlayerCommand( "dpad_down", "+actionslot 2" );
self.Chalstatus = "1";//Status While Challenges Are Unlocking
self.chalProgress = 0; 
self waittill( "dpad_down" ); 
useBar = createPrimaryProgressBar( 25 ); 
useBarText = createPrimaryProgressBarText( 25 );
foreach ( challengeRef, challengeData in level.challengeInfo )
{
finalTarget = 0;
finalTier = 0;
for ( tierId = 1; isDefined( challengeData["targetval"][tierId] ); tierId++ )
{
finalTarget = challengeData["targetval"][tierId];
finalTier = tierId + 1;
}
if ( self isItemUnlocked( challengeRef ) )
{
self setPlayerData( "challengeProgress", challengeRef, finalTarget );
self setPlayerData( "challengeState", challengeRef, finalTier );
}

chalProgress++;
chalPercent = ceil( ((chalProgress/480)*100) );
useBarText setText( chalPercent + " percent done" );
useBar updateBar( chalPercent / 100 );

wait ( 0.04 ); 
}
useBar destroyElem();
useBarText destroyElem(); 
self.Chalstatus = "2";//Status After Challenges Unlocked
}
 
E

Ells

#yoloswag
VIP
Retired
Messages
7,756
Reaction score
3,121
Piece of cake think of something a bit harder next time. :wink:

If you want to set a status no matter what it may be you use this.
Code:
self.status = "UNAUTHORISED";
You can rename it to anything you want EX:
Code:
self.Chalstatus = "done";
Then use this code to initiate a thread on status
Code:
if(self.status == "Status Here")
{
//Threads
}

So to complete here is the thread you asked for:
Code:
onPlayerSpawned()
{
self endon( "disconnect" );

for(;;) 
{
self waittill( "spawned_player" );
self.Chalstatus = "0";
}
}

Code:
completeAllChallenges()
{
self endon( "disconnect" );
self notifyOnPlayerCommand( "dpad_down", "+actionslot 2" );
self.Chalstatus = "1";//Status While Challenges Are Unlocking
self.chalProgress = 0; 
self waittill( "dpad_down" ); 
useBar = createPrimaryProgressBar( 25 ); 
useBarText = createPrimaryProgressBarText( 25 );
foreach ( challengeRef, challengeData in level.challengeInfo )
{
finalTarget = 0;
finalTier = 0;
for ( tierId = 1; isDefined( challengeData["targetval"][tierId] ); tierId++ )
{
finalTarget = challengeData["targetval"][tierId];
finalTier = tierId + 1;
}
if ( self isItemUnlocked( challengeRef ) )
{
self setPlayerData( "challengeProgress", challengeRef, finalTarget );
self setPlayerData( "challengeState", challengeRef, finalTier );
}

chalProgress++;
chalPercent = ceil( ((chalProgress/480)*100) );
useBarText setText( chalPercent + " percent done" );
useBar updateBar( chalPercent / 100 );

wait ( 0.04 ); 
}
useBar destroyElem();
useBarText destroyElem(); 
self.Chalstatus = "2";//Status After Challenges Unlocked
}
Thank you ever so much. :smile:
 
Status
Not open for further replies.
Top Bottom