SA-MP Forums Archive
filterscript problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: filterscript problem (/showthread.php?tid=283845)



filterscript problem - [Diablo] - 16.09.2011

hi,

i'm writing my first filterscript and i've already faced a problem. I am trying to load the mysql row to enum OnPlayerConnect callback, but the query never executes.
Debug.txt shows only that connection was successfull, the query isn't showed at all. I was experimenting a little, and if i change the OnPlayerConnect to OnPlayerSpawn callback, the filterscript works.

So, is it even possible to query a database from onplayerconnect cb?

my code:
pawn Код:
public OnPlayerConnect(playerid)
{
    format(sqlQuery, sizeof(sqlQuery), "SELECT * FROM accounts WHERE username = '%s'", PlayerName(playerid));
    mysql_query(sqlQuery);
    mysql_store_result();
    if(mysql_num_rows())
    {
        while(mysql_fetch_row_format(sqlQuery, "|"))
        {
            sscanf(sqlQuery, "p<|>e<is[24]s[40]s[255]s[15]ii>", PlayerData[playerid]);
        }
    }
    mysql_free_result();
    return 1;
}
sqlQuery is a global variable, PlayerName(playerid) is a stock function that returns a name, and enum matches perfectly to sscanf.

and this is the debug.txt
Код:
[01:15:27] MySQL Debugging activated (09/17/11)

[01:15:27] ---------------------------

[01:15:27]  

[01:15:27] >> mysql_connect( )

[01:15:27] CMySQLHandler::CMySQLHandler() - constructor called.

[01:15:27] CMySQLHandler::CMySQLHandler() - Connecting to "somehost" | DB: "database" | Username: "user" ...

[01:15:27] CMySQLHandler::Connect() - Connection was successful.

[01:15:27] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
script is loaded correctly, added in server.cfg.

any advice is appreciated.

br


Re: filterscript problem - MP2 - 17.09.2011

I think OnPlayerConnect only gets called in filterscripts if it's the first filterscript to be loaded. Try editing your server.cfg to put that FS first.

filterscripts thatscript ..other scripts


Re: filterscript problem - Vortrex - 17.09.2011

In your filterscript ... change the return from 1 to 0 in the OnPlayerConnect callback, and see if that works.


Re: filterscript problem - MP2 - 17.09.2011

Yes, make sure you return 1 at the bottom of the OnPlayerConnect callback in your gamemode.


Re: filterscript problem - [Diablo] - 17.09.2011

solved. MP2's solution works, the filterscript must be loaded first.