ItsMods

Full Version: Toggle feature on and off
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am making a mod that is based on the telekinetic roll on RTD. I have everything ready but I am wanting to make it so I can turn off and on the telekinetic shooting. I have tried this and it has not worked.
PHP Code:
for(;;)
{
while(!
self useButtonPressed()) 
wait 0.05;
doTelekinetic();
wait 0.5;
while(!
self useButtonPressed())
wait 0.05;
self notify("stopkinetic");
wait 0.5;

I put that into the the onplayerspawned();
I then added this.
PHP Code:
doTelekinetic()
{
self endon("death");
self endon("stopkinetic");

//telekinetic code here

It somewhat works as when you first spawn you can turn it on but can't turn it back off then when you respawn you lose the weapon you should have and can only turn it on.
Anyone? I want to have this in the first release.
Look at the way the jetpack on use is coded in, try and go with that? Not sure who made it but it uses a on use function similar to urs from what i remember.
This should allow the player to toggle Telekinetic shooting:

Code:
onPlayerSpawed()
{
    // rest of code above this
    
    self.isTelekinetic = false;

    for(;;)
    {
        if( self useButtonPressed() )
        {
            if( !self.isTelekinetic )
            {
                self thread doTelekinetic()
                self.isTelekinetic = true;
            }
            else if( self.isTelekinetic )
            {
                self notify( "stop_telekinetic" );
                self.isTelekinetic = false;
            }
            
            wait 1;
        }
        wait 0.05;
    }
}


doTelekinetic()
{
    self endon( "disconnect" );
    self endon( "death" );
    self endon( "stop_telekinetic");

    //telekinetic code here
}