SA-MP Forums Archive
MySQL R7 and stocks - 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: MySQL R7 and stocks (/showthread.php?tid=585719)



MySQL R7 - appleomax - 16.08.2015

I've created this stock to load player data:

Код:
stock LoadPlayerData( playerid )
{

        new query[50];
	format( query, 50 ,"SELECT XP FROM players WHERE Vardas = '%s'",GetName[ playerid ] );
 	mysql_function_query( mysql, query, true, "LoadData", "i", playerid );

        SetPlayerScore(playerid, XP[playerid]);
}
When I try to give player XP in the stock it gives 0, but when I use SetPlayerScore in LoadData function it gives the XP.

If possible, how can I give player XP in the stock?


Re: MySQL R7 and stocks - Syzygy1 - 16.08.2015

Firstly, I recommend that you read this: https://sampforum.blast.hk/showthread.php?tid=570635

Anyway, you need to use a callback called LoadData(playerid) to get the data (XP) from the query (cache_get_row_int).

You also need to make sure you don't miss any brackets out when you write your code.


Re: MySQL R7 and stocks - appleomax - 16.08.2015

Thanks for your reply, I do get the data from the query in LoadData, but why player doesn't get the XP, when XP[playerid] should already have a value after this is called:

Код:
mysql_function_query( mysql, query, true, "LoadData", "i", playerid );
Do I need timer or something?