AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [CSGO] Turning Thrown Grenades Into Footballs (https://forums.alliedmods.net/showthread.php?t=327837)

SweetDickWilly 10-12-2020 19:32

[CSGO] Turning Thrown Grenades Into Footballs
 
I am creating a CSGO plugin and attempting to turn grenades into a ball; have the ability to be caught and picked up on the ground by all players. I already have some of the projectile logic working but can't seem to allow players the ability to touch the ball at all. Can anyone point me in the right direction? So far I have the following:

PHP Code:

public void OnEntityCreated(int entity, const char[] classname)
{
    if(
StrContains(classname"_projectile") != -1SDKHook(entitySDKHook_SpawnPostGrenade_SpawnPost);
    if(
StrContains(classname"_projectile") != -1SDKHook(entitySDKHook_StartTouch, Catch);    
}

public 
void Grenade_SpawnPost(int entity)
{
    
int client GetEntPropEnt(entityProp_Send"m_hOwnerEntity"); 
    if (
client == -1)return; // if the client's index is -1, stop
    
int iReference EntIndexToEntRef(entity); 
    
CreateTimer(0.1Timer_OnGrenadeCreatediReference);
}

public 
Action Timer_OnGrenadeCreated(Handle timerany ref)
{
  
int entity EntRefToEntIndex(ref);
  if(
entity != INVALID_ENT_REFERENCE)
  {
    
SetEntProp(entityProp_Data"m_nNextThinkTick", -1); // block grenade explosion
  
}
}

public 
void Catch (int clientint entity)
{
    if (!
IsValidEntity(entity))
        return;
    
    
PrintToChatAll("the football has hit something");    


At current, when a player throws a grenade/ball off the wall the player cannot catch the grenade; the grenade goes through the player's body. Do I need to set an ent's property or is one of my functions interfering in some way?

Cruze 10-13-2020 04:58

Re: [CSGO] Turning Thrown Grenades Into Footballs
 
PHP Code:

public void OnEntityCreated(int entity, const char[] classname)
{
    if(
StrContains(classname"_projectile") != -1SDKHook(entitySDKHook_SpawnPostGrenade_SpawnPost);
    if(
StrContains(classname"_projectile") != -1SDKHook(entitySDKHook_StartTouch, Catch);
}

public 
void Grenade_SpawnPost(int entity)
{
    
int client GetEntPropEnt(entityProp_Send"m_hOwnerEntity");
    if (
client == -1)return; // if the client's index is -1, stop
    
int iReference EntIndexToEntRef(entity);
    
CreateTimer(0.1Timer_OnGrenadeCreatediReference);
}

public 
Action Timer_OnGrenadeCreated(Handle timerany ref)
{
    
int entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
    {
        
SetEntProp(entityProp_Data"m_nNextThinkTick", -1); // block grenade explosion
        
SetEntProp(entityProp_Send"m_CollisionGroup"5);
    }
}

public 
void Catch (int clientint entity)
{
    if (!
IsValidEntity(entity))
        return;

    
PrintToChatAll("the football has hit something");    


Try this

SweetDickWilly 10-15-2020 15:39

Re: [CSGO] Turning Thrown Grenades Into Footballs
 
Thank you, as your suggestion worked for picking up thrown grenades off the ground and I intended to create this behavior. If you want to allow the thrower the ability to catch his/her's own grenade after throwing it in the air or bouncing it off a wall you have to reset the entity property named "m_hOwnerEntity".

PHP Code:

SetEntPropEnt(entityProp_Send"m_hOwnerEntity", -1); 



All times are GMT -4. The time now is 10:22.

Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.