Whats wrong?
#1

Can someone tell me why this callback doesn't load stats?:

Код:
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][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] = cache_get_field_content_int(0, "RegisterDate");
 	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;
}
Lemme explain:

I made a /test cmd to add some score, money etc etc to player account just to test. I quit and stats are saved (in db too, checked!) - (saving works perfectly), BUT i re-login and nothng...stats reset to 0!!

This is mysql_log as you can see it was saving the stats and loading them:

Quote:

//I'm ingame and used /test cmd then quitting-------------------------------------------------------//
UPDATE `players` SET `IP` = 'HIDDEN IP', `Admin` = '5', `VIP` = '1', `Deaths` = '6', `Score` = '40', `Money` = '20000', `MissionsPlayed` = '27' WHERE `Username` = 'Face9000'
UPDATE `players` SET `VipTime` = 'Y', `Warns` = '3', `Cookies` = '89', `Jailed` = '0', `Muted` = '0', `RegisterDate` = '', `Duty` = '0', `Nopm` = '0' WHERE `Username` = 'Face9000'
[part] Face9000 has left the server (0:1)

//Joining after few seconds------------------------------------------------------//
[connection] **** requests connection cookie.
[connection] incoming connection: HIDDEN IP id: 0
[join] Face9000 has joined the server (0:HHIDEN IP)
SELECT `IP`, `Password` FROM `players` WHERE `Username` = 'Face9000' LIMIT 1

//Noticed? All stats were to 0!-------------------------------------------------------------//
UPDATE `players` SET `IP` = '93.148.160.140', `Admin` = '0', `VIP` = '0', `Deaths` = '0', `Score` = '0', `Money` = '0', `MissionsPlayed` = '0' WHERE `Username` = 'Face9000'
UPDATE `players` SET `VipTime` = '', `Warns` = '0', `Cookies` = '0', `Jailed` = '0', `Muted` = '0', `RegisterDate` = '', `Duty` = '0', `Nopm` = '0' WHERE `Username` = 'Face9000'
UPDATE `players` SET `IP` = '93.148.160.140', `Admin` = '0', `VIP` = '0', `Deaths` = '0', `Score` = '0', `Money` = '0', `MissionsPlayed` = '0' WHERE `Username` = 'Face9000'
UPDATE `players` SET `VipTime` = '', `Warns` = '0', `Cookies` = '0', `Jailed` = '0', `Muted` = '0', `RegisterDate` = '', `Duty` = '0', `Nopm` = '0' WHERE `Username` = 'Face9000'
[part] Face9000 has left the server (0:1)

Reply
#2

You didn't look for data in the first place.

Use
pawn Код:
cache_get_data
pawn Код:
public OnAccountLoad(playerid)
{
    new score;
    new rows, fields;
    cache_get_data(rows, fields, Connection)//Connection is your DB connection
    if(rows)
    {
     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][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] = cache_get_field_content_int(0, "RegisterDate");
    }
    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
#3

Same problem.
Reply
#4

Код:
pData[playerid][RegisterDate] = cache_get_field_content_int(0, "RegisterDate");
Does the "RegisterDate" field in your db consist only of numbers? Because you're using cache_get_field_content_int which only works with integers(numbers).
Reply
#5

RegisterDate stores the registration date in db, such as like: 28/09/2015. But i dont see where's the problem, can't be that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)