Raised This Month: $32 Target: $400
 8% 

[TF2]Hook when player press H on a grave


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 02-21-2017 , 07:26   [TF2]Hook when player press H on a grave
Reply With Quote #1

Hey,
How can I hook when player press H while looking at a grave and get the grave owner?
ty.
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests

Last edited by asherkin; 10-25-2018 at 17:14. Reason: Restore to previous version.
BraveFox is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 02-21-2017 , 07:44   Re: [TF2]Hook when player press H on a grave
Reply With Quote #2

Use the OnClientCommandKeyValues forward, and then look for kv section name if it matches "use_action_slot_item_server" or "+use_action_slot_item_server" or "-use_action_slot_item_server" or "+inspect_server" or "-inspect_server".
__________________
Benoist3012 is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 02-21-2017 , 08:06   Re: [TF2]Hook when player press H on a grave
Reply With Quote #3

Can you show me an example?
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 02-21-2017 , 09:00   Re: [TF2]Hook when player press H on a grave
Reply With Quote #4

Code:
public Action OnClientCommandKeyValues(int iClient, KeyValues kvCommand) {     char sCommand[64];     kvCommand.GetSectionName(sCommand,sizeof(sCommand));     if (strcmp(sCommand,"use_action_slot_item_server") == 0)//The client pressed his action key (Default:H)     {         //Do your stuff here     } }
__________________

Last edited by Benoist3012; 02-21-2017 at 09:00.
Benoist3012 is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 02-21-2017 , 09:50   Re: [TF2]Hook when player press H on a grave
Reply With Quote #5

And how can I get the grave entity(that the player look on)?
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests

Last edited by BraveFox; 02-21-2017 at 09:50.
BraveFox is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 02-21-2017 , 09:53   Re: [TF2]Hook when player press H on a grave
Reply With Quote #6

Why not just hook the entity?

https://sm.alliedmods.net/new-api/sd...okEntityOutput
https://developer.valvesoftware.com/...ess_2_Entities

"OnUse" or whatever the entity output is whenever someone clicks on it.
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS

Last edited by OSWO; 02-21-2017 at 09:54.
OSWO is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 02-21-2017 , 10:03   Re: [TF2]Hook when player press H on a grave
Reply With Quote #7

Quote:
Originally Posted by OSWO View Post
Why not just hook the entity?

https://sm.alliedmods.net/new-api/sd...okEntityOutput
https://developer.valvesoftware.com/...ess_2_Entities

"OnUse" or whatever the entity output is whenever someone clicks on it.
It's not entity that you can use.
It's a grave.
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-21-2017 , 10:12   Re: [TF2]Hook when player press H on a grave
Reply With Quote #8

You can probably use GetClientAimTarget to get the entity.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 02-21-2017 , 10:19   Re: [TF2]Hook when player press H on a grave
Reply With Quote #9

Quote:
Originally Posted by nosoop View Post
You can probably use GetClientAimTarget to get the entity.
Yes, but don't forget to set only clients on false, GetClientAimTarget(iClient, false);
Also this won't be perfect if you have a friendly player near.

Quote:
Originally Posted by BraveFox View Post
It's not entity that you can use.
It's a grave.
At first I thought you considered grave as its own thing that it's not an entity lol.

Anyway try to start from this code
Code:
float eyePos[3], eyeAng[3], flPos[3]; GetClientEyePosition(iClient, eyePos); GetClientEyeAngles(iClient, eyeAng); Handle hTrace = TR_TraceRayFilter(eyePos, eyeAng, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitPlayersOrEntity, iClient); int iGrave = TR_GetEntityIndex(hTrace); delete hTrace; if (iGrave > MaxClients) {     if (//Make sure the entity is a grave here)     {         //Do stuff here     } } public bool TraceRayDontHitPlayersOrEntity(int entity,int mask,any data) {     if (entity == data) return false;     if (entity > 0 && entity <= MaxClients) return false;         return true; }
__________________

Last edited by Benoist3012; 02-21-2017 at 10:21.
Benoist3012 is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 02-21-2017 , 10:37   Re: [TF2]Hook when player press H on a grave
Reply With Quote #10

Quote:
Originally Posted by Benoist3012 View Post
Yes, but don't forget to set only clients on false, GetClientAimTarget(iClient, false);
Also this won't be perfect if you have a friendly player near.


At first I thought you considered grave as its own thing that it's not an entity lol.

Anyway try to start from this code
Code:
float eyePos[3], eyeAng[3], flPos[3]; GetClientEyePosition(iClient, eyePos); GetClientEyeAngles(iClient, eyeAng); Handle hTrace = TR_TraceRayFilter(eyePos, eyeAng, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitPlayersOrEntity, iClient); int iGrave = TR_GetEntityIndex(hTrace); delete hTrace; if (iGrave > MaxClients) {     if (//Make sure the entity is a grave here)     {         //Do stuff here     } } public bool TraceRayDontHitPlayersOrEntity(int entity,int mask,any data) {     if (entity == data) return false;     if (entity > 0 && entity <= MaxClients) return false;         return true; }
How can I check if the entity is a grave(this is my first time with entities)?
And how can I get the owner of the entity?
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests

Last edited by BraveFox; 02-21-2017 at 10:37.
BraveFox 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 09:07.


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