Small error
#1

I'm getting this:

Quote:

[04:49:15] [DEBUG] mysql_tquery - scheduling query "UPDATE `players` SET `VipTime`=0, `Warns`=3, `Cookies`=89, `Jailed`=0, `Muted`=0, `RegisterDate`=0, `Duty`=0, `Nopm`=0 WHERE `ID`=0"..
[04:49:15] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[04:49:15] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Regarding this line:

Код:
stock SaveStatsForPlayer(playerid)
{
    new query[700], query2[500];
    mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%d, `VIP`=%d, `Deaths`=%d, `Score`=%d, `Money`=%d, `MissionsPlayed`=%d WHERE `ID`=%d", IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Deaths], GetPlayerScore(playerid), pData[playerid][Money], pData[playerid][MissionsPlayed]);
	mysql_format(mysql, query2, sizeof(query2), "UPDATE `players` SET  `VipTime`=%s, `Warns`=%d, `Cookies`=%d, `Jailed`=%d, `Muted`=%d, `RegisterDate`=%s, `Duty`=%d, `Nopm`=%d WHERE `ID`=%d", pData[playerid][VipTime], pData[playerid][Warns], pData[playerid][Cookies], pData[playerid][Jailed], pData[playerid][Muted], pData[playerid][RegisterDate],pData[playerid][Duty], pData[playerid][Nopm], pData[playerid][ID]);
    mysql_tquery(mysql, query, "", "");
    mysql_tquery(mysql, query2, "", "");
}
But i think i wrote it correctly...or no?
Reply
#2

Guess you can try this,

