Small help
#1

Since i converted my gm to mysql R39-3 can someone help me to convert this code to my current mysql version? Thanks:

Код:
new stats[128];
	format(stats, sizeof(stats), "UPDATE ServerStats SET TotalAccounts = TotalAccounts + 1");
	mysql_function_query(mConnectionHandle, stats, false, "", "");
Reply
#2

pawn Код:
new stats[128];
       format(stats,sizeof(stats), "UPDATE ServerStats SET TotalAccounts = TotalAccounts + 1");
       mysql_query(stats);
https://sampwiki.blast.hk/wiki/MySQL/R33 sames functions of R39
Reply
#3

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery
Reply
#4

Код:
new stats[128];
mysql_format(mConnectionHandle, stats, sizeof(stats), "UPDATE ServerStats SET TotalAccounts = TotalAccounts + 1");
mysql_tquery(mConnectionHandle, stats);
Reply
#5

Oh, thanks all. And now how i can read it to show a message ingame like: "There are X accounts registered"...?
Reply
#6

PHP код:
CMD:printtotalacc(playeridparams[])
{
     
mysql_tquery(mConnectionHandle"SELECT TotalAccounts FROM ServerStats""PrintTotalAcc""d"playerid);
     return 
1;
}
forward PrintTotalAcc(playerid);
public 
PrintTotalAcc(playerid)
{
      
printf("Total Accs: %d"cache_get_row_int(00mConnectionHandle));
      return 
SendClientMessage(playerid0x00cc00FF"Total accounts printed in server log!");

Reply
#7

Actually you don't need to save that to know how many registered in your server, everytime you wanna count registered accounts just do
PHP код:
 "SELECT * FROM Player_table" 
and row counts are your registered accounts, just a suggestion
Reply
#8

BroZeus since i have to place your code inside the registration callback i edited a bit:

Код:
new stats[128];
			mysql_format(mConnectionHandle, stats, sizeof(stats), "UPDATE ServerStats SET TotalAccounts = TotalAccounts + 1");
			mysql_tquery(mConnectionHandle, stats);
			
			mysql_tquery(mConnectionHandle, "SELECT TotalAccounts FROM ServerStats");
			
			new name[24];
			GetPlayerName(playerid, name, sizeof(name));
			format(irc,sizeof(irc),"1,3%s (%d) has registered a new account. Total accounts registered: %d",name,playerid,cache_get_row_int(0, 0, mConnectionHandle));
			IRC_GroupSay(groupID, IRC_CHANNEL, irc);
			IRC_GroupSay(groupID, IRC_ACHANNEL, irc);
Seems the TotalAccounts row is not updating:

Quote:

16:13:17] [DEBUG] mysql_format - connection: 0, len: 128, format: "UPDATE ServerStats SET TotalAccounts = TotalAccounts + 1"
[16:13:17] [ERROR] mysql_format - invalid connection handle (id: 0)
[16:13:17] [DEBUG] mysql_tquery - connection: 0, query: "", callback: "(null)", format: "(null)"
[16:13:17] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[16:13:17] [DEBUG] mysql_tquery - connection: 0, query: "SELECT TotalAccounts FROM ServerStats", callback: "(null)", format: "(null)"
[16:13:17] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[16:13:17] [DEBUG] cache_get_row_int - row: 0, field_idx: 0, connection: 0

Reply
#9

This is non-sense... all you have to do is loop through the table and return the row count.

PHP код:
mysql_tquery(mConnectionHandle"SELECT * FROM Accounts""Query1""d"playerid);
forward public Query1();
Query1()
{
    new 
s[30]; format(ssizeof(s), "Total Accounts: %d"cache_get_row_count()), SendClientMessage(playerid, -1s);
    return 
1;

EDIT: Oops, fixed it.
Reply
#10

....how to place that code if there is inside a public? I need the code without using a public..
Reply


Forum Jump:


Users browsing this thread: