Using Enum ...
#1

i made this to store retrieved data from the database but it always gets me null


the definitions
pawn Код:
enum pIN
{
    SCORE,
    MONEY,
    KILLS,
    DEATHS
};

new pInfo[MAX_PLAYERS][pIN];

The function to retrieve data from the database then saves it into the variables

pawn Код:
stock ret_cDATA(playerid)
{
    new
        Query[ 256 ],
        Messages[ 256 ],
        DBResult: Result,
        pName[ MAX_PLAYER_NAME ],
        Field[ 50 ]
    ;
   
    format(Query, sizeof(Query), "SELECT * FROM `Accounts` WHERE `NAME` = '%s' COLLATE NOCASE", DB_Escape(pName));
    Result = db_query(DATABASE, Query);
   
    pInfo[playerid][SCORE] = db_get_field_assoc(Result, "SCORE", Field, 30);
    pInfo[playerid][MONEY] = db_get_field_assoc(Result, "CASH", Field, 30);
    pInfo[playerid][KILLS] = db_get_field_assoc(Result, "KILLS", Field, 30);
    pInfo[playerid][DEATHS] = db_get_field_assoc(Result, "DEATHS", Field, 30);
   
    print(pInfo[playerid][MONEY]);
}
Then when i do this
pawn Код:
ret_cDATA(playerid);//onplayerconnect
it tells me in the console that the value is null, although it is 5000

Please i need an immediate help and thanks
Reply
#2

OH MY GOD WHAT A STUPID AM I !!!! SORRY GUYS I FORGOT THIS SMALL LINE AND THIS WHAT MADE THE WHOLE PROB

pawn Код:
GetPlayerName(playerid, pName, sizeof(pName);
so the database was returning null value
Reply
#3

Sorry i want to ask a question but dont want to open a new thread for it

Is retrieving the player data on player connect (before login) is safe ?
Reply
#4

Quote:
Originally Posted by Healian
Посмотреть сообщение
Sorry i want to ask a question but dont want to open a new thread for it

Is retrieving the player data on player connect (before login) is safe ?
no better after he inputes the (CORRECT) password
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)