Scripts / Player crouched

Author
Message
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 13th Jul 2016 08:03
Good morning .
Wondering if there is a way to detect if player is crouched. I've searched the global but all I find is the CharacterControlDucked which works with characters ( well kind of) but I want to detect if player is crouched. Something along the lines of;

if g_Entity[e]['plrvisible'] ==1 and g_PlayerHealth > 0 and g_PlayerControlDucked==1 then

Obviously the red code does not exist but wondering if anyone had an idea. I have considered the x, y,z co-ordinates option to detect height of player but because of the different elevations in map this will become too complicated - not to mention beyond my abilities.

Thanks.
Nathan38
13
Years of Service
User Offline
Joined: 13th Feb 2011
Location:
Posted: 13th Jul 2016 10:13 Edited at: 13th Jul 2016 10:14
Hi Isagabe,
you could try using g_InKey == " ", in here you can detect any key press. I can't remember what the default crouch key is, but you would put that key in there, e.g. g_InKey == "c"
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 13th Jul 2016 11:31
Quote: "I have considered the x, y,z co-ordinates option to detect height of player but because of the different elevations in map this will become too complicated"


Quote: "GetTerrainHeight : height = GetTerrainHeight(x,z) -- where X and Z are the coordinates on the terrain you want the height from"


hth

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 13th Jul 2016 14:43
Thanks for the suggestions. Will give it a try. Regards
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 13th Jul 2016 17:33
@Nathan38. Got it working by including 'local KeyPressC = 0' and then in the main 'if g_Entity[e]['plrinzone'] ==1 and g_KeyPressC == 0 then'. not ideal but for gameplay continuity testing purposes it suffices. But if player uses the ctrl key to crouch then the code does not work - or rather it does but because the player is not pressing c the game cannot progress until player presses c. Learn as you go.

@3com thanks for pointing me to 'GetTerrainHeight : height = GetTerrainHeight(x,z)' - thanks. I think that this would probably be the best way around it. Beyond my skills at this stage but I will spend a few days looking at scripts to try figure out how to implement this.

Login to post a reply

Server time is: 2024-12-22 18:45:33
Your offset time is: 2024-12-22 18:45:33