Raised This Month: $32 Target: $400
 8% 

Trying to detour IsSpawnPointValid in CSGO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Effeff
AlliedModders Donor
Join Date: Jan 2019
Location: discord: ff#0533
Old 02-21-2021 , 19:22   Trying to detour IsSpawnPointValid in CSGO
Reply With Quote #1

My goal is to accomplish what this plugin does, but different https://forums.alliedmods.net/showthread.php?t=260532

I see three relevant functions:

CTeamSpawnPoint::IsValid
(I don't think I'm allowed to link the csgo leak, but it's in team_spawnpoint.cpp)

CGameRules::IsSpawnPointValid

CCSGameRules::IsSpawnPointValid

I used IDA Freeware to find the signatures for these three, and I wrote the following code to try it out.

Code:
"Games"
{
	"csgo"
	{
		"Signatures"
		{
			"CTeamSpawnPoint::IsValid"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x57\x56\x53\x81\xEC\x2C\x08\x00\x00\x8B\x5D\x08"
			}
			"CGameRules::IsSpawnPointValid"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x57\x56\x53\x81\xEC\x2C\x08\x00\x00\x8B\x5D\x0C"
			}
			"CCSGameRules::IsSpawnPointValid"
			{
				"library"	"server"
				"linux"		"\x55\x89\xE5\x81\xEC\x88\x00\x00\x00\x89\x5D\xF4\x8B\x5D\x0C\x8B\x55\x10"
			}
		}
		"Functions"
		{
			"CTeamSpawnPoint::IsValid"
			{
				"signature"	"CTeamSpawnPoint::IsValid"
				"callconv"	"thiscall"
				"return"	"bool"
				"this"		"ignore"
			}
			"CGameRules::IsSpawnPointValid"
			{
				"signature"	"CGameRules::IsSpawnPointValid"
				"callconv"	"thiscall"
				"return"	"bool"
				"this"		"ignore"
			}
			"CCSGameRules::IsSpawnPointValid"
			{
				"signature"	"CCSGameRules::IsSpawnPointValid"
				"callconv"	"thiscall"
				"return"	"bool"
				"this"		"ignore"
			}
		}
	}
}
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <dhooks>

ConVar cvar_SolidTeammates;

Handle g_hGameData;

Handle g_dhIsSpawnPointValidDetour;

public 
void OnPluginStart()
{
    
cvar_SolidTeammates FindConVar("mp_solid_teammates");
    
    
g_hGameData LoadGameConfigFile("detour_csgo_spawns.games2");
    
    if (
g_hGameData == null)
    {
        
SetFailState("failed to load game config file");
    }
    else
    {
        
PrintToChatAll("gamedata is not null");
    }
    
    
g_dhIsSpawnPointValidDetour DHookCreateDetour(Address_NullCallConv_THISCALLReturnType_BoolThisPointer_Ignore);
    
    if (
g_dhIsSpawnPointValidDetour == null)
    {
        
SetFailState("failed to setup spawnpoint valid hook");
    }
    else
    {
        
PrintToChatAll("hook setup success");
    }
    
    if (!
DHookSetFromConf(g_dhIsSpawnPointValidDetourg_hGameDataSDKConf_Signature"<insert signature name here>"))
    {
        
SetFailState("failed to load spawnpoint valid signature");
    }
    else
    {
        
PrintToChatAll("hook load success");
    }
    
    if (!
DHookEnableDetour(g_dhIsSpawnPointValidDetourfalseDetour_IsSpawnPointValid))
    {
        
SetFailState("failed to detour spawnpoint valid");
    }
    else
    {
        
PrintToChatAll("detour success");
    }
}

public 
MRESReturn Detour_IsSpawnPointValid(Handle hReturnHandle hParams)
{
    if (!
cvar_SolidTeammates.BoolValue)
    {
        
PrintToChatAll("Detour_IsSpawnPointValid called, changing return value to true");
        
DHookSetReturn(hReturntrue);
        return 
MRES_Override;
    }
    
PrintToChatAll("Detour_IsSpawnPointValid called, not changing return value");
    return 
MRES_Ignored;

There were no errors when I tried the first function. However, the detour never actually "occurs".
The latter two functions resulted in errors in DHookSetFromConf.

I'm not sure how to proceed from here, and am not sure if I am doing something wrong. Never attempted to use dhooks before this.

Last edited by Effeff; 02-21-2021 at 20:07.
Effeff is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-23-2021 , 05:35   Re: Trying to detour IsSpawnPointValid in CSGO
Reply With Quote #2

From what I know, mp_solid_teammates 0 or 2 will spawn players in the same spawnpoint if none available.
What are you trying to accomplish?
__________________
Ilusion9 is offline
Effeff
AlliedModders Donor
Join Date: Jan 2019
Location: discord: ff#0533
Old 02-23-2021 , 09:27   Re: Trying to detour IsSpawnPointValid in CSGO
Reply With Quote #3

Quote:
Originally Posted by Ilusion9 View Post
From what I know, mp_solid_teammates 0 or 2 will spawn players in the same spawnpoint if none available.
What are you trying to accomplish?
There seems to be a limit of how many players can spawn (or even join a team) based off the number of spawnpoints on a map. I want to try and see if any of these functions are related.

Here's what I have 'observed' but am not certain if it happens the way I think it does (when I tried the map with 1 spawnpoint, it was with mp_solid_teammates 2):

A map only has one spawnpoint for each team, and 20 people are joining. I have a plugin that automatically forces players onto teams when they join. It will only allow two people to spawn, and the rest will be stuck on the UNASSIGNED(?) team. If those players manually join a team later on, they will be able to. I believe it is because at this point the first two players who successfully spawned end up moving somewhere else.

Last edited by Effeff; 02-23-2021 at 09:28.
Effeff is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-23-2021 , 14:33   Re: Trying to detour IsSpawnPointValid in CSGO
Reply With Quote #4

PHP Code:

AddCommandListener
(CommandListener_JoinTeam"jointeam");    

public 
Action CommandListener_JoinTeam(int client, const char[] commandint args)
{
    if (!
IsEntityClient(client) || !IsClientInGame(client))
    {
        return 
Plugin_Handled;
    }
    
    
char arg[3];
    
GetCmdArg(1argsizeof(arg));
    
    
int toTeam;
    if (!
StringToIntEx(argtoTeam) || toTeam CS_TEAM_SPECTATOR || toTeam CS_TEAM_CT || GetClientTeam(client) == toTeam)
    {
        return 
Plugin_Handled;
    }
    
    if (
IsPlayerAlive(client))
    {
        
ForcePlayerSuicide(client);
    }
    
    
ChangeClientTeam(clienttoTeam);
    return 
Plugin_Handled;

I use this and never had problems with player spawns. (I use noblock as well).
__________________
Ilusion9 is offline
Effeff
AlliedModders Donor
Join Date: Jan 2019
Location: discord: ff#0533
Old 02-23-2021 , 17:51   Re: Trying to detour IsSpawnPointValid in CSGO
Reply With Quote #5

Quote:
Originally Posted by Ilusion9 View Post
<spliced out code>

I use this and never had problems with player spawns. (I use noblock as well).
I just tried this and it didn't make a difference with solving the issue I am describing. I suspect that there is something funky going on and "jointeam" doesn't get called at all.

It is particular to my own implementation though.

Anyway. It gave me an idea for an alternate solution to my problem. Instead of ClientCommand jointeam, do RequestFrame + ChangeClientTeam. It seems to work.

I will reply to the ExtraSpawnPoints thread with my findings.
Effeff 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 18:00.


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