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

[L4D] PrepSDKCall_SetFromConf returns 0


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Downtown1
Veteran Member
Join Date: Mar 2004
Old 03-11-2009 , 02:44   [L4D] PrepSDKCall_SetFromConf returns 0
Reply With Quote #1

Hello,

I am trying to write a simple plugin to read in the team scores in L4D, which involves using CTerrorGameRules::GetTeamScore and CTerrorGameRules::ClearTeamScores in the L4D server_i486.so

Unfortunately when I get to the PrepSDKCall_SetFromConf part it seems to return 0. Therefore EndPrepSDKCall also returns an INVALID_HANDLE

l4dscores.sp
Code:
/* Plugin Template generated by Pawn Studio */

#include <sourcemod>
#include <sdktools>

public Plugin:myinfo = 
{
	name = "L4D Score Read/Write Test",
	author = "Downtown1",
	description = "Test plugin to read/write team scores",
	version = "1.0",
	url = "<- URL ->"
}

#define SCORE_DEBUG 1

new Handle:gConf = INVALID_HANDLE;
new Handle:fGetTeamScore = INVALID_HANDLE;
new Handle:fClearTeamScores = INVALID_HANDLE;

new bool:bGetTeamScore;
new bool:bClearTeamScores;

public OnPluginStart()
{
	gConf = LoadGameConfigFile("l4dscores");
	if(gConf == INVALID_HANDLE)
	{
		DebugPrintToAll("Could not load gamedata/l4dscores.txt");
	}
	else
	{
		DebugPrintToAll("Loaded gConf, handle = %d", gConf);
	}
	
	StartPrepSDKCall(SDKCall_GameRules);
	bGetTeamScore = PrepSDKCall_SetFromConf(gConf, SDKConf_Signature, "GetTeamScore");
	PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
	PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
	PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
	PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
	fGetTeamScore = EndPrepSDKCall();
	
	StartPrepSDKCall(SDKCall_GameRules);
	bClearTeamScores = PrepSDKCall_SetFromConf(gConf, SDKConf_Signature, "ClearTeamScores");
	fClearTeamScores = EndPrepSDKCall();
	
	
	RegConsoleCmd("sm_getscore", Command_GetTeamScore, "sm_getscore <team> <0|1> <0|1>");
	RegConsoleCmd("sm_clearscore", Command_ClearTeamScores);
}

public Action:Command_GetTeamScore(client, args)
{
	if (args < 3)
	{
		ReplyToCommand(client, "[SM] Usage: sm_getscore <team> <0|1> <0|1>");
		return Plugin_Handled;
	}
	
	if(fGetTeamScore == INVALID_HANDLE)
	{
		DebugPrintToAll("Could not load GetTeamScore function, GetConf = %b", bGetTeamScore);
		return Plugin_Handled;
	}
	
	new String:arg1[64], String:arg2[64], String:arg3[64];
	GetCmdArg(1, arg1, 64);
	GetCmdArg(2, arg2, 64);
	GetCmdArg(3, arg3, 64);
	
	new team = StringToInt(arg1);
	new b1 = StringToInt(arg2);
	new b2 = StringToInt(arg3);
	
	new score = SDKCall(fGetTeamScore, team, b1, b2);
	
	DebugPrintToAll("Team score is %d", score);
	
	return Plugin_Handled;
}

public Action:Command_ClearTeamScores(client, args)
{	
	if(fClearTeamScores == INVALID_HANDLE)
	{
		DebugPrintToAll("Could not load ClearTeamScores function, GetConf = %b", bClearTeamScores);
		return Plugin_Handled;
	}
	
	new String:arg1[64];
	GetCmdArg(1, arg1, 64);
	
	SDKCall(fClearTeamScores);
	
	DebugPrintToAll("Team scores have been cleared");
	
	return Plugin_Handled;
}


DebugPrintToAll(const String:format[], any:...)
{
	#if SCORE_DEBUG	
	decl String:buffer[192];
	
	VFormat(buffer, sizeof(buffer), format, 2);
	PrintToChatAll("%s", buffer);
	PrintToConsole(0, "%s", buffer);
	LogMessage("[READY] %s", buffer);
	#else
	//suppress "format" never used warning
	if(format[0])
		return;
	else
		return;
	#endif
}
gamedata/l4dscores.txt
Code:
"Games"
{
	"left4dead"
	{
		"Signatures"
		{
			"GetTeamScore"
			{
				"library"	"server"
				"linux"	"@_ZN16CTerrorGameRules12GetTeamScoreEibb"
			}
			"ClearTeamScores"
			{
				"library"	"server"
				"linux" "@_ZN16CTerrorGameRules15ClearTeamScoresEv"
			}
		}
	}
}
I will gladly appreciate any insight anyone has on this, it's my first time using signatures and SDK Calls.
Downtown1 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:24.


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