PDA

View Full Version : Press F didn't work



Loveboy
30th June 2013, 14:27
Hi Guys, i have a script, where you must press F, but if you press then nothing happens, but it should.

Script:



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?

RobsoN
30th June 2013, 14:34
How and where the "startheli()" function is called?

kung foo man
30th June 2013, 14:38
Are you calling that on "level" again?

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

Loveboy
30th June 2013, 14:40
Its called by Killstreak



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 :



main()
{
thread startheli();
}

RobsoN
30th June 2013, 14:44
Change from: self thread maps\mp\gametypes\_carepackage::main();

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

Loveboy
30th June 2013, 14:56
Thx but nothing changed :D Same problem

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

but till here it works:



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

RobsoN
30th June 2013, 14:59
You need to put loop..



self endon("disconnect");

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

Loveboy
30th June 2013, 15:10
Thanks RobsoN, that works!

Earliboy
1st July 2013, 13:59
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

Ni3ls
1st July 2013, 14:53
I thought that for(;;) could be used without wait and that only while(1) needs a wait. Correct me if im wrong

Tally
1st July 2013, 15:25
I thought that for(;;) could be used without wait and that only while(1) needs a wait. Correct me if im wrong

It depends if the 3 control arguments (int, condition, increment) are used or not. If not, then you require a wait time of at least a server frame.