28.01.2015, 10:04
Quote:
Follow this thread https://sampforum.blast.hk/showthread.php?tid=485633
EDIT: Also, you don't have to use "cache get data" and "(rows)" as written in this thread, use it just like this when you have done everything else. pawn Код:
|
That how I maded the Update function:
PHP код:
public Update (playerid, type) {
new var[128];
switch (type) {
case pLevelx: {
format (var,128,"UPDATE `accounts` SET `Level` = '%d' WHERE `Username`='%s'", PlayerInfo[playerid][pLevel], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
case pAdminx: {
format (var,128,"UPDATE `accounts` SET `AdminLevel` = '%d' WHERE `Username`='%s'", PlayerInfo[playerid][pAdmin], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
case pDonateRankx: {
format (var,128,"UPDATE `accounts` SET `DonateRank` = '%d' WHERE `Username`='%s'", PlayerInfo[playerid][pDonateRank], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
case pSPos_xx: {
format (var,128,"UPDATE `accounts` SET `SPos_x` = '%f' WHERE `Username`='%s'", PlayerInfo[playerid][pSPos_x], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
case pSPos_yx: {
format (var,128,"UPDATE `accounts` SET `SPos_y` = '%f' WHERE `Username`='%s'", PlayerInfo[playerid][pSPos_y], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
case pSPos_zx: {
format (var,128,"UPDATE `accounts` SET `SPos_z` = '%f' WHERE `Username`='%s'", PlayerInfo[playerid][pSPos_z], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
case pSPos_rx: {
format (var,128,"UPDATE `accounts` SET `SPos_r` = '%f' WHERE `Username`='%s'", PlayerInfo[playerid][pSPos_r], PlayerName(playerid));
mysql_tquery (dbHandle, var, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
}
return 1;
}
PHP код:
for (new i = 0; i < NUMBER_OF_QUERIES; i++) // NUMBER_OF_QUERIES defined as 10
Update (playerid, i);
PHP код:
PlayerInfo[playerid][pLevel] = cache_get_field_content_int(0, "Level");
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "AdminLevel");
PlayerInfo[playerid][pSPos_x] = cache_get_field_content_int(0, "SPos_x");
PlayerInfo[playerid][pSPos_y] = cache_get_field_content_int(0, "SPos_y");
PlayerInfo[playerid][pSPos_z] = cache_get_field_content_int(0, "SPos_z");
PlayerInfo[playerid][pSPos_r] = cache_get_field_content_int(0, "SPos_r");
PlayerInfo[playerid][pDonateRank] = cache_get_field_content_int(0, "DonateRank");
Anyway. Thanks for help. +reped.