Hello, i wanted to make plugin to log message when player touchs specific player.
Touch - unhook, freeze, unfreeze - hook.
But touch event is not working properly, is there a way to hook this on client, and be ready to get touched by another client?
Code:
public OnClientDisconnect(client)
{
SDKUnhook(client, SDKHook_StartTouchPost, PlayerTouch);
}
public Action:PlayerTouch(client, other)
{
new Float:forigin[3];
GetClientEyePosition(client, forigin);
if(client > 0 && client < MaxClients + 1 && other > 0 && other < MaxClients + 1 )
{
SetEntityMoveType(other, MOVETYPE_NONE);
SetEntityRenderMode(other, RENDER_TRANSCOLOR);
SetEntityRenderColor(other, 255, 255, 255, 20);
EmitSoundToAll("weapons/hegrenade/explode5.wav", client, SNDCHAN_AUTO, SNDLEVEL_GUNFIRE);
TE_SetupExplosion(forigin, sprite_explosion, 10.0, 1, 0, 100, 100);
TE_SendToAll();
PrintToChatAll("%s %N został złapany przez %N", PREFIX, client, other);
CreateTimer(4.0, AfterTouch, other);
SDKUnhook(client, SDKHook_StartTouchPost, PlayerTouch);
// PrintToChat(client, "Odhookowany przez dotkniecie");
CreateTimer(4.0, Hooking, client);
LogMessage("%s %N caught by %N", PREFIX, client, other);
}
}
return Plugin_Continue;
}
public Action:Hooking(Handle timer, any client)
{
if(!IsClientInGame(client) || !IsValidClient(client))
return Plugin_Continue;
SDKHook(client, SDKHook_StartTouchPost, PlayerTouch);
PrintToChat(client, "Zahookowany przez timer"); // hooked
return Plugin_Continue;
}
public Action:AfterTouch(Handle timer, other)
{
if(!IsClientInGame(other) || !IsValidClient(other))
return Plugin_Continue;
SetEntityMoveType(other, MOVETYPE_WALK);
SetEntityRenderMode(other, RENDER_TRANSCOLOR);
SetEntityRenderColor(other, 255, 255, 255, 255);
return Plugin_Continue;
}