Answered GSC Code Help

Quacked420

Veteran
Messages
58
Reaction score
10
Points
793
Hey CabConModding community, so basically I have been making this x2 Speed code but i freezes my console when I choose it in the menu, here is the code:

Code:
toggleSpeed()
{
    if(self.speed==false)
    {
        self thread Speed();
        self.speed=true;
        self iPrintln("x2 Speed ^2On");
    }
    else
    {
        self notify("stop_speed");
        self.speed=false;
        self iPrintln("x2 Speed ^1Off");
    }
}

Speed()
{
    self endon("disconnect");
    self endon("stop_speed");
    for(;;)
    {
        self setmovespeedscale(2);
    }
}

If anyone could help fix and explain this it would be great, thanks.
 

DF_AUS

Moderator
Staff member
Head Staff Team
Donator
Messages
582
Reaction score
825
Points
878
You was missing a wait time on your loop, however i don't think you need to loop that code, try this:

Code:
toggleSpeed()
{
    if(!isDefined(self.speed))
    {
        self.speed = true;
        self setmovespeedscale(2);
        self iPrintln("x2 Speed ^2On");
    }
    else
    {
        self setmovespeedscale(1);
        self.speed = undefined;
        self iPrintln("x2 Speed ^1Off");
    }
}
 

Quacked420

Veteran
Messages
58
Reaction score
10
Points
793
You was missing a wait time on your loop, however i don't think you need to loop that code, try this:

Code:
toggleSpeed()
{
    if(!isDefined(self.speed))
    {
        self.speed = true;
        self setmovespeedscale(2);
        self iPrintln("x2 Speed ^2On");
    }
    else
    {
        self setmovespeedscale(1);
        self.speed = undefined;
        self iPrintln("x2 Speed ^1Off");
    }
}
Thanks bro got it working. :smile:
 
Top