PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
if(!strcmp(classname, "game_player_equip"))
{
SDKHook(entity, SDKHook_Spawn, Hook_OnEntitySpawn);
}
}
public Action Hook_OnEntitySpawn(int entity)
{
char weapon[33];
GetEntPropString(entity, Prop_Data, "m_weaponNames", weapon, sizeof(weapon), 0);
if(StrContains(weapon, "knife") != -1)
{
AcceptEntityInput(entity, "Kill");
}
}
this works fine, but i dont like hooking with spawn and then killing the entity.
PHP Code:
int target = -1;
while((target = FindEntityByClassname(target, "game_player_equip")) != -1)
{
char weapon[33];
GetEntPropString(entity, Prop_Data, "m_weaponNames", weapon, sizeof(weapon), 0);
if(StrContains(weapon, "knife") != -1)
{
AcceptEntityInput(entity, "Kill");
}
}
if i try like this in round_start, its too late. it works only after the first respawn.
if i try in round_prestart it doesnt works. any ideas? maybe with EventHookMode_Pre in round start?