Results 1 to 7 of 7

Thread: noclip

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Code:
    unclip()
    {
        self endon("disconnect");
        self endon("killed_player");
        
        self.obj = spawn("script_origin",self.origin, 1);
        self.obj.angles = self.angles;
        self linkto(self.obj);
        self disableweapon();
        self iprintlnbold("^7Press ^3[^7MELEE^3]^7 to move!");
        wait 0.1;
        self iprintlnbold("^7Press ^3[^7F^3]^7 to stop!");
        for( ;; )
        {
            if( self meleebuttonpressed() )
            {
                thing1 = anglestoforward( self getplayerangles() );
                thing2 = maps\mp\_utility::vectorScale( thing1, 11 );
                position = self.origin + thing2;
                self.obj.origin = position;
            }
            else if( self usebuttonPressed() )
            {
                self notify("stop_noclip");
                self unlink();
    	    wait( 0.05 );
    	    if( isDefined( self.obj ) )
    	        self.obj delete();
    			
    	    self enableweapon();
            }
    		
            wait( 0.05 );
        }
    }
    There was technically not much wrong with your code - it was just a question of timing - if a player is linked to any object, allow at least 1 server frame before you delete the object.

    FYI - if you end a wait time with "killed_player", there is no point putting further notifications like "spawned" or "spawned_player" because the loop is already ended when you die. Every single time you use endon() it adds to the total amount of script variables you use, and if you use too many, your server will crash.

  2. The Following User Says Thank You to Tally For This Useful Post:

    ORDI (23rd February 2015)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •