I need a function for my script, which turns a certain action on and off when pressing a button
-
This is my script, as you can see I had to put the same function by directing buttons one to turn on and another to turn it off because I don't know what I should do to use only one button, join my script in 1 only and it will turn on when press a button and pressing that button again turns it off.
NightVisionON()
{
self endon("disconnect"); self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado"); for(;;) { if(self actionslotfourbuttonpressed()) { self setinfraredvision(true); } wait 0.01; }}
NightVisionOFF()
{
self endon("disconnect"); for(;;) { if(self actionslotonebuttonpressed()) { self setinfraredvision(false); } wait 0.01; }}
-
This is my script, as you can see I had to put the same function by directing buttons one to turn on and another to turn it off because I don't know what I should do to use only one button, join my script in 1 only and it will turn on when press a button and pressing that button again turns it off.
NightVisionON()
{
self endon("disconnect"); self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado"); for(;;) { if(self actionslotfourbuttonpressed()) { self setinfraredvision(true); } wait 0.01; }}
NightVisionOFF()
{
self endon("disconnect"); for(;;) { if(self actionslotonebuttonpressed()) { self setinfraredvision(false); } wait 0.01; }}
NightVisionToggle() { level endon("game_ended"); self endon("disconnect"); self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado"); for(;;) { if(self actionslotfourbuttonpressed()) { if (!isDefined(self.nightvision)) { self.nightvision = true; self setinfraredvision(true); } else { self.nightvision = undefined; self setinfraredvision(false); } } wait 0.05; } }using the isDefined(variable) you can create a variable on the player and use that as the check for the toggle. Hopefully this makes sense
-
NightVisionToggle() { level endon("game_ended"); self endon("disconnect"); self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado"); for(;;) { if(self actionslotfourbuttonpressed()) { if (!isDefined(self.nightvision)) { self.nightvision = true; self setinfraredvision(true); } else { self.nightvision = undefined; self setinfraredvision(false); } } wait 0.05; } }using the isDefined(variable) you can create a variable on the player and use that as the check for the toggle. Hopefully this makes sense
Cahz I speak Spanish and when translating it I understood something like
if(isdefined(self setinfraredvision)) if(self actionslotonebuttonpressed()) { self setinfraredvision(false); } -
NightVisionToggle() { level endon("game_ended"); self endon("disconnect"); self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado"); for(;;) { if(self actionslotfourbuttonpressed()) { if (!isDefined(self.nightvision)) { self.nightvision = true; self setinfraredvision(true); } else { self.nightvision = undefined; self setinfraredvision(false); } } wait 0.05; } }using the isDefined(variable) you can create a variable on the player and use that as the check for the toggle. Hopefully this makes sense
Cahz Thank you very much for helping me again, very kind of you. I already did it, I am going to leave the code here in case someone is interested or is looking for the same goal as me.
-
Remember call night vision
NightVision()
{
self endon("disconnect"); self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado"); for(;;) { if(self actionslotfourbuttonpressed()) { self InfraredVision(); } wait 0.01; }}
InfraredVision()
{
if (!IsDefined(self.InfraredVision))
{
self.InfraredVision = true;
self setinfraredvision(true);
self IPrintLn("InfraredVision: ^2Enabled");
}
else
{
self.InfraredVision = undefined;
self setinfraredvision(false);
self IPrintLn("InfraredVision: ^1Disabled");
}
}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login