29.01.2012, 02:11
hi,
i have a code that shall show the player the score he has earned per game session.
This values are saved to a mysql database but the problem is it isnt saving the score of his current session but all his score he has in general.
I hope you can help me
No mysql log errors or warnings etc.
i have a code that shall show the player the score he has earned per game session.
This values are saved to a mysql database but the problem is it isnt saving the score of his current session but all his score he has in general.
I hope you can help me
No mysql log errors or warnings etc.
pawn Код:
new DOMScore[MAX_PLAYERS][2];
//OnPlayerConnect
DOMScore[playerid][0]=0;
//OnPlayerDisconnect
DOMScore[playerid][1]=(GetPlayerScore(playerid)-DOMScore[playerid][0]);
new query[128],query2[128],pname[24];
GetPlayerName(playerid,pname,24);
format(query, sizeof(query), "SELECT name FROM `DOM` WHERE name = '%s' LIMIT 1", pname);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
format(query2,sizeof(query2), "INSERT INTO `DOM` (name, score) VALUES('%s','%d')",pname,DOMScore[playerid][1]);
mysql_query(query2);
}
else if(rows == 1)
{
new queryDC[128],pDOMtmp;
format(queryDC, sizeof(queryDC), "SELECT score FROM `DOM` WHERE `name` = '%s'", pname);
mysql_query(queryDC);
mysql_store_result();
new rowD[24];
mysql_fetch_row(rowD);
sscanf(rowD, "p<|>d",pDOMtmp);
format(query2, sizeof(query2), "UPDATE pDOM SET score=%d WHERE name='%s'",(pDOMtmp+DOMScore[playerid][1]),pname);
mysql_query(query2);
}
mysql_free_result();