MySQL R7 and stocks
#1

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?
Reply
#2

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.
Reply
#3

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)