Raised This Month: $51 Target: $400
 12% 

[CS 1.6] How to detect if a player is crouched?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sekac
Senior Member
Join Date: Nov 2016
Old 10-15-2017 , 05:37   [CS 1.6] How to detect if a player is crouched?
Reply With Quote #1

The title says it all, how do i detect if a player is crouched (with and without holding the duck button, player will stay ducked if he is in a small area).
sekac is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 10-15-2017 , 07:49   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=97083
__________________
Relaxing is offline
sekac
Senior Member
Join Date: Nov 2016
Old 10-15-2017 , 15:29   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #3

I don`t know how to use that
sekac is offline
GrimmReaper
Junior Member
Join Date: Oct 2017
Location: Name's the Clue
Old 10-15-2017 , 21:20   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #4

Quote:
Originally Posted by sekac View Post
I don`t know how to use that
Its quite easy actually.
First you have to include hamsandwich to use it like this
PHP Code:
#include <hamsandwich> 
Then in plugin_init() forward put this
PHP Code:
RegisterHam(Ham_Player_Duck"player""player_duck"0); 
Now to explain this
Ham_Player_Duck - This is a event which triggers the ham to execute
"player" - Its the entity or in simple words object to which the above event is hooked to.
"player_duck" - Its basically the name of function you create to execute the code before or while or after the the event you specified. You can change this one to anything as long as the function you are creating has the same name.
The last parameter is for the pre/post
2 - before the event
0 - while the event is active or in your case while the player is crouching
1 - after the event
Lastly you have to make a function to execute the code like this
PHP Code:
public player_duck(id)
{
//Some code here

__________________
Add Me On Steam

Last edited by GrimmReaper; 10-16-2017 at 07:09.
GrimmReaper is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-16-2017 , 03:00   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #5

Quote:
Originally Posted by GrimmReaper View Post
Its quite easy actually.
First you have to include hamsandwich to use it like this
PHP Code:
#include <hamsandwich> 
Then in plugin_init() forward put this
PHP Code:
RegisterHam(Ham_Player_Duck"player""player_duck"0); 
Now to explain this
Ham_Player_Duck - This is a event which triggers the ham to execute
"player" - Its the entity or in simple words object to which the above event is hooked to.
"player_duck" - Its basically the name of function you create to execute the code before or while or after the the event you specified. You can change this one to anything as long as the function you are creating has the same name.
The last parameter is for the pre/post
-1 - before the event
0 - while the event is active or in your case while the player is crouching
1 - after the event
Lastly you have to make a function to execute the code like this
PHP Code:
public player_duck(id)
{
//Some code here

The 4th param in registerham is only has 2 values 0 & 1
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
GrimmReaper
Junior Member
Join Date: Oct 2017
Location: Name's the Clue
Old 10-16-2017 , 07:08   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
The 4th param in registerham is only has 2 values 0 & 1
Sorry my bad.
__________________
Add Me On Steam

Last edited by GrimmReaper; 10-16-2017 at 07:10.
GrimmReaper is offline
sekac
Senior Member
Join Date: Nov 2016
Old 10-16-2017 , 10:10   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #7

PHP Code:
register_clcmd("say /test""Test");

RegisterHam(Ham_Player_Duck"player""player_duck"0);  
new 
boolIsCrouched[32];

public 
player_duck(id

IsCrouched[id] = true;
}

public 
Test(id) {

if(
IsCrouched[id])
//some code here

Is this how i use it? I need to run a command somewhere else in the code, if the player is crouched. And if so, when do i set IsCrouched to false?
sekac is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 10-16-2017 , 10:47   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #8

First of all, you should tell us what you`re trying to achieve
__________________
retired chump
DjSoftero is offline
sekac
Senior Member
Join Date: Nov 2016
Old 10-16-2017 , 10:53   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #9

Just trying to give an item to player if he is crouching, if he isn`t return a message. It`s simple.
sekac is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 10-16-2017 , 11:41   Re: [CS 1.6] How to detect if a player is crouched?
Reply With Quote #10

i guess you can do it with orpheu
PHP Code:
new Is_Ducking OrpheuGetParamStructMember(1,"usehull")
if(
Is_Ducking == 1) {
    
//it means you`re ducking and you do smth
}
else
    
//not ducking 
I don`t really know if this will work and can`t test it atm, but you should give it a try.

source: https://forums.alliedmods.net/showth...7217?p=1387217
__________________
retired chump

Last edited by DjSoftero; 10-16-2017 at 11:50.
DjSoftero is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode