My check account with mysql dosen't work
#6

Quote:
Originally Posted by Sime30
Посмотреть сообщение
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 Код:
if(cache_num_rows())
    {
I followed that tutorial all this time, I corrected my job everywhere. Now, my account is checked if exists or not, but variables don't save / don't load! It's written in database only when account is created.
That how I maded the Update function:
PHP код:
public Update (playeridtype) {
    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_RESULTplayerid);
        }
        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_RESULTplayerid);
        }
        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_RESULTplayerid);
        }
        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_RESULTplayerid);
        }
        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_RESULTplayerid);
        }
        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_RESULTplayerid);
        }
        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_RESULTplayerid);
        }
    }
    return 
1;

Ofc, I defined the cases (from 1 to 7) and I put this on OnPlayerDisconnect.
PHP код:
for (new 0NUMBER_OF_QUERIESi++) // NUMBER_OF_QUERIES defined as 10
    
Update (playeridi); 
And load function:
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"); 
But I still didn't understand what's with that "cache_num_rows()", what you said. I didn't replace yet.
Anyway. Thanks for help. +reped.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)