View Single Post
Beaverboys
Member
Join Date: Aug 2012
Old 05-18-2015 , 22:25   Re: Using SDKHook_Touch with grenades?
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
Out of curiosity, have you tried hooking SDKHook_SpawnPost in OnEntityCreated?
I tried this and it didn't work, it actually made the SetEntProp line not work anymore as well
PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if(!
strcmp(classname"hegrenade_projectile"false))
    {
        new 
iReference EntIndexToEntRef(entity);
        
SDKHook(iReference,SDKHook_SpawnPost,OnGrenadeCreated);
    }
}

public 
Action:OnGrenadeCreated(ref)
{
    new 
entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
        
SetEntProp(entityProp_Data"m_nNextThinkTick", -1); // prevent the grenade from exploding
    
SDKHook(entity,SDKHook_Touch,GrenadeTouch);
}

public 
GrenadeTouch(entity,other)
{
    if (
<= other <= MaxClients// grenade touches a player
        
PrintToServer("Player touched a grenade");

Beaverboys is offline