error 022: must be lvalue (non-constant)
#1

Can some one explain me how do i get the players money and score and put them in the database?
i am using konstatinos sqlite tutorial...

errors:
pawn Код:
(372) : error 022: must be lvalue (non-constant)
(376) : error 022: must be lvalue (non-constant)
pawn Код:
USER_MONEY = GetPlayerMoney(playerid); //372
db_get_field_assoc(Result, "money", Query, 20);
User[playerid][USER_MONEY] = strval(Query);
                   
USER_SCORE = GetPlayerScore(playerid); //376
db_get_field_assoc(Result, "score", Query, 100);
User[playerid][USER_SCORE] = strval(Query);
I read the tutorial completely but i dont understand it.
Reply
#2

USER_MONEY and USER_SCORE are indexes of the enum so you cannot use it like that.

Also lines 372 and 376 are not needed at all because all you want to do is load the money and score the the database - therebefore, getting the money/score is useless.
Reply
#3

pawn Код:
User[playerid][USER_MONEY] = GetPlayerMoney(playerid);

User[playerid][USER_SCORE] = GetPlayerScore(playerid); //376
Reply
#4

pawn Код:
enum OMGx2
{
    USER_MONEY,
    USER_SCORE
};
new User[MAX_PLAYERS][OMGx2];

db_get_field_assoc(Result, "money", Query, 20);
User[playerid][USER_MONEY] = strval(Query);

db_get_field_assoc(Result, "score", Query, 100);
User[playerid][USER_SCORE] = strval(Query);
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
USER_MONEY and USER_SCORE are indexes of the enum so you cannot use it like that.

Also lines 372 and 376 are not needed at all because all you want to do is load the money and score the the database - therebefore, getting the money/score is useless.
So i want it to be like the rest.. like when you get money in game it saves to the database etc... where and what am i suposed to do?
Reply
#6

Quote:
Originally Posted by Voxel
Посмотреть сообщение
So i want it to be like the rest.. like when you get money in game it saves to the database etc... where and what am i suposed to do?
When a player disconnects (OnPlayerDisconnect), you execute a query about updating the data.

pawn Код:
format( Query, sizeof( Query ), "UPDATE users SET money = %d, score = %d WHERE username = '%s'", GetPlayerMoney( playerid ), GetPlayerScore( playerid ), DB_Escape( User[ playerid ][ USER_NAME ] ) );
db_query( Database, Query );
If you use server-side money, then replace GetPlayerMoney with the one you store the money.
Reply
#7

Thank you ! gonna try it.
Reply
#8

It works! ty Konstantinos!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)