Hi there,
I tried to made a little test-plugin so I can get used to SourcePawn and how it all works.
The plugin was supposed to do an SQL-Query on playerdeath and look if the player who died has an entry in the database and then type something in the chat depending on the result of the query.
I don't get errors while compiling, the plugin successfully loads, but it doesn't do anything and I don't get any errors.
PHP Code:
#include <sourcemod>
#include <tf2>
new Handle:dbase
public Plugin:myinfo =
{
name = "Database-Test",
author = "author",
description = "<- Description ->",
version = "1.0",
url = "<- URL ->"
}
new const String:AUTHMETHOD_RESTRICT[] = "default"
public OnPluginStart()
{
CreateAuthMethod(AUTHMETHOD_RESTRICT)
decl String:error[255]
if (SQL_CheckConfig("smplugins"))
{
dbase = SQL_Connect("smplugins", true, error, sizeof(error))
}
if (dbase == INVALID_HANDLE)
{
LogError("Could not connect to database \"smplugins\": %s", error)
return
}
HookEvent("player_death", EventPlayerDeath)
}
public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
PrintToChatAll("Event-Start")
new client = GetClientOfUserId(GetEventInt(event, "userid"))
new String:QueryStr[512]
new Handle:QueryHndl
new String:ClientSteamID[36]
PrintToChatAll("vor GetClientAuthString")
GetClientAuthString(client, ClientSteamID, sizeof(ClientSteamID))
Format(QueryStr,sizeof(QueryStr),"SELECT * FROM Users WHERE STEAMID = '%s'", ClientSteamID);
PrintToChatAll("vor SQL_Query")
QueryHndl = SQL_Query(dbase, QueryStr)
if (SQL_FetchRow(QueryHndl))
{
PrintToChatAll("in DB")
}
else
{
PrintToChatAll("not in DB")
}
}
As you may have noticed I tried to make some chat-output to find out until which line of code it gets until it stops working, but unfortunately I don't get any chat-message at all.
I'm sure it's just a little noob-mistake or something I just don't know yet or I haven't considered...but since there seems to be no way to debug those plugins at runtime (correct me if I'm wrong) and I already spent a few hours trying to figure out why it doesn't work, I would really appreciate every help I can get.
Thanks in advance