Raised This Month: $120 Target: $400
 30% 

Touch event for client


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertimor
Member
Join Date: Sep 2017
Old 12-08-2018 , 10:51   Touch event for client
Reply With Quote #1

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;
}

Last edited by supertimor; 12-08-2018 at 10:53.
supertimor is offline
supertimor
Member
Join Date: Sep 2017
Old 12-09-2018 , 07:22   Re: Touch event for client
Reply With Quote #2

Someone? It can't be so hard to do.

// ofc i am hooking player on respawn

Code:
public Action:Event_PlayerRespawn(Handle:event, String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(!IsValidClient(client) || !ma_klase[client])
		return Plugin_Continue;
 
	SDKHook(client, SDKHook_StartTouchPost, DotykMiny);
	PrintToChat(client, "Zahookowany przez respawn");		
	return Plugin_Continue;
}

Last edited by supertimor; 12-09-2018 at 07:26.
supertimor is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:49.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode