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

Hook owner of smoke from smokegrenade.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HSFighter
Veteran Member
Join Date: Aug 2007
Location: Flensburg - Germany
Old 11-19-2011 , 10:22   Hook owner of smoke from smokegrenade.
Reply With Quote #1

Hi all,

i try to Hook the owner of smoke from a smokegrenade.

But i get a "-1" back when i try to get the clientID What i doing wrong?


PHP Code:
public OnEntityCreated(entity, const String:classname[])
{    
    if (
entity MaxClients && IsValidEntity(entity))
    {
        if(
StrEqual(classname"env_particlesmokegrenade"false))
        {
            
SDKHook(entitySDKHook_SpawnOnSpawnParticles);
        }
    }
}

// EntitySpawned
public OnSpawnParticles(entity)
{
    
// Get owner from entity
    
new client GetEntPropEnt(entityProp_Data"m_hOwnerEntity");
    
    
PrintToChatAll("Client --> %i"client);
    
PrintToChatAll("Entity --> %i"entity);

__________________



Sorry for my very bad english
Greetings HSFighter

Last edited by HSFighter; 11-19-2011 at 10:23.
HSFighter is offline
Send a message via ICQ to HSFighter
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-19-2011 , 12:18   Re: Hook owner of smoke from smokegrenade.
Reply With Quote #2

Aaaf...
Spoiler
*edit
Those who have not know.
smokegrenade_projectiles stay on ground, not get removed, but disappear until new round.

*edit edit
Maybe this better ?
PHP Code:
#include <sdktools>

public OnPluginStart()
{
    
HookEvent("smokegrenade_detonate"smokegrenade_detonate);
}

public 
smokegrenade_detonate(Handle:event, const String:name[], bool:dontBroadcast)
{
/*
    "smokegrenade_detonate"
    {
        "userid"    "short"
            "x"        "float"
            "y"        "float"
            "z"        "float"
    }
*/
    
new client GetClientOfUserId(GetEventInt(event"userid"));

    new 
Float:a[3], Float:b[3];
    
a[0] = GetEventFloat(event"x");
    
a[1] = GetEventFloat(event"y");
    
a[2] = GetEventFloat(event"z");

    new 
ent = -1;

    while((
ent FindEntityByClassname(ent"env_particlesmokegrenade")) != -1)
    {
        
GetEntPropVector(entProp_Send"m_vecOrigin"b);

        
//PrintToServer("%f %f %f\n%f %f %f", a[0], a[1], a[2], b[0], b[1], b[2]);

        
if(a[0] == b[0] && a[1] == b[1] && a[2] == b[2])
        {
            
PrintToChatAll("Client --> %i"client);
            
PrintToChatAll("env_particlesmokegrenade --> %i"ent);
            break;
        }
    }    

__________________
Do not Private Message @me

Last edited by Bacardi; 11-19-2011 at 14:23.
Bacardi is offline
HSFighter
Veteran Member
Join Date: Aug 2007
Location: Flensburg - Germany
Old 11-21-2011 , 11:36   Re: Hook owner of smoke from smokegrenade.
Reply With Quote #3

My first try was to look of this plugin: http://forums.alliedmods.net/showthread.php?t=158363
But i'm not the Sourcepawn Array Master.

--

Thank you Bacardi.
Very nice Idea. I try it and will report soon.


-
__________________



Sorry for my very bad english
Greetings HSFighter

Last edited by HSFighter; 11-21-2011 at 11:38.
HSFighter is offline
Send a message via ICQ to HSFighter
HSFighter
Veteran Member
Join Date: Aug 2007
Location: Flensburg - Germany
Old 11-21-2011 , 11:37   Re: Hook owner of smoke from smokegrenade.
Reply With Quote #4

* Doublepost Sorry *
__________________



Sorry for my very bad english
Greetings HSFighter

Last edited by HSFighter; 11-21-2011 at 11:38.
HSFighter is offline
Send a message via ICQ to HSFighter
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-21-2011 , 19:14   Re: Hook owner of smoke from smokegrenade.
Reply With Quote #5

Yeah, Peace-Maker have done looking smokegrenade projectile owners and save in array (Haven't spend much time about those arrayes).
Next when smoke particle spawn XYZ, it check array list all smokegrenade projectiles what match with same location.

But I don't see huge difference what I posted... maybe I'm blind.
__________________
Do not Private Message @me

Last edited by Bacardi; 11-21-2011 at 19:16.
Bacardi is offline
HSFighter
Veteran Member
Join Date: Aug 2007
Location: Flensburg - Germany
Old 11-23-2011 , 14:43   Re: Hook owner of smoke from smokegrenade.
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
Yeah, Peace-Maker have done looking smokegrenade projectile owners and save in array (Haven't spend much time about those arrayes).
Next when smoke particle spawn XYZ, it check array list all smokegrenade projectiles what match with same location.

But I don't see huge difference what I posted... maybe I'm blind.
Your example is easier to understand for me
And it work's fine. Thank You Bacardi.

But now i have an other problem.
I try to change the render settings of the smoke.

I seen that Peace-Maker have spawn a light in the smoke.
This will work for 5 sec. (only to test):

PHP Code:
LightCreate(Float:Pos[3])   
{  
    new 
iEntity CreateEntityByName("light_dynamic");
    
DispatchKeyValue(iEntity"inner_cone""0");
    
DispatchKeyValue(iEntity"cone""80");
    
DispatchKeyValue(iEntity"brightness""1");
    
DispatchKeyValueFloat(iEntity"spotlight_radius"150.0);
    
DispatchKeyValue(iEntity"pitch""90");
    
DispatchKeyValue(iEntity"style""1");
    
DispatchKeyValue(iEntity"_light""75 75 255 255");
    
DispatchKeyValueFloat(iEntity"distance"freezedistance);
    
EmitSoundToAll(SOUND_FREEZE_EXPLODEiEntitySNDCHAN_WEAPON);
    
CreateTimer(5.0DeleteiEntityTIMER_FLAG_NO_MAPCHANGE);

    
DispatchSpawn(iEntity);
    
TeleportEntity(iEntityPosNULL_VECTORNULL_VECTOR);
    
AcceptEntityInput(iEntity"TurnOn");
}

public 
Action:Delete(Handle:timerany:entity)
{
    if(
IsValidEdict(entity)) AcceptEntityInput(entity"kill");

But i search an easier way if it's possible?

Here my Code.
But nothing happens :

PHP Code:

#include <sdktools>

#define K_RENDER_NORMAL            0
#define K_RENDER_TRANS_COLOR    1

new g_Color[4]   = {25500255}; // Red

new g_RenderModeOffset;
new 
g_RenderClrOffset;

public 
OnPluginStart()
{
    
g_RenderModeOffset FindSendPropOffs("ParticleSmokeGrenade""m_nRenderMode");
    
g_RenderClrOffset FindSendPropOffs("ParticleSmokeGrenade""m_clrRender");
}


// public Action here...
{
    
UTIL_Render(entg_Color);    
}


UTIL_Render(ent, const color[4])
{
    
PrintToChatAll("Ent ---> %i"ent);
    new 
mode = (color[3] == 255) ? K_RENDER_NORMAL K_RENDER_TRANS_COLOR;
    
    
SetEntData(entg_RenderModeOffsetmode1);
    
SetEntDataArray(entg_RenderClrOffsetcolor41);
    
ChangeEdictState(ent);
    

__________________



Sorry for my very bad english
Greetings HSFighter

Last edited by HSFighter; 11-23-2011 at 18:49.
HSFighter is offline
Send a message via ICQ to HSFighter
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 18:08.


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