29.01.2012, 03:18
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 * 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
{
new queryDC[128],pDOMtmp;
format(queryDC, sizeof(queryDC), "SELECT score FROM `DOM` WHERE `name` = '%s'", pname);
mysql_query(queryDC);
mysql_store_result();
new str[128], score;
mysql_fetch_row_format(query,"|"))
mysql_fetch_field_row(str, "score");
score = (strval(str) + DOMScore[playerid][1]);
format(query2, sizeof(query2), "UPDATE DOM SET score=%d WHERE name='%s'",score,pname);
mysql_query(query2);
}
mysql_free_result();