Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dhook PassServerEntityFilter is not work #137

Closed
gaejuck opened this issue Apr 23, 2024 · 3 comments · Fixed by #138
Closed

Dhook PassServerEntityFilter is not work #137

gaejuck opened this issue Apr 23, 2024 · 3 comments · Fixed by #138

Comments

@gaejuck
Copy link

gaejuck commented Apr 23, 2024

Strangely, Detour_PassServerEntityFilterPost is not responding I don't know why.

SourceMod Version Information

    SourceMod Version: 1.12.0.7116
    SourcePawn Engine: 1.12.0.7116, jit-x86 (build 1.12.0.7116)
    SourcePawn API: v1 = 5, v2 = 16
    Compiled on: Apr 18 2024 04:45:06
    Built from: https://github.com/alliedmodders/sourcemod/commit/6cac489f
    Build ID: 7116:6cac489f
    http://www.sourcemod.net/

Metamod:Source Version Information

   Metamod:Source version 1.12.0-dev+1192
   Plugin interface version: 16:14
   SourceHook version: 5:5
   Loaded As: Valve Server Plugin
   Compiled on: Feb  7 2024 16:03:42
   Built from: https://github.com/alliedmodders/metamod-source/commit/837fa2c
   Build ID: 1192:837fa2c
   http://www.metamodsource.net/

Additionally, it's running in linux server.

@FortyTwoFortyTwo
Copy link
Member

In linux, this function now have a clone version of it. Not sure if there is a way to be able to detour either of it

@gaejuck
Copy link
Author

gaejuck commented Apr 25, 2024

It's working. But sometime clients seems to always return ret.Value= false.
These clients can't touch with attack and they doesn't work to noblock with enemy teams.

@gaejuck
Copy link
Author

gaejuck commented Apr 28, 2024

It's working. But sometime clients seems to always return ret.Value= false. These clients can't touch with attack and they doesn't work to noblock with enemy teams.

This problem was solved by modifying it like the code below.

public MRESReturn Detour_PassServerEntityFilterPost(DHookReturn ret, DHookParam param)
{
	if (!ret || param.IsNull(1) || param.IsNull(2))
	{
		return MRES_Ignored;
	}
	
	int touch_ent = param.Get(1);
	int pass_ent  = param.Get(2);
	
	if (!IsValidEntity(touch_ent) || !IsValidEntity(pass_ent))
	{
		return MRES_Ignored;
	}
	
	bool touch_is_player = touch_ent > 0 && touch_ent <= MaxClients && IsPlayerAlive(touch_ent);
	bool pass_is_player  = pass_ent > 0 && pass_ent <= MaxClients && IsPlayerAlive(pass_ent);
	
	if ((touch_is_player && pass_is_player) || (!touch_is_player && !pass_is_player))
	{
		ret.Value = true;
		return MRES_Supercede;
	}
	
	int entity = touch_is_player ? pass_ent : touch_ent;
	
	char classname[64];
	GetEntityClassname(entity, classname, sizeof(classname));
	
	if (strncmp(classname, "func_door", sizeof(classname)) != 0 && strncmp(classname, "func_movelinear", sizeof(classname)) != 0)
	{
		ret.Value = true;
		return MRES_Supercede;
	}
	
	int client = touch_is_player ? touch_ent : pass_ent;
	
	ret.Value = !Classes_OnDoorWalk(client, entity);
	return MRES_Supercede;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants