UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

How to write code for holding F a certain amount of time to activate script?

broken avatar :(
Created 3 years ago
by Chadric273
0 Members and 1 Guest are viewing this topic.
805 views
broken avatar :(
×
broken avatar :(
Location: Minnesota
Date Registered: 7 July 2012
Last active: 4 months ago
Posts
36
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
Chadric273's Groups
Chadric273's Contact & Social Linkschadric.hjellming
Hey guys! So, I tried looking on this link for a built-in function but I could not find anything (link: https://aviacreations.com/modme/scriptdocs/#). What line of code would I write to have it so the player has to hold F for 5 seconds before it allows th rest of the script to run? I know how to do it for pressing F once, but I do not know how to write it so that you have to hold F for 5 seconds. Any help with this would be much appreciated!

On a second note, how do I go about making it so that while the player is holding F , a "progress bar" appears that fills up to show you how much longer you have to hold F for?

broken avatar :(
×
broken avatar :(
Location: Minnesota
Date Registered: 7 July 2012
Last active: 4 months ago
Posts
36
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
Chadric273's Groups
Chadric273's Contact & Social Linkschadric.hjellming
Not sure if this will benefit anyone who may view this thread in the future, but if you are wondering how to do what I asked about as well, I did manage to write a chunk of code that basically checks to see if you are holding F every second the code runs. The "use button" is referencing whatever button you press to basically do anything (buy perks, buy weapons off the wall, etc.).

Code:
for(i = 5; i > 0; i--) //For i = 5 you can change the five to how ever many seconds you want the player to hold F for.
{
if(player UseButtonPressed()) //UseButtonPressed is referencing whatever button you have to press to buy doors, perks, and so on. For my controls that button is F.
{
player DisableWeapons();
IPrintLnBold(i);
wait 1;
}
else
{
player EnableWeapons();
break;
}
}
NOTE: you may have to change lines of this code to adjust it to what you want the script to do and to make it work correctly with your script. If you have any questions about this chunk of code don't be afraid to ask! (:
 
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 5 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Try using a while loop instead of an if and have it count up until the set time is reached while your pressing use

 
Loading ...