Scripts / [SOLVED] Problems with timer

Author
Message
Vpze
4
Years of Service
User Offline
Joined: 17th Feb 2020
Location:
Posted: 2nd Aug 2020 15:30 Edited at: 2nd Aug 2020 15:33
Hi everyone, I'm currently working on a script that when you are injured and you come to a first aid kit, you hold E for 3 secs to heal - like any other games like Payday, PUBG,... A progress bar will also show up during that 3 secs. The matter is that there is something wrong with my script that it won't work, it just heals immediately when I press E. Any ideas? Thanks in advance!


The author of this post has marked a post as an answer.

Go to answer
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 2nd Aug 2020 16:06 Edited at: 2nd Aug 2020 16:35
This post has been marked by the post author as the answer.
The second script is starting the timer for that entity, i.e. the one that the script is attached to.
The first script is testing it's timer, which hasn't been started.

You need something like the attached.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
Vpze
4
Years of Service
User Offline
Joined: 17th Feb 2020
Location:
Posted: 2nd Aug 2020 18:04
Quote: "You need something like the attached."

OMG Thank you AmenMoses, your script has solved the problem! I have stuck with this for ages.
But I don't know why after 3 secs it reduces my health instead of gaining more health. I think it's because of this line:

So I have changed to this and it works fine:


Once again, thank you for your help, your code is so impressive!
Vpze
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 2nd Aug 2020 20:01
Hmm, maybe AddPlayerHealth doesn't work the way I thought it does, it would probably be safer to use SetPlayerHealth( 100 )
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Aug 2020 13:30 Edited at: 3rd Aug 2020 13:31
the original commands use a value in the .fpe of the object to adjust the player health which is why you use the entity number rather than a value... it's not very user friendly when adjusting and it's better to use the SetPlayerHealth command in your script as this can take direct values (or set the value to an exposed variable so you can adjust it per entity again)
p.s. i have a version that might be useful too
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Pink Panther
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 3rd Aug 2020 16:26
That's a great script, thanks for sharing! Just out of curiosity, what image are you using for a progress bar?
PM

Login to post a reply

Server time is: 2024-04-18 04:10:45
Your offset time is: 2024-04-18 04:10:45