SA-MP Forums Archive
Using Enum ... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Using Enum ... (/showthread.php?tid=369381)



Using Enum ... - Healian - 16.08.2012

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


Re: Using Enum ... - Healian - 16.08.2012

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


Re: Using Enum ... - Healian - 16.08.2012

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 ?


Re: Using Enum ... - CROSS_Hunter - 17.08.2012

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