View Single Post
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 07-07-2020 , 13:16   Re: Hook an event to trigger a command
Reply With Quote #4

If anyone wanna know i found the way, the code example i use for testing is:

Code:
#pragma semicolon 1

#include <sourcemod>

public OnPluginStart()
{
	HookEvent("player_hurt", test);
}

public Action:test(Handle:event, const String:name[], bool dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	CreateTimer(0.0, lmao, client);
}

public Action:lmao(Handle:timer, any:client)
{
	if (client == 0)
	{
		return Plugin_Continue;
	}
	if (IsPlayerAlive(client))
	{
		FakeClientCommandEx(client, "kill");
	}
	return Plugin_Handled;
}
keep in mind this may spew out some invalid client index errors at some points
__________________
Teamkiller324 is offline