Hello Modders,
I want to write a simple plugin which sets the player animation to any of the default existing animations.
I tried with this code from
Andersso:
Code:
#include <sourcemod>
#include <sdktools>
public OnPluginStart()
{
AddTempEntHook("PlayerAnimEvent", OnPlayerAnimEvent);
RegConsoleCmd("test_playeranimevent", Command_TestPlayerAnimEvent);
}
public Action:OnPlayerAnimEvent(const String:te_name[], const Players[], numClients, Float:delay)
{
new client = TE_ReadNum("m_hPlayer");
new event = TE_ReadNum("m_iEvent");
new data = TE_ReadNum("m_nData");
PrintToChatAll("AnimEvent: Player: %i, Event: %i, Data: %i", client, event, data);
}
public Action:Command_TestPlayerAnimEvent(client, args)
{
decl String:arg1[64], String:arg2[64], String:arg3[64];
GetCmdArg(1, arg1, sizeof(arg1));
GetCmdArg(2, arg2, sizeof(arg2));
GetCmdArg(3, arg3, sizeof(arg3));
TE_Start("PlayerAnimEvent");
TE_WriteNum("m_hPlayer", StringToInt(arg1));
TE_WriteNum("m_iEvent", StringToInt(arg2));
TE_WriteNum("m_nData", StringToInt(arg3));
TE_SendToAll();
}
And tested it on my servers, and worked ! but there is a big problem with this code: It doesn't tell me the client number (from the server perspective)
Example: client=0 is the server itself, client=1 is usually the first player entering game, etc.
I would like to write a simple function that sets a client (argument by clientId) animation to any of the default ones (like crouching, knife, etc)