Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Press F didn't work

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    Press F didn't work

    Hi Guys, i have a script, where you must press F, but if you press then nothing happens, but it should.

    Script:

    Code:
    startheli()
    {
    	level endon("end_map");
    	self endon("disconnect");
    
    	self iprintlnbold("Press F to call your Carepackage!");
    
    	if(self useButtonPressed())
    	{
    		for(;;)
    		{
    		self iprintlnbold("should work...");
                    //.... script function
                    }
             }
    }
    The script will called but i am 100 % sure the Press F didn't work.

    Please help me, what i must do for that?

  2. #2
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    How and where the "startheli()" function is called?

  3. The Following User Says Thank You to RobsoN For This Useful Post:

    Loveboy (30th June 2013)

  4. #3
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Are you calling that on "level" again?

    Player code needs to be called like: player thread startheli();
    timescale 0.01

  5. The Following User Says Thank You to kung foo man For This Useful Post:

    Loveboy (30th June 2013)

  6. #4
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Its called by Killstreak

    Code:
    streak()
    {
    	streak = self.streak;
    	switch(streak)
    	{
    	case 3:
    		iprintln(self.name+" ^7is on 3 Killstreak!");
            self iprintlnbold("You are on 3 Killstreak, you get your Carepackage!");
    		self thread maps\mp\gametypes\_carepackage::main();
    		break;
    	}
    }
    then on _carepackage.gsc :

    Code:
    main()
    {
    	thread startheli();
    }

  7. #5
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    Change from: self thread maps\mp\gametypes\_carepackage::main();

    To: self thread maps\mp\gametypes\_carepackage::startheli();

  8. The Following User Says Thank You to RobsoN For This Useful Post:

    Loveboy (30th June 2013)

  9. #6
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Thx but nothing changed Same problem

    the if(self usebuttonpressed)
    {
    .....
    }
    is for pressing f then should happen something, but nothing will happen

    but till here it works:

    Code:
    startheli()
    {
    	level endon("end_map");
    	self endon("disconnect");
    
    	self iprintlnbold("Press F to call your Carepackage!");
     // here comes the iprintbold
    
        but then...
    	if(self useButtonPressed())
    	{
    	// FUNCTION...
            // DIDNT WORK

  10. #7
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    You need to put loop..

    PHP Code:
    self endon("disconnect");

    while(
    1)
    {
        if(
    self useButtonPressed())
        {
        
    //code
        
    }
       
    wait 0.05;


  11. The Following 2 Users Say Thank You to RobsoN For This Useful Post:

    kung foo man (30th June 2013),Loveboy (30th June 2013)

  12. #8
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Thanks RobsoN, that works!

  13. #9
    Private First Class Earliboy's Avatar
    Join Date
    Nov 2012
    Location
    Germany
    Posts
    130
    Thanks
    5
    Thanked 88 Times in 61 Posts
    PHP Code:
    self endon("disconnect");

    while( 
    self useButtonPressed() ) //If he is pressing the use button allready, so he don't activates it random
         
    wait .1;

    self iprintlnBold("Press F to call Heli");

    while( !
    self useButtonPressed() )
         
    wait .1;

    if(!
    isAlive(self)) //if he needs to be alive to get a heli/care package
         
    return;
    //functions

    Also, NEVER use
    for(;
    self iprintlnBold("BLA");

    without an wait! The server won't start cause of infinity loop
    No ... No ... this is not possible .......

  14. The Following User Says Thank You to Earliboy For This Useful Post:

    Loveboy (1st July 2013)

  15. #10
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I thought that for(; could be used without wait and that only while(1) needs a wait. Correct me if im wrong

Posting Permissions

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