MySQL GetValue script - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL GetValue script (
/showthread.php?tid=162139)
MySQL GetValue script -
baske007 - 22.07.2010
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
Re: MySQL GetValue script -
baske007 - 22.07.2010
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...
Re: MySQL GetValue script -
baske007 - 22.07.2010
-bump-
Sorry for bump but I just need this, otherwise I can stop coding
Re: MySQL GetValue script -
Vince - 22.07.2010
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.