-
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?
-
How and where the "startheli()" function is called?
-
Are you calling that on "level" again?
Player code needs to be called like: player thread startheli();
-
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();
}
-
Change from: self thread maps\mp\gametypes\_carepackage::main();
To: self thread maps\mp\gametypes\_carepackage::startheli();
-
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:
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
-
You need to put loop..
PHP Code:
self endon("disconnect");
while(1)
{
if(self useButtonPressed())
{
//code
}
wait 0.05;
}
-
Thanks RobsoN, that works!
-
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
-
I thought that for(;;) could be used without wait and that only while(1) needs a wait. Correct me if im wrong