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

Solved Calling engine function with SDKCall


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
root88
Senior Member
Join Date: May 2016
Old 01-26-2022 , 17:07   Calling engine function with SDKCall
Reply With Quote #1

Hi!
Can you help me with finishing the plugin below? What I wanna do is getting real server fps at the moment by calling:
Code:
CEngine::GetFrameTime
This if for CSGO.
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

Handle hFunction;

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_test_call"cmdTestCallADMFLAG_ROOT"Test command");
    
GameData hGameConf = new GameData("root.game.csgo");
    if(!
hGameConf)
    {
        
SetFailState("sourcemod/gamedata/root.game.csgo.txt' is missing!");
    }
    
StartPrepSDKCall(SDKCall_Raw);
    if(!
PrepSDKCall_SetFromConf(hGameConfSDKConf_Signature"CEngine::GetFrameTime"))
    {
        
SetFailState("CEngine::GetFrameTime signature not found!");
    }
    
PrepSDKCall_SetReturnInfo(SDKType_FloatSDKPass_Plain);
    
hFunction EndPrepSDKCall();
}

public 
Action cmdTestCall(int clientint args)
{
    
PrintToChatAll("FPS: %.2f"1.0/SDKCall(hFunction, ??));
    return 
Plugin_Handled;    

My gamedata:
Code:
"Games"
{
	"csgo"
	{
		"Signatures"
		{
			"CEngine::GetFrameTime"
			{
				"library"		"engine"
				"linux"			"\x55\x89\xE5\x8B\x45\x08\x5D\xD9\x40\x18\xC3"
			}
			
		}
	}
}
Any advices welcome.
__________________

Last edited by root88; 01-27-2022 at 12:18.
root88 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-26-2022 , 21:39   Re: Calling engine function with SDKCall
Reply With Quote #2

hmmm
[CS:GO] Getting "SV" and "Var" values
__________________
Do not Private Message @me
Bacardi is offline
root88
Senior Member
Join Date: May 2016
Old 01-27-2022 , 07:22   Re: Calling engine function with SDKCall
Reply With Quote #3

Thanks for the tip, but with this method we can only get those 3 mentioned values (attachement).

EDIT: This will probalby work (1000.0*GetFrameComputationTime()), I will try to update signature and test it.
EDIT2: This works (CSGO, linux only):
PHP Code:
#include <sourcemod>
#include <sdktools>

static Address ptrFPS Address_Null;

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
RegAdminCmd("sm_fps"cmdFPSADMFLAG_ROOT"Test command");
}

public 
Action cmdFPS(int clientint args)
{
    
PrintToServer("FPS: %f"GetServerFPS());
    return 
Plugin_Handled;
}

static 
void LoadSVVarGameConf()
{
    
Handle hConfig LoadGameConfigFile("root.game.csgo");
    if (
hConfig == null)
        
ThrowError("Failed to load root.game.csgo");
    
    
ptrFPS GameConfGetAddress(hConfig"HostTimeFrame");
    if (
ptrFPS == Address_Null)
        
ThrowError("Failed to look up HostTimeFrame");
    
    
delete hConfig;
}

float GetServerFPS()
{
    if (
ptrFPS == Address_Null)
    {
        
LoadSVVarGameConf();
    }
    
    return 
1.0/view_as<float>(LoadFromAddress(ptrFPSNumberType_Int32));

Code:
"Games"
{
	"csgo"
	{
		"Addresses"
		{
			"HostTimeFrame"
			{
				"linux"
				{
					"signature"	"GetStatsString"				
					"read"		"163"
				}
			}
		}
		"Signatures"
		{
			"GetStatsString"
			{
				"library"	"engine"
				"linux"	"\x55\x31\xC0\x89\xE5\x57\x56\x53\x81\xEC\xCC\x00\x00\x00\x89\x45\xE0\x89\x45\xE4\x8D\x45\xE4\x8B"
			}
		}
	}
}
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	52
Size:	7.7 KB
ID:	193332  
__________________

Last edited by root88; 01-27-2022 at 12:18.
root88 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 00:14.


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