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

[CSGO] Get grenade owner


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 08-02-2017 , 18:46   [CSGO] Get grenade owner
Reply With Quote #1

Hey, I'm trying to find the owner of the grenade right before (or after) a player throw it.

(OnEntityCreated)
PHP Code:
int client GetEntPropEnt(iGrenadeProp_Send"m_hOwnerEnity"); 
Seems to always return me client = -1.

Anyway have a idea ?
__________________
Want to check my plugins ?
Arkarr is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 08-02-2017 , 19:01   Re: [CSGO] Get grenade owner
Reply With Quote #2

Use SDKHook(entity, SDKHook_SpawnPost, ProjectileSpawned) or a timer in the OnEntityCreated event, and now you will get the owner with GetEntPropEnt(iGrenade, Prop_Send, "m_hOwnerEnity")
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 08-02-2017 , 19:22   Re: [CSGO] Get grenade owner
Reply With Quote #3

Quote:
Originally Posted by Franc1sco View Post
Use SDKHook(entity, SDKHook_SpawnPost, ProjectileSpawned) or a timer in the OnEntityCreated event, and now you will get the owner with GetEntPropEnt(iGrenade, Prop_Send, "m_hOwnerEnity")
Thanks mate!
__________________
Want to check my plugins ?
Arkarr is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 08-02-2017 , 19:45   Re: [CSGO] Get grenade owner
Reply With Quote #4

Quote:
Originally Posted by Arkarr View Post
Thanks mate!
Nice to help you, especially to you since I love your job and your attitude (no homo) <3
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 08-03-2017 , 05:51   Re: [CSGO] Get grenade owner
Reply With Quote #5

Quote:
Originally Posted by Franc1sco View Post
Nice to help you, especially to you since I love your job and your attitude (no homo) <3
Well, thanks.
Anyway, I got news. It doesn't seems to work. Here is my code :
PHP Code:
public void OnEntityCreated(int entity)
{
    
SDKHook(entitySDKHook_SpawnPostProjectileSpawned); 
}

public 
void ProjectileSpawned(int entity)
{
    
char classname[45];
    
GetEdictClassname(entityclassnamesizeof(classname));
    
    if(
StrContains(classname"_projectile"false) != -1)
    {
        
int owner GetEntPropEnt(entityProp_Send"m_hOwnerEnity")
        
        if (
owner != -1)
        {
            
PrintToChatAll("It works !");
        }
        
        
PrintToChatAll("Owner : %i"owner);
        
    }

Error :
Code:
[SM] Plugin [CSGO] Infinite Tag Grenade reloaded successfully.
L 08/03/2017 - 11:49:54: [SM] Exception reported: Property "m_hOwner" not found (entity 433/flashbang_projectile)
L 08/03/2017 - 11:49:54: [SM] Blaming: CSGO_InfiniteTagNade.smx
L 08/03/2017 - 11:49:54: [SM] Call stack trace:
L 08/03/2017 - 11:49:54: [SM]   [0] GetEntPropEnt
L 08/03/2017 - 11:49:54: [SM]   [1] Line 41, C:\Users\Arkarr\AppData\Roaming\spedit\sourcepawn\scripts\CSGO_InfiniteTagNade.sp::ProjectileSpawned
__________________
Want to check my plugins ?

Last edited by Arkarr; 08-03-2017 at 05:54.
Arkarr is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 08-03-2017 , 06:11   Re: [CSGO] Get grenade owner
Reply With Quote #6

Sorry for double post. It works now, this is my final code :
PHP Code:
public void OnEntityCreated(int entity)
{
    
char classname[45];
    
GetEdictClassname(entityclassnamesizeof(classname));
    if(
StrContains(classname"_projectile"false) != -1)
        
CreateTimer(0.3TMR_ResetNadeentity);
}

public 
Action TMR_ResetNade(Handle timerany entity)
{
    
int owner GetEntPropEnt(entityProp_Send"m_hThrower")
    
    if (
owner != -1)
        return;
        
    
//Do something

__________________
Want to check my plugins ?
Arkarr 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 10:21.


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