SA-MP Forums Archive
MySQL cache - 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 cache (/showthread.php?tid=621223)



MySQL cache - Micko123 - 08.11.2016

Can someone explain me this
PHP код:
cache_get_value_int(0"id"PlayerInfo[playerid][ID]); 
I don't get what this '0' is??


Re: MySQL cache - MerryDeer - 08.11.2016

it's row


Re: MySQL cache - Micko123 - 08.11.2016

But I don't get it.. If I have more than 1 player registered how its going to be??
I am newbie to MySQL so..


Re: MySQL cache - Micko123 - 08.11.2016

Is this for assign player's data on spawn??
PHP код:
AssignPlayerData(playerid)
{
    
cache_get_value_int(0"id"PlayerInfo[playerid][ID]);
    
cache_get_value_int(0"kills"PlayerInfo[playerid][Kills]);
    
cache_get_value_int(0"deaths"PlayerInfo[playerid][Deaths]);
    
cache_get_value_int(0"interior"PlayerInfo[playerid][Interior]);
    
cache_get_value_int(0"money"PlayerInfo[playerid][Money]);
    
cache_get_value_int(0"score"PlayerInfo[playerid][Score]);
    
cache_get_value_int(0"admin"PlayerInfo[playerid][Admin]);
    
cache_get_value_int(0"vip"PlayerInfo[playerid][VIP]);
    return 
1;

It is called when player types his password. If it is for assigning it is not working. Values are written in database as they should be but ther are not assigned to player.. Any ideas??


Re: MySQL cache - X337 - 08.11.2016

Код:
cache_get_value_int(row, column_name, &destination);
That function is to assign integer value returned from sql query into a variable.

Example, you have a query that returns these 2 rows.
Код:
+--------+----------+
| id     | name     | <!---- column/fields
+--------+----------+
|      1 | Fineman  | <!---- row 0
|      2 | Finemann | <!---- row 1
+--------+----------+

new value;
cache_get_value_int(0, "id", value); // This code will assign the value from "id" column at row 0 to "value" variable
printf("%d", value); // Output will be 1
cache_get_value_int(1, "id", value); // This code will assign the value from "id" column at row 1 to "value" variable
printf("%d", value); // Output will be 2
More explanation: https://sampwiki.blast.hk/wiki/MySQL/R40


Re: MySQL cache - Micko123 - 08.11.2016

Thx for this explanation man

But one more question. How do I know when to use this
PHP код:
cache_get_value_int(0"id"value); 
And when to use this
PHP код:
cache_get_value_int(1"id"value); 
EDIT: I fixed not loading player's data. I didn't know that row name was case sensitive xD


Re: MySQL cache - F1N4L - 08.11.2016

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Thx for this explanation man

But one more question. How do I know when to use this
PHP код:
cache_get_value_int(0"id"value); 
And when to use this
PHP код:
cache_get_value_int(1"id"value); 
EDIT: I fixed not loading player's data. I didn't know that row name was case sensitive xD
Correctly for int type:
Код:
new getvalueinteger = cache_get_value_int(1, "id");



Re: MySQL cache - Konstantinos - 08.11.2016

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Correctly for int type:
Код:
new getvalueinteger = cache_get_value_int(1, "id");
Not anymore, it is passed by reference: https://sampwiki.blast.hk/wiki/MySQL/R40...value_name_int

@Micko: When you select the data for a player, you know the max number of rows will be 1 so the rowid will be 0. For queries with multiple rows returned, you use a loop that goes from rowid 0 to rows_returned-1.


Re: MySQL cache - X337 - 08.11.2016

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Correctly for int type:
Код:
new getvalueinteger = cache_get_value_int(1, "id");
In the newest MySQL plugin, the value passed by reference.

Edit: Too late


Re: MySQL cache - Micko123 - 08.11.2016

Thank you all guys So much