Raised This Month: $ Target: $400
 0% 

Solved [L4D2]Get SDKHooks StartTouch toucher index


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Morning
Member
Join Date: May 2021
Old 04-06-2022 , 10:58   [L4D2]Get SDKHooks StartTouch toucher index
Reply With Quote #1

I want to use StartTouch to detect when a player touches an entity or vice-versa so I can do something with either player or entity. Im having the problem of not being able to access the other's index.

I found this thread, but that relates to a player touching a tank bot and I can't make it work for me. I don't have much code to go on because I don't know weather I should be hooking touch on the player or entity to start with. I would prefer to hook touch on the entity because the entity won't be moving around touching lots of other items, for example:
Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public Action Spawn(char model[64], char origin[128])
{
	int entity = CreateEntityByName("prop_physics_override");
	DispatchKeyValue(entity, "count", "1");
	DispatchKeyValue(entity, "collisions", "1");
	DispatchKeyValue(entity, "spawnflags", "11");
	DispatchKeyValue(entity, "origin", origin);
	DispatchKeyValue(entity, "model", model); 
	DispatchSpawn(entity);
	SDKHook(entity, SDKHook_StartTouch, Touch_Player);
}

public Action Touch_Player(int entity)
{

}

Last edited by Morning; 04-06-2022 at 11:18.
Morning is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 04-06-2022 , 11:09   Re: [L4D2]Get SDKHooks StartTouch toucher index
Reply With Quote #2

You callback is wrong, check: sdkhooks.inc

PHP Code:
    // EndTouch
    // StartTouch
    // Touch
    // Blocked
    
function Action (int entityint other);

    
// EndTouchPost
    // StartTouchPost
    // TouchPost
    
function void (int entityint other); 
Where entity is "the entity/client you hooked" and other is the "other touching entity" (e.g. player)

Should be

PHP Code:
public Action Touch_Player(int entityint other)
{
    
PrintToChatAll("entity %i, is touching %i"entityother);

    return 
Plugin_Continue;

And if you won't change the behavior, is safer to use StartTouchPost
__________________

Last edited by Marttt; 04-07-2022 at 13:36.
Marttt is offline
Morning
Member
Join Date: May 2021
Old 04-06-2022 , 11:17   Re: [L4D2]Get SDKHooks StartTouch toucher index
Reply With Quote #3

Okay, now i feel stupid! Thanks Marttt
Morning 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 11:10.


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