SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/06/2020, 04:33 PM   #1
Pitstop
Big Clucker
 
Join Date: Aug 2015
Posts: 94
Reputation: 3
Default R33 to R40 (some errors)

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 ?
Pitstop is offline   Reply With Quote
Old 05/06/2020, 04:38 PM   #2
zampa
Little Clucker
 
Join Date: Dec 2019
Posts: 17
Reputation: 0
Default Re: R33 to R40 (some errors)

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

SetPVarInt(playerid, "Cash", cashvar);
read this
zampa is offline   Reply With Quote
Old 05/06/2020, 04:39 PM   #3
Cell_
Big Clucker
 
Join Date: May 2012
Posts: 160
Reputation: 50
Default Re: R33 to R40 (some errors)

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);
__________________
Discord: madgenius0#4058
Cell_ is online now   Reply With Quote
Old 05/06/2020, 06:31 PM   #4
ShadowMortar
Huge Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 303
Reputation: 89
Default Re: R33 to R40 (some errors)

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 
__________________
If you appreciate(d) my help, I will appreciate +REP .

Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
Quote:
Originally Posted by Pottus View Post
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
ShadowMortar is offline   Reply With Quote
Old 06/06/2020, 01:14 AM   #5
Pitstop
Big Clucker
 
Join Date: Aug 2015
Posts: 94
Reputation: 3
Default Re: R33 to R40 (some errors)

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
Pitstop is offline   Reply With Quote
Old 06/06/2020, 05:48 AM   #6
SharpenBlade
Huge Clucker
 
Join Date: May 2020
Posts: 201
Reputation: 25
Default Re: R33 to R40 (some errors)

If you are trying to count the rows try this:
new rows;
cache_get_row_count(rows);
if(rows)
SharpenBlade is online now   Reply With Quote
Old 06/06/2020, 06:41 AM   #7
ShadowMortar
Huge Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 303
Reputation: 89
Default Re: R33 to R40 (some errors)

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 ) {

}
__________________
If you appreciate(d) my help, I will appreciate +REP .

Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
Quote:
Originally Posted by Pottus View Post
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
ShadowMortar is offline   Reply With Quote
Old 06/06/2020, 03:51 PM   #8
Pitstop
Big Clucker
 
Join Date: Aug 2015
Posts: 94
Reputation: 3
Default Re: R33 to R40 (some errors)

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 ?
Pitstop is offline   Reply With Quote
Old 06/06/2020, 03:58 PM   #9
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,739
Reputation: 1686
Default Re: R33 to R40 (some errors)

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.
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 06/06/2020, 04:07 PM   #10
Pitstop
Big Clucker
 
Join Date: Aug 2015
Posts: 94
Reputation: 3
Default Re: R33 to R40 (some errors)

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.
Pitstop is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pawn Compiling errors, Errors and Line are inside [ +REP ] EgyptForLife Scripting Help 8 19/07/2014 08:26 PM
[S-HELP] Compiling errors, Errors and Lines inside. EgyptForLife Scripting Help 3 16/07/2014 07:56 PM
Class Errors: loose indentation (2 Errors) DerickClark Scripting Help 18 22/02/2014 08:01 PM
[ERRORS] Errors appear after adding a Gang System. ••• ĤÁĶÁM ••• Help Archive 17 27/10/2010 05:19 PM
Common compiling errors - READ BEFORE POSTING ERRORS Streetplaya Help Archive 0 23/01/2010 11:20 AM


All times are GMT. The time now is 01:54 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.