R33 to R40 (some errors)
#1

Hello guys

I am converting my script from R33 to R40.
I'm getting this error:
Code:
error 035: argument type mismatch (argument 2)
for this line:
Code:
SetPVarInt(playerid, "Cash", cache_get_value_index_int(0, "Cash"));
What's wrong here ?
Reply
#2

Code:
new cashvar;
cache_get_value_name_int(0, "Cash", cashvar);

SetPVarInt(playerid, "Cash", cashvar);
read this
Reply
#3

First of all, you are using the wrong function. If you want to fetch a field using the column name, you have to use the function cache_get_value_name_int. Second, you need to save the said field into a destination, the function does not return the value of the field. Your code should look like:
pawn Code:
new cash;
cache_get_value_name_int(0, "Cash", cash);
SetPVarInt(playerid, "Cash", cash);
Reply
#4

PHP Code:
/*
    cache_get_value_name -> Is used to fetch string from MySQL
    cache_get_value_name_int -> Is used to fetch integers(number(s)) from MySQL
    cache_get_value_name_float -> Is used to fetch float from MySQL
    cache_get_value_name_bool -> s used to fetch boolean from MySQL
*/
cache_get_value_namerow_idx, const column_name[ ], destination[ ], max_len sizeofdestination ) )
cache_get_value_name_introw_idx, const column_name[ ], destination )
cache_get_value_name_floatrow_idx, const column_name[ ], Float:destination )
cache_get_value_name_boolrow_idxcolumn_name[ ], &bool:destination 
Reply
#5

Thanks!

Getting now errors:
Code:
error 017: undefined symbol "cache_get_value_index_count"
For this line:
Code:
if(cache_get_value_index_count() > 0)
I'm sorry for asking too much questions, I just didn't find any solution for it in forums
Reply
#6

If you are trying to count the rows try this:
new rows;
cache_get_row_count(rows);
if(rows)
Reply
#7

Quote:
Originally Posted by SharpenBlade
View Post
If you are trying to count the rows try this:
new rows;
cache_get_row_count(rows);
if(rows)
Or alternative:
Code:
if( cache_num_rows( ) ){
	
}
AKA
Code:
new rows = cache_num_rows( );
if( rows ) {

}
Reply
#8

Thanks.
Now I want to fetch players's vehicle from 'vehicles' table.
In 'public PrintVehicleStats' I did this:


Code:
for(new i = 0; i < cache_num_rows(); i++)
{
		foreach(new i2 : VehicleIterator)
		{
    		if(VehicleInfo[i2][vID] == cache_get_value_name_int(i, "ID",idvar))
    		{
    			vehicleid = i2;
    		}
}
And it doesn't show nothing. I assume the problem is in for(new i = 0; i < cache_num_rows(); i++)
What's wrong and how could I fix it guys ?
Reply
#9

Are you sure PrintVehicleStats() is actually called?
Also, now every loop calls cache_num_rows(). I personally prefer to only use cache_num_rows() if you've just to check if there are rows. If I want to use the amount of rows (eg. for a loop) I'd go with cache_get_row_count(), since cache_num_rows() does the same.
Just something about minor optimalizations in runtime (which you would never see back in runtime tho -just hate the fact it has to do more work for the same outcome).
Anyway, make sure PrintVehicleStats() is called and that there are actually results for the used query.
Reply
#10

Quote:
Originally Posted by Kwarde
View Post
Are you sure PrintVehicleStats() is actually called?
Also, now every loop calls cache_num_rows(). I personally prefer to only use cache_num_rows() if you've just to check if there are rows. If I want to use the amount of rows (eg. for a loop) I'd go with cache_get_row_count(), since cache_num_rows() does the same.
Just something about minor optimalizations in runtime (which you would never see back in runtime tho -just hate the fact it has to do more work for the same outcome).
Anyway, make sure PrintVehicleStats() is called and that there are actually results for the used query.
I sent you in PM.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)