PHP код:
stock SaveStatsForPlayer(playerid)
{
    new 
query[700], query2[500];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `players` SET `IP` = '%s', `Admin` = '%i', `VIP` = '%i', `Deaths` = '%i', `Score` = '%i', `Money` = '%i', `MissionsPlayed` = '%i' WHERE `ID` = '%i'"IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Deaths], GetPlayerScore(playerid), pData[playerid][Money], pData[playerid][MissionsPlayed]);
    
mysql_format(mysqlquery2sizeof(query2), "UPDATE `players` SET  `VipTime` = '%s', `Warns` = '%i', `Cookies` = '%i', `Jailed` = '%i', `Muted` = '%i', `RegisterDate` = '%s', `Duty` = '%i', `Nopm` = '%i' WHERE `ID` = '%i'"pData[playerid][VipTime], pData[playerid][Warns], pData[playerid][Cookies], pData[playerid][Jailed], pData[playerid][Muted], pData[playerid][RegisterDate], pData[playerid][Duty], pData[playerid][Nopm], pData[playerid][ID]);
    
mysql_tquery(mysqlquery"""");
    
mysql_tquery(mysqlquery2"""");

Reply
#3

Ok the syntax error is gone but still doesn't load stats.

mysql_log:

Quote:

[06:02:39] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `IP`, `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1"
[06:02:39] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `IP`, `Password`, `ID` FROM `players` WHERE `Username` = ", callback: "OnAccountCheck", format: "i"
[06:02:39] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[06:02:39] [DEBUG] mysql_tquery - scheduling query "SELECT `IP`, `Password`, `ID` FROM `players` WHERE `Username` = 'Face9000' LIMIT 1"..
[06:02:39] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE ServerStats SET TotalJoins = TotalJoins + 1", callback: "(null)", format: "(null)"
[06:02:39] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[06:02:39] [DEBUG] mysql_tquery - scheduling query "UPDATE ServerStats SET TotalJoins = TotalJoins + 1"..
[06:02:39] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - starting query execution
[06:02:39] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - query was successful
[06:02:39] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[06:02:39] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - data being passed to ProcessCallbacks()
[06:02:39] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[06:02:39] [DEBUG] CMySQLQuery::Execute[()] - query was successful
[06:02:39] [DEBUG] CMySQLQuery::Execute[()] - no callback specified, skipping result saving
[06:02:39] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[06:02:39] [DEBUG] Calling callback "OnAccountCheck"..
[06:02:39] [DEBUG] cache_get_data - connection: 1
[06:02:39] [DEBUG] cache_get_field_content - row: 0, field_name: "IP", connection: 1, max_len: 16
[06:02:39] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "IP", data: "HIDDEN IP"
[06:02:39] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[06:02:39] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[06:02:39] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Admin", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "VIP", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Money", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Score", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Deaths", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "MissionsPlayed", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "VipTime", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Warns", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Cookies", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Jailed", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Muted", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Duty", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Nopm", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:02:42] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Score", connection: 1
[06:02:42] [WARNING] cache_get_field_content_int - no active cache
[06:03:29] [DEBUG] mysql_format - connection: 1, len: 700, format: "UPDATE `players` SET `IP` = '%s', `Admin` = '%i', `VIP` = '%i', `Deaths` = '%i', `Score` = '%i', `Money` = '%i', `MissionsPlayed..."
[06:03:29] [ERROR] mysql_format - no value for specifier "%i" available
[06:03:29] [DEBUG] mysql_format - connection: 1, len: 500, format: "UPDATE `players` SET `VipTime` = '%s', `Warns` = '%i', `Cookies` = '%i', `Jailed` = '%i', `Muted` = '%i', `RegisterDate` = '%s'..."
[06:03:29] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET `IP` = 'HIDDEN IP', `Admin` = '0', `VI", callback: "(null)", format: "(null)"
[06:03:29] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[06:03:29] [DEBUG] mysql_tquery - scheduling query "UPDATE `players` SET `IP` = 'HIDDEN IP', `Admin` = '0', `VIP` = '0', `Deaths` = '0', `Score` = '0', `Money` = '0', `MissionsPlayed` = '0' WHERE `ID` = ''"..
[06:03:29] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET `VipTime` = '', `Warns` = '0', `Cookies` =", callback: "(null)", format: "(null)"
[06:03:29] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[06:03:29] [DEBUG] mysql_tquery - scheduling query "UPDATE `players` SET `VipTime` = '', `Warns` = '0', `Cookies` = '0', `Jailed` = '0', `Muted` = '0', `RegisterDate` = '', `Duty` = '0', `Nopm` = '0' WHERE `ID` = '0'"..
[06:03:29] [DEBUG] mysql_format - connection: 1, len: 700, format: "UPDATE `players` SET `IP` = '%s', `Admin` = '%i', `VIP` = '%i', `Deaths` = '%i', `Score` = '%i', `Money` = '%i', `MissionsPlayed..."
[06:03:29] [ERROR] mysql_format - no value for specifier "%i" available
[06:03:29] [DEBUG] mysql_format - connection: 1, len: 500, format: "UPDATE `players` SET `VipTime` = '%s', `Warns` = '%i', `Cookies` = '%i', `Jailed` = '%i', `Muted` = '%i', `RegisterDate` = '%s'..."
[06:03:29] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET `IP` = 'HIDDEN IP', `Admin` = '0', `VI", callback: "(null)", format: "(null)"
[06:03:29] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[06:03:29] [DEBUG] mysql_tquery - scheduling query "UPDATE `players` SET `IP` = 'HIDDEN IP', `Admin` = '0', `VIP` = '0', `Deaths` = '0', `Score` = '0', `Money` = '0', `MissionsPlayed` = '0' WHERE `ID` = ''"..
[06:03:29] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET `VipTime` = '', `Warns` = '0', `Cookies` =", callback: "(null)", format: "(null)"
[06:03:29] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[06:03:29] [DEBUG] mysql_tquery - scheduling query "UPDATE `players` SET `VipTime` = '', `Warns` = '0', `Cookies` = '0', `Jailed` = '0', `Muted` = '0', `RegisterDate` = '', `Duty` = '0', `Nopm` = '0' WHERE `ID` = '0'"..
[06:03:29] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[06:03:29] [DEBUG] CMySQLQuery::Execute[()] - query was successful
[06:03:29] [DEBUG] CMySQLQuery::Execute[()] - no callback specified, skipping result saving
[06:03:29] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()

OnAccountCheck:

Код:
public OnAccountCheck(playerid)
{
	new rows, fields;
	cache_get_data(rows, fields, mysql);
	if(rows)
	{
		cache_get_field_content(0, "IP", IP[playerid], mysql, 16);
		new newIP[16];
		GetPlayerIp(playerid, newIP, 16);
		IsPlayerRegisterd[playerid] = 1;

		if(strlen(IP[playerid]) != 0 && !strcmp(IP[playerid], newIP, true))
		{
			GameTextForPlayer(playerid, "Loading Account", 3000, 3);
			SetTimerEx("OnAccountLoad", 3000, false, "i", playerid);
		}
		else
		{
			(!strlen(IP[playerid]) || strcmp(IP[playerid], newIP, true));
			cache_get_field_content(0, "Password", pData[playerid][Password], mysql, 129);
			pData[playerid][ID] = cache_get_field_content_int(0, "ID");
			printf("%s", pData[playerid][Password]);
			ShowPlayerDialog(playerid, dLOGIN, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit");
		}
	}
	else
	{
		ShowPlayerDialog(playerid, dREGISTER, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
	}

	return 1;
}
Код:
public OnAccountLoad(playerid)
{
	new score;
 	pData[playerid][Admin] = cache_get_field_content_int(0, "Admin");
 	pData[playerid][VIP] = cache_get_field_content_int(0, "VIP");
 	pData[playerid][Money] = cache_get_field_content_int(0, "Money");
 	pData[playerid][Score] = cache_get_field_content_int(0, "Score");
 	pData[playerid][Deaths] = cache_get_field_content_int(0, "Deaths");
 	pData[playerid][MissionsPlayed] = cache_get_field_content_int(0, "MissionsPlayed");
 	pData[playerid][VipTime] = cache_get_field_content_int(0, "VipTime");
 	pData[playerid][Warns] = cache_get_field_content_int(0, "Warns");
 	pData[playerid][Cookies] = cache_get_field_content_int(0, "Cookies");
 	pData[playerid][Jailed] = cache_get_field_content_int(0, "Jailed");
 	pData[playerid][Muted] = cache_get_field_content_int(0, "Muted");
 	pData[playerid][Duty] = cache_get_field_content_int(0, "Duty");
 	pData[playerid][Nopm] = cache_get_field_content_int(0, "Nopm");
 	score = cache_get_field_content_int(0, "Score");
 	SetPlayerScore(playerid, score);
 	GivePlayerCash(playerid, pData[playerid][Money]);

 	SendClientMessage(playerid,red,"------------------------------------------------------");
	new	playername3[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername3, sizeof(playername3));
	new string[128];
    format(string,sizeof(string),"* System: Welcome back {F70505}%s (%d) {FFFFFF} - Your stats have been restored.",playername3,playerid);
	SCM(playerid,-1,string);
	SendClientMessage(playerid,red,"------------------------------------------------------");
	CheckVipTime(playerid);
    Logged[playerid] = 1;
	return 1;
}
Reply
#4

Bump. I noticed another problem, seems the stats are loaded for all registered players in db (same stats for all)..

This is what i mean:

http://s4.postimg.org/8suliwfbf/lol.jpg
Reply
#5

Are you logging them in with their IP address? Here try this.

Be sure to reset all stats when they disconnect, it will prevent other players who connect with the previous ID to capture those stats.

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    if(
Logged[playerid] == 1)
    {
        for(new 
ipInfo:pInfoi++) pData[playerid][pInfo:i] = 0;
        
Logged[playerid] = 0;
    }
    return 
1;

Change pInfo to your enum thing.

Assuming you're using Whirlpool. So try this

PHP код:
forward OnAccountLoad(playerid, const password[]);
public 
OnAccountLoad(playerid, const password[])
{
   new 
ppassword[500], hashedpass[500],  registerdate;
    
WP_Hash(hashedpasssizeof(hashedpass), mysql);
    
cache_get_field_content(0"Password"ppasswordmysql);
    
cache_get_field_content(0"RegisterDate"registerdatemysql);
    
    if(!
strcmp(hashedpassppassword))
    {
        if(
Logged[playerid] != 1)
        {
            
pData[playerid][Admin] = cache_get_field_content_int(0"Admin");
            
pData[playerid][VIP] = cache_get_field_content_int(0"VIP");
            
GivePlayerCash(playeridcache_get_field_content_int(0"Money"));
            
SetPlayerScore(playeridcache_get_field_content_int(0"Score"));
            
pData[playerid][Deaths] = cache_get_field_content_int(0"Deaths");
            
pData[playerid][MissionsPlayed] = cache_get_field_content_int(0"MissionsPlayed");
            
pData[playerid][VipTime] = cache_get_field_content_int(0"VipTime");
            
pData[playerid][Warns] = cache_get_field_content_int(0"Warns");
            
pData[playerid][Cookies] = cache_get_field_content_int(0"Cookies");
            
pData[playerid][Jailed] = cache_get_field_content_int(0"Jailed");
            
pData[playerid][Muted] = cache_get_field_content_int(0"Muted");
            
pData[playerid][Duty] = cache_get_field_content_int(0"Duty");
            
pData[playerid][Nopm] = cache_get_field_content_int(0"Nopm");
             
pData[playerid][RegisterDate] = registerdate;
            
CheckVipTime(playerid);
            
Logged[playerid] = 1;
            
            
SendClientMessage(playerid,red,"------------------------------------------------------");
            new    
playername3[MAX_PLAYER_NAME];
            
GetPlayerName(playeridplayername3sizeof(playername3));
            new 
string[128];
            
format(string,sizeof(string),"* System: Welcome back {F70505}%s (%d) {FFFFFF} - Your stats have been restored.",playername3,playerid);
            
SCM(playerid,-1,string);
            
SendClientMessage(playerid,red,"------------------------------------------------------");
        }
    }
    else 
ShowPlayerDialog(playeriddLOGINDIALOG_STYLE_INPUT"Login""In order to play, you need to login""Login""Quit");
    return 
1;

I've edited your check to see if they're registered or not.

PHP код:
forward OnAccountCheck(playerid);
public 
OnAccountCheck(playerid)
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows)
    {
        
ShowPlayerDialog(playeriddLOGINDIALOG_STYLE_INPUT"Login""In order to play, you need to login""Login""Quit");
    }
    else
    {
        
ShowPlayerDialog(playeriddREGISTERDIALOG_STYLE_INPUT"Register""In order to play, you need to register.""Register""Quit");
    }
    return 
1;

I've changed some of your functions so if you get errors just reply with error and the lines. And me or somebody will help you. I didn't really understand why half of the variables were in your OnAccountCheck so if it doesnt work properly you'll have to put them back in.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)