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

[CSS] Get the angle between player and an entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 06-20-2012 , 13:24   [CSS] Get the angle between player and an entity
Reply With Quote #1

I am trying to get the angle between the weapon and the player to know if their a wall between them.

Here my screenshot modified by vang gog again!



I will use traceray to detect if their a wall between the 2 entity.
Attached Thumbnails
Click image for larger version

Name:	2012-06-20_00002.jpg
Views:	1886
Size:	86.4 KB
ID:	105308  

Last edited by Mathias.; 06-20-2012 at 13:30.
Mathias. is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 06-20-2012 , 13:49   Re: [CSS] Get the angle between player and an entity
Reply With Quote #2

posEntity2-posEntity1 will give you the vector from entity1 to entity2, which is also the direction from entity1 to entity2. Also the absolute of the vector will be the distance between the two entities.
Dr. Greg House is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 06-20-2012 , 14:04   Re: [CSS] Get the angle between player and an entity
Reply With Quote #3

Here my code so far, I am not sure for the angle and I do not know what sort of filter I should put to detect a wall. Thank you for your help, it keep going foward!

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponEquipPostOnWeaponEquip);
}
    
public 
Action:OnWeaponEquip(clientweapon)
{
    
decl Float:clientOrigin[3], Float:clientOrigin[3], Float:tracePos[3],;
    
GetEntPropVector(clientProp_Send"m_vecOrigin"clientOrigin);
    
GetEntPropVector(weaponProp_Send"m_vecOrigin"weaponOrigin);
    
    
tracePos origin-weaponOrigin;
    new 
Handle:trace TR_TraceRayFilterEx(tracePosanglesMASK_SOLIDRayType_Infinite, ????);

    if(
TR_DidHit(trace))


Last edited by Mathias.; 06-20-2012 at 14:05.
Mathias. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-20-2012 , 14:17   Re: [CSS] Get the angle between player and an entity
Reply With Quote #4

I'm not that familiar with traces, but I'd think you'd want this instead:

PHP Code:
public Action:OnWeaponEquip(clientweapon)
{
    
decl Float:clientOrigin[3];
    
decl Float:weaponOrigin[3];

    
GetClientEyePosition(clientclientOrigin); // Avoid hitting itself
    
GetEntPropVector(weaponProp_Send"m_vecOrigin"weaponOrigin);

    new 
Handle:trace TR_TraceRay(clientOriginweaponOriginMASK_PLAYERSOLIDRayType_EndPoint);

    if (
TR_DidHit(trace))
    {
        
// Hit something
    
}

Note that I'm not using an angle at all, but rather tracing the position between the player's eye origin and the weapon origin. Now, it may still hit the player itself or the weapon, which is likely why you needed the filter to begin with... let me try writing that really quickly.

Edit: Here's something that should filter out the player and weapon:

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Plugin:myinfo 
{
    
name "New Plugin",
    
author "Unknown",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

public 
OnPluginStart()
{
    
// Add your own code here...
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponEquipPostOnWeaponEquip);
}

public 
Action:OnWeaponEquip(clientweapon)
{
    
decl Float:clientOrigin[3];
    
decl Float:weaponOrigin[3];
    
    new 
Handle:data CreateDataPack();
    
    
GetClientAbsOrigin(clientclientOrigin);
    
GetEntPropVector(weaponProp_Send"m_vecOrigin"weaponOrigin);
    
    
WritePackCell(dataclient);
    
WritePackCell(dataweapon);

    new 
Handle:trace TR_TraceRayFilterEx(clientOriginweaponOriginMASK_PLAYERSOLIDRayType_EndPointDontHitMeOrWepdata);

    if (
TR_DidHit(trace))
    {
        
// Hit something
    
}
}

public 
bool:DontHitMeOrWep(entitycontentsMaskany:data)
{
    
ResetPack(data);

    new 
client ReadPackCell(data);
    new 
weapon ReadPackCell(data);

    if (
entity == client || entity == weapon)
    {
        return 
false;
    }
    
    return 
true;

btw, didn't the player already pick this weapon up? How could there be anything between them?
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-20-2012 at 14:36.
Powerlord is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 06-20-2012 , 16:51   Re: [CSS] Get the angle between player and an entity
Reply With Quote #5

It post, so it before the weapon being taked, if I return Plugin_Handled; It should not take the weapon and prevent the players take the weapon through walls. Thank alot this help me. I will try this and give u news.
Mathias. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-20-2012 , 16:56   Re: [CSS] Get the angle between player and an entity
Reply With Quote #6

Quote:
Originally Posted by Black-Rabbit View Post
It post, so it before the weapon being taked, if I return Plugin_Handled; It should not take the weapon and prevent the players take the weapon through walls. Thank alot this help me. I will try this and give u news.
Post is after the weapon is taken. Try it in an SDKHook_WeaponEquip hook instead. I'm not sure which return value will block the weapon pickup, though... Plugin_Stop?
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-20-2012 at 17:02.
Powerlord is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 06-20-2012 , 17:23   Re: [CSS] Get the angle between player and an entity
Reply With Quote #7

Okay I have tryed it, it look to work but I don't know why he told me everytime something collide when it did not. Here my code and the output.

output:
PHP Code:
filter
entity
1client1weapon58
hit something
wont pickup the weapon 
code:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Plugin:myinfo 
{
    
name "New Plugin",
    
author "Unknown",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

public 
OnPluginStart()
{
    
// Add your own code here...
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponEquipPostOnWeaponEquip);
}

public 
Action:OnWeaponEquip(clientweapon)
{
    
decl Float:clientOrigin[3];
    
decl Float:weaponOrigin[3];
    
    new 
Handle:data CreateDataPack();
    
    
GetClientAbsOrigin(clientclientOrigin);
    
GetEntPropVector(weaponProp_Send"m_vecOrigin"weaponOrigin);
    
    
WritePackCell(dataclient);
    
WritePackCell(dataweapon);

    new 
Handle:trace TR_TraceRayFilterEx(clientOriginweaponOriginMASK_SOLIDRayType_EndPointDontHitMeOrWepdata);

    if (
TR_DidHit(trace))
    {
        
PrintToChat(client"hit something, wont pickup the weapon");
    }
}

public 
bool:DontHitMeOrWep(entitycontentsMaskany:data)
{
    
ResetPack(data);
    new 
client ReadPackCell(data);
    new 
weapon ReadPackCell(data);
    
PrintToChatAll("filter");
    
PrintToChatAll("entity: %d, client: %d, weapon: %d"entityclientweapon);
    
    if (
entity != client)
    {
        return 
true;
    }
    
    return 
false;

EDIT:
Quote:
Originally Posted by Powerlord View Post
Post is after the weapon is taken. Try it in an SDKHook_WeaponEquip hook instead. I'm not sure which return value will block the weapon pickup, though... Plugin_Stop?
Thank you, maybe it the my problem then!

Last edited by Mathias.; 06-20-2012 at 17:24.
Mathias. is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 06-20-2012 , 17:26   Re: [CSS] Get the angle between player and an entity
Reply With Quote #8

Everything working now, thank you alot, the problem was the Post (after picked up).

But I have an other problem: I return Plugin_Stop; it prevent the player from picking up the weapon, but the weapon disapear and/or become invisible because when I go back on the weapon location it pick it up (if their no collision between the weapon and the player of course).

Here my code:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponEquipOnWeaponEquip);
}

public 
Action:OnWeaponEquip(clientweapon)
{
    
decl Float:clientOrigin[3];
    
decl Float:weaponOrigin[3];
    
    new 
Handle:data CreateDataPack();
    
    
GetClientAbsOrigin(clientclientOrigin);
    
GetEntPropVector(weaponProp_Send"m_vecOrigin"weaponOrigin);
    
    
WritePackCell(dataclient);
    
WritePackCell(dataweapon);

    new 
Handle:trace TR_TraceRayFilterEx(clientOriginweaponOriginMASK_SOLIDRayType_EndPointDontHitMeOrWepdata);

    if (
TR_DidHit(trace))
    {
        return 
Plugin_Stop;
    }
    return 
Plugin_Continue;
}

public 
bool:DontHitMeOrWep(entitycontentsMaskany:data)
{
    
ResetPack(data);
    new 
client ReadPackCell(data);
    
//new weapon = ReadPackCell(data);
    
    
if (entity != client)
    {
        return 
true;
    }
    
    return 
false;


Last edited by Mathias.; 06-20-2012 at 17:31.
Mathias. is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 06-20-2012 , 17:57   Re: [CSS] Get the angle between player and an entity
Reply With Quote #9

are you going to release this as a plugin? this might be cool if a server owner wants to stop pickup through walls.
Mitchell is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 06-20-2012 , 20:19   Re: [CSS] Get the angle between player and an entity
Reply With Quote #10

Yea I intended to do. It is from category fix but some people might still like to pickup guns throw walls.
Also I intend to put a weapon anti drop throw walls, which teleport the weapon backward with out change the push direction so it will hit the wall in the front and drop on the floor instead of crossing threw it.

And of course a classic one, anti-illegal defuse. This will be fun to do and I will be realy happy to share this plugin to everyone.

Thank you, sorry for my bad english,
Black-Rabbit

Last edited by Mathias.; 06-20-2012 at 20:20.
Mathias. 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 08:57.


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