AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   plugin compiled, no errors, but not working (https://forums.alliedmods.net/showthread.php?t=163157)

Stuffinator 07-27-2011 09:55

plugin compiled, no errors, but not working
 
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"trueerrorsizeof(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(clientClientSteamIDsizeof(ClientSteamID))
    
    
Format(QueryStr,sizeof(QueryStr),"SELECT * FROM Users WHERE STEAMID = '%s'"ClientSteamID); 
    
PrintToChatAll("vor SQL_Query")
    
QueryHndl SQL_Query(dbaseQueryStr)
    
    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 :?

Lebson506th 07-27-2011 10:11

Re: plugin compiled, no errors, but not working
 
Is the plugin actually running?

Also, you don't need to include <tf2>

Stuffinator 07-27-2011 13:02

Re: plugin compiled, no errors, but not working
 
Quote:

Originally Posted by Lebson506th (Post 1519656)
Is the plugin actually running?

Well if I type "sm plugins list" in the console it is listed, if that's what you mean.
Quote:

Originally Posted by Lebson506th (Post 1519656)
Also, you don't need to include <tf2>

Oh yes, I tried something different before and forgot to take the include out again.

mjmfighter 07-29-2011 14:48

Re: plugin compiled, no errors, but not working
 
make sure the event is right. Im assuming your making this plugin for tf2. maybe player_death isnt the right event for when a player dies in tf2 (it would make sense that it is, but you never know)

Powerlord 07-29-2011 15:01

Re: plugin compiled, no errors, but not working
 
Quote:

Originally Posted by mjmfighter (Post 1521190)
make sure the event is right. Im assuming your making this plugin for tf2. maybe player_death isnt the right event for when a player dies in tf2 (it would make sense that it is, but you never know)

Yeah, pretty sure it is.


All times are GMT -4. The time now is 21:30.

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