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

Working with SDKCalls


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-28-2009 , 21:08   Working with SDKCalls
Reply With Quote #1

I should point out now that I am developing for a Linux Team Fortress 2 server.

So I have just discovered the joys of offsets. For my latest plugin mock-up I would like to return the names of weapons as they appear in the kill cam as these weapons names are names that people recognise rather than being tf_weapon_bat_wood etc. I had a look in CBaseCombatWeapon and found a few functions that looked interesting however I have no idea how to use them. My problem being is how do I know what parameters to add when I am preparing the SDK call and what I should expect to be returned.

I already have a few SDK calls such as this:
PHP Code:
    StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetFromConf(gameConfSDKConf_Virtual"GiveNamedItem");
    
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
PrepSDKCall_SetReturnInfo(SDKType_CBaseEntitySDKPass_Plain);
    
giveNamedItem EndPrepSDKCall(); 
MikeJS coded the above block and it works 100%. What I would like to know is how would I find out these parameters and returns for myself for something like this:
PHP Code:
    StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetFromConf(gameConfSDKConf_Virtual"GetDeathNoticeName");
/*  Some Parameters
    and returns in here */
    
getDeathNoticeName EndPrepSDKCall(); 
Thanks in advance for your time and advice.
Wazz is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-29-2009 , 16:14   Re: Working with SDKCalls
Reply With Quote #2

Ok I am getting desparate now, why wont something like this return a string:

PHP Code:
new Handle:getPrintName
PHP Code:
    gameConf LoadGameConfigFile("test.games");

    
StartPrepSDKCall(SDKCall_Entity);
    
PrepSDKCall_SetFromConf(gameConfSDKConf_Virtual"GetPrintName");
    
PrepSDKCall_SetReturnInfo(SDKType_StringSDKPass_Pointer);
    
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
    
getPrintNameEndPrepSDKCall(); 
PHP Code:
    new String:testStr[64];
    
SDKCall(getPrintNameenttestStr64);            
    
PrintToChat(client"SDK Call: %s"testStr); 
The offsets should be correct but here they are anyway:
Code:
"Games"
{
    "tf"
    {
        "Offsets"
        {
            "GetPrintName"
            {
                "windows"    "307"
                "linux"      "308"
            }
        }
    }
}
Any ideas what I am doing wrong? In-game there are no errors just a string in my chat log saying "SDK Call: "
Wazz is offline
pRED*
Join Date: Dec 2006
Old 05-29-2009 , 18:43   Re: Working with SDKCalls
Reply With Quote #3

You've set return info twice.

Remove

PrepSDKCall_SetReturnInfo(SDKType_PlainOldDat a, SDKPass_Plain);
pRED* is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-29-2009 , 19:08   Re: Working with SDKCalls
Reply With Quote #4

So you can only use ReturnInfo once per prep? I didn't have much to go on so I guessed there would be 2 returns, one for the string and one for the size of the string. Anyway, thanks for the info

Just a quick edit: Thanks again pRED, that was what I needed to know to get me going. I have actually managed to construct a plugin that blocks selected unlockable weapons for TF2

Last edited by Wazz; 05-29-2009 at 21:25.
Wazz is offline
pRED*
Join Date: Dec 2006
Old 05-29-2009 , 21:43   Re: Working with SDKCalls
Reply With Quote #5

C++ only supports a single return value for functions. Any other return data must be returned by reference through params (note the copyback flags).

Strings returned are NULL ('\0') terminated to determine the length.
pRED* 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 22:32.


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