Loading a number from MYSQL
#1

So the thing is i want OnPlayerSpawn i want to load the players money,and give it to him.
This is my script for it:
pawn Код:
new moneyquery[126];
    format(moneyquery,sizeof(moneyquery),"SELECT * FROM users WHERE username = '%s'",Name);
    mysql_query(moneyquery);
    mysql_store_result();
    new result[128];
    mysql_fetch_row_format(result, " ");
    sscanf(moneyquery,"i",PlayerInfo[playerid][money]);
    SetPVarInt(playerid, "money",PlayerInfo[playerid][money]);
    GivePlayerMoney(playerid, PlayerInfo[playerid][money]);
    return 1;
There's no errors,but still.. The money just doesn't appear.
Reply
#2

What is the purpose of fetching the entire row if you only need one field?

PHP код:
SELECT money FROM users WHERE username '%s'
Then use mysql_fetch_int in R6 or earlier or strval in R7 and later.
Reply
#3

THANKS a lot for that. Now my problem is that OnPlayerDisconnect it doesn't save the amount(and did yesterday)
pawn Код:
format(query,sizeof(query),"UPDATE users SET Money = '%d' WHERE username = '%s'",PlayerInfo[playerid][money],Name);
        mysql_query(query);
Do you see a problem?
Reply
#4

I did. But this is my way of learning Thats why i'm asking
Reply
#5

Is your field "Money" with a capital M or money without a capital M
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)