Raised This Month: $9 Target: $400
 2% 

Solved Can SDKCall Return String?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ABCDEFGH23
Junior Member
Join Date: Jun 2020
Location: HEEELP!!!
Old 10-02-2020 , 21: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 01:18.
ABCDEFGH23 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 10-02-2020 , 23:25   Re: Can SDKCall Return String?
Reply With Quote #2

Yep. This is what I use in Info Editor plugin to return strings from an SDKCall:

PHP Code:
    StartPrepSDKCall(SDKCall_Raw);
    if( 
PrepSDKCall_SetFromConf(hGameDataSDKConf_Signature"KeyValues::GetString") == false )
        
SetFailState("Could not load the \"KeyValues::GetString\" gamedata signature.");
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
PrepSDKCall_SetReturnInfo(SDKType_StringSDKPass_Pointer);
    
SDK_KV_GetString EndPrepSDKCall();
    if( 
SDK_KV_GetString == null )
        
SetFailState("Could not prep the \"KeyValues::GetString\" function.");


        
char key[MAX_STRING_LENGTH];
        
char value[MAX_STRING_LENGTH];
        
SDKCall(SDK_KV_GetStringg_PointerMissionvaluesizeof(value), key"N/A"); 
The "key" var is what it's looking for, the "value" var is what it's returning and the "N/A" is the default returned if not found. I think SM wiki explains all this which is where I learnt to SDKCall and return strings.
__________________

Last edited by Silvers; 10-02-2020 at 23:25.
Silvers is offline
ABCDEFGH23
Junior Member
Join Date: Jun 2020
Location: HEEELP!!!
Old 10-03-2020 , 01:13   Re: Can SDKCall Return String?
Reply With Quote #3

Many Thank You!
ABCDEFGH23 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 06:47.


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