MySQL cache
#1

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

it's row
Reply
#3

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

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

Код:
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
Reply
#6

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

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");
Reply
#8

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

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
Reply
#10

Thank you all guys So much
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)