Scripts / problem with displaying player lives

Author
Message
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 22nd Jun 2017 09:24
hi there i have a hud were i want the player lives to be displayed in custom hud ive managed to access the g_PlayerLiives command and display it onscreen using text but after a minutes in game it disappears ive got the script attached to a nonstatic entity and set always active to yes but it still keeps on disappearing any help would be appreciated heres the code im using


local text_showing = 0
playerlives = g_PlayerLives
function player_lives_init(e)


end

function player_lives_main(e)

if text_showing == 0 or text_showing == e then
TextColor(90,90,5,"Lives ["..playerlives.."]",100,0,10)
text_showing = e
end
end
as i say it does work at first but it dissappearss the player health uses a similar script and that works fine
iam am using third person and the projectile script by Smallg but as i say everything else works fine
thanks bonesy23438
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Jun 2017 11:30
your code can be simplified to:

Been there, done that, got all the T-Shirts!
PM
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 23rd Jun 2017 12:49
hi there i done that originally and its doing th same thing as the above code it only displays it for a minute or so then disappears
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Jun 2017 14:43
Double check it is 'always active' and add a debug line like:

Prompt("Got Here") in the script right after the TextColor line to make sure the script is actually being executed.
Been there, done that, got all the T-Shirts!
PM
bonesy23438
9
Years of Service
User Offline
Joined: 8th May 2015
Location:
Posted: 23rd Jun 2017 22:49
i seemed to have fixed the problem all i did was redo the entity with the script and moved it closer to my player even though always active was yes it seems to be working fine now
PM
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 3rd Jul 2017 22:07
How do you go about having more than one text field active on screen at the same time?
Twitter - Teabone3 | Youtube - Teabone3 | Twitch - Teabone3 | TGC Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GT 740
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Jul 2017 22:59
Quote: "How do you go about having more than one text field active on screen at the same time?"

the Text() commands aren't limited to 1, just the Prompt commands that are.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-05-08 17:59:44
Your offset time is: 2024-05-08 17:59:44