View Single Post
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 08-22-2019 , 14:48   Re: [Question] Entity Index
Reply With Quote #5

Quote:
Originally Posted by Halt View Post
Now I don't want any code, I just want to know if I'm on the right track & what I might do to better improve it.

PLEASE DONT GIVE ME FINISHED CODE

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

public void OnPluginStart()
{
  
HookEvent("OnEntityCreated"Event_EntityCreated);
}

public 
Action Event_EntityCreated(Handle eventint iEntity, const char[] EntityName)
{
  if (
iEntity == "grenade_projectile"
  {
    
int iGrenadeUser GetEntProp(iEntityProp_Data"m_hThrower"); //Gets user for killfeed
    
SetEntProp(iEntity"color""255 0 0"); //Sets Smoke Grenade to Red
  
}

iEntity is an integer (entity index), "grenade_projectile" is a string (entity classname)

You should use GetEntityClassname EntityName and see if it's equal to grenade_projectile using StrEqual function.

You cannot check for m_hThrower at entity creation because it's not set, it is set only after it's spawned and this is where SDKHook comes to to play.

Also, I think m_hThrower is a sendprop so you should use Prop_Send, with the function GetEntPropEnt because it's checking for an entity of the thrower (a player). basically any m_h* is a handle to an entity.

Last edited by TheDS1337; 08-22-2019 at 14:50.
TheDS1337 is offline