UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

While loop problem

broken avatar :(
Created 10 years ago
by reckfullies
0 Members and 1 Guest are viewing this topic.
1,664 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 9 months ago
Posts
305
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
*Before I start i'm not too educated in c++ or c so something basic like this is a problem for me*
I am trying to setup my perk in the _zombiemode_weapons.gsc file since it edits the box price.

This is the code I currently have in the treasure_chest_think function.

Code Snippet
Plaintext
boxUser = undefined;
BoxBoozeTrigger = GetEnt( "BoxBoozeTrig", "targetname" );
BoxBoozeTrigger waittill( "trigger", boxUser );
while( boxUser hasPerk( "specialty_gpsjammer" ) )
{
cost = 700;
self set_hint_string( self, "default_treasure_chest_" + 700 );
self setCursorHint( "HINT_NOICON" );
}

However when I check if the player has the perk in a while loop I get an error saying cost is uninitialized, but when its in an if statement its fine.
Marked as best answer by reckfullies 10 years ago
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
Code Snippet
Plaintext
boxUser = undefined;
BoxBoozeTrigger = GetEnt( "BoxBoozeTrig", "targetname" );
BoxBoozeTrigger waittill( "trigger", boxUser );
cost = 950;                                                      // also put it outside the loop / if statement
while( boxUser hasPerk( "specialty_gpsjammer" ) )          // If this is not true, cost wont be intialised
{
cost = 700;
self set_hint_string( self, "default_treasure_chest_" + 700 );
self setCursorHint( "HINT_NOICON" );

        wait 0.1;                                       // Always put a wait in a while-loop, or the game will break the loop on launch ('potential infinite loop - killing thread' error )
}


Not sure if you need a while loop here? If the player has the perk, the function will basicly get stuck in the loop till the player loses the perk..
Last Edit: September 27, 2016, 06:34:41 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 9 months ago
Posts
305
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
I've fixed it now, not entirely sure what my problem was but the reason I decided to add a while loop was because it was taking a while to update the first time one the player got the perk for some reason.

I'm doing it with just an if statement now and it seems to be working fine.

Looks like it was a one time thing.

 
Loading ...