MySQL GetValue script
#1

Hello everyone,

I'm busy with a gamemode from scratch. It is going to be a RolePlay server, and everything is based on MySQL. I maded a function to get a value from the users table. The problem is: No errors while compiling, but the script doesn't work!

Код:
public GetUserValue(playerid, qrow[])
{
    new playername[500];
    new qresult[500];
    new qresult2;
    GetPlayerName(playerid, playername, sizeof(playername));
    format(query, sizeof(query), "SELECT '%s' FROM users WHERE username='%s' LIMIT 1", qrow, playername);
    samp_mysql_query(query);
    samp_mysql_store_result();
    samp_mysql_fetch_row(qresult);
    qresult2 = strval(qresult);
    return qresult2;
}
So, in the script I use the function like this:
Код:
public OnPlayerSpawn(playerid)
{
	GivePlayerMoney(playerid, GetUserValue(playerid, "money"));
	
	return 1;
}
But, it doesn't work, I don't get a value from the function.
It's driving me crazy! Please help.

Thanks for now!

Bas
Reply
#2

Btw, the rest of the mysql system is working, like login/register, so it's just something with the function that isn't correct!
P.S. Sorry for double post, for some reason my edit button isn't working...
Reply
#3

-bump-
Sorry for bump but I just need this, otherwise I can stop coding
Reply
#4

Did you enable the MySQL debug function?
There should be a mysql log file somewhere in your server folder. Also try adding print's between your code to debug.

And this ..

Код:
new playername[500];
is just a waste of 476 cells, as a players name cannot be longer than 24 cells.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)