R33 to R40 (some errors) -
Pitstop - 05.06.2020
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 ?
Re: R33 to R40 (some errors) -
zampa - 05.06.2020
Code:
new cashvar;
cache_get_value_name_int(0, "Cash", cashvar);
SetPVarInt(playerid, "Cash", cashvar);
read
this
Re: R33 to R40 (some errors) -
Cell_ - 05.06.2020
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);
Re: R33 to R40 (some errors) -
ShadowMortar - 05.06.2020
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_name( row_idx, const column_name[ ], destination[ ], max_len = sizeof( destination ) )
cache_get_value_name_int( row_idx, const column_name[ ], destination )
cache_get_value_name_float( row_idx, const column_name[ ], Float:destination )
cache_get_value_name_bool( row_idx, column_name[ ], &bool:destination )
Re: R33 to R40 (some errors) -
Pitstop - 06.06.2020
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
Re: R33 to R40 (some errors) -
SharpenBlade - 06.06.2020
If you are trying to count the rows try this:
new rows;
cache_get_row_count(rows);
if(rows)
Re: R33 to R40 (some errors) -
ShadowMortar - 06.06.2020
Quote:
Originally Posted by SharpenBlade
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 ) {
}
Re: R33 to R40 (some errors) -
Pitstop - 06.06.2020
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 ?
Re: R33 to R40 (some errors) -
Kwarde - 06.06.2020
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.
Re: R33 to R40 (some errors) -
Pitstop - 06.06.2020
Quote:
Originally Posted by Kwarde
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.