Raised This Month: $51 Target: $400
 12% 

[RESOLVED] Detect when player touches?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-05-2011 , 04:54   [RESOLVED] Detect when player touches?
Reply With Quote #1

I want to detect when a player touches a player, and when a player touches a door. How can I achieve this via sourcemod?

I know in AmxModX, I can register_touch("player","player","player_touc hedplayer"), but how do I go about doing this in sourcemod?

Thanks.
__________________


Last edited by mysticssjgoku4; 06-05-2011 at 13:56.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-05-2011 , 05:15   Re: Detect when player touches?
Reply With Quote #2

I seemed to have found my own answer, although not as efficient as I wanted...

Using SDKHooks,
Code:
public OnClientPutInServer(id)
{
	SDKHook(id, SDKHook_StartTouch, Start_Touch);
}

public OnClientDisconnect(id)
{
	SDKUnhook(id, SDKHook_StartTouch, Start_Touch);
}

//Toucher/Touched object
//Toucher should always be player..
public Action:Start_Touch(e1, e2)
{
}
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-05-2011 , 05:16   Re: Detect when player touches?
Reply With Quote #3

You don't need to use:
PHP Code:
public OnClientDisconnect(id)
{
    
SDKUnhook(idSDKHook_StartTouchStart_Touch);

__________________
xbatista is offline
Send a message via Skype™ to xbatista
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-05-2011 , 05:18   Re: Detect when player touches?
Reply With Quote #4

Quote:
Originally Posted by xbatista View Post
You don't need to use:
PHP Code:
public OnClientDisconnect(id)
{
    
SDKUnhook(idSDKHook_StartTouchStart_Touch);

Thanks.
Would you happen to know how to invoke an entity? IE, say... push a button or use a door through code?
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-05-2011 , 05:21   Re: Detect when player touches?
Reply With Quote #5

You mean when player presses 'E' button on entity?
__________________

Last edited by xbatista; 06-05-2011 at 05:23.
xbatista is offline
Send a message via Skype™ to xbatista
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-05-2011 , 05:24   Re: Detect when player touches?
Reply With Quote #6

No, I mean being able to invoke an entity not by player, but by activation through code. Somehow invoke a door, or button.
I tried, ActivateEntity to no avail.
http://docs.sourcemod.net/api/index....d=show&id=675&
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
KawMAN
SourceMod Donor
Join Date: Sep 2007
Location: Cracov
Old 06-05-2011 , 18:24   Re: [RESOLVED] Detect when player touches?
Reply With Quote #7

Try AcceptEnitiyInput and Toggle (or any other) input:
http://developer.valvesoftware.com/wiki/Func_door

like:
SetVariantString("");
AcceptEntityInput(some_door_ent_id, "Toogle");
__________________
KawMAN is offline
Send a message via ICQ to KawMAN Send a message via Skype™ to KawMAN
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-05-2011 , 18:55   Re: [RESOLVED] Detect when player touches?
Reply With Quote #8

I know it's solved and all, but just a few posts below.. https://forums.alliedmods.net/showthread.php?t=158511
__________________
Silvers is offline
Reply



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 14:20.


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