02.03.2013, 09:54
It may very well be that your cache_get_data has wrong parameters passed to it. The 3rd parameter needs to be the connection ID value, so replace it with duomenys (which is apparently the array you store the connection ID in).
The source of your problem is this line:
Your query returns ONE FIELD, but you're asking the script to look for the FOURTH FIELD - this will not work. Please learn that the numbering of the returned fields is RELATIVE TO THE QUERY itself, so doing
SELECT name FROM players WHERE id=1;
will return ONE FIELD with the index of 0.
Furthermore, you could optimize your whole process a bit by never even calling the query for NPCs. What you currently do is call the query, but don't process its result? What's the point of this? Simply don't execute the query in case the player is a NPC.
// EDIT:
About the declaration of arrays with default values.
Something like this will not work indeed (it may, well, but I'm quite sure it won't do what you want it to):
Instead, you need to use code like this:
This will set all the values in the array (indexes 0-19) to 1.
Doing
is not necessary as values are set to 0 by default.
Good luck coding!
The source of your problem is this line:
pawn Код:
cache_get_row(0, 3, timeban[playerid], data);
SELECT name FROM players WHERE id=1;
will return ONE FIELD with the index of 0.
Furthermore, you could optimize your whole process a bit by never even calling the query for NPCs. What you currently do is call the query, but don't process its result? What's the point of this? Simply don't execute the query in case the player is a NPC.
// EDIT:
About the declaration of arrays with default values.
Something like this will not work indeed (it may, well, but I'm quite sure it won't do what you want it to):
pawn Код:
new Array[20] = 1;
pawn Код:
new Array[20] = {1, ...};
Doing
pawn Код:
new Array[20] = {0, ...};
Good luck coding!