Thread: [Solved] Can SDKCall Return String?
View Single Post
Author Message
ABCDEFGH23
Junior Member
Join Date: Jun 2020
Location: HEEELP!!!
Old 10-02-2020 , 20:51   Can SDKCall Return String?
Reply With Quote #1

PHP Code:

ConditionNames
:

"TF_COND_AIMING"(0)
"TF_COND_ZOOMED"(4)
"TF_COND_DISGUISING"(8)
"TF_COND_DISGUISED"(0xC//12
"TF_COND_STEALTHED"(0x10//16
"TF_COND_INVULNERABLE"(0x14//20
.
.

PHP Code:
GetTFConditionName(int condition){
if(
condition 129)return 0;
return 
DS:ConditionNames[condition*4];


PHP Code:
"GetTFConditionName"
{
"library" "server"
"windows"    "\x55\x8B\xEC\x8B\x45\x08\x3D\x82\x00\x00\x00"
"linux"        "@_Z18GetTFConditionName7ETFCond"
"mac"        "@_Z18GetTFConditionName7ETFCond"

PHP Code:
Handle hTestHandle;

public 
void OnPluginStart(){

Handle Config LoadGameConfigFile("TextFile");

StartPrepSDKCall(SDKCall_Static);
PrepSDKCall_SetFromConf(ConfigSDKConf_Signature"GetTFConditionName");
PrepSDKCall_SetReturnInfo(SDKType_StringSDKPass_Pointer);

/*
i tried SDKType_PlainOldData, SDKPass_Pointer,
SDKType_PlainOldData, SDKPass_ByRef,
even SDKType_PlainOldData, SDKPass_ByVal,
well it worked, but it prints DWORD size, like this "TF_C", "Y{'Q"
+ SDKType_String, SDKPass_ByRef, ByVal, Pointer = runtime error
*/

PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
hTestHandleEndPrepSDKCall();

//PrintToServer("%d", hTestHandle) -> 49..1, Valid Handle

CloseHandle(Config);

RegConsoleCmd("sm_string_test"stringtest);

}
public 
Action stringtest(int clientint args){

char test[30];

test SDKCall(hTestHandle5); //compile error

PrintToConsole(client"%s"test);

return 
Plugin_Handled;


Solved!!!!!!!!! YES!!!! Many Thank YOU!!!!

PHP Code:

//-------------Solved-------------

Handle hGetTFConditionName;
Handle hStrCopy;

public 
void OnPluginStart(){

Handle Config LoadGameConfigFile("TextFile");

StartPrepSDKCall(SDKCall_Static);
PrepSDKCall_SetFromConf(ConfigSDKConf_Signature"GetTFConditionName");
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
hGetTFConditionName EndPrepSDKCall();

StartPrepSDKCall(SDKCall_Static);
PrepSDKCall_SetFromConf(ConfigSDKConf_Signature"V_strncpy");
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
hStrCopy EndPrepSDKCall();

CloseHandle(Config);

RegConsoleCmd("sm_string_test"stringtest);

}

public 
Action stringtest(int clientint args){

char test[30];
SDKCall(hStrCopytestSDKCall(hGetTFConditionName33), 30); 
PrintToConsole(client"%s"test); //worked!

return Plugin_Handled;

}
//------------------------------- 

Last edited by ABCDEFGH23; 10-03-2020 at 00:18.
ABCDEFGH23 is offline