SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 06/11/2019, 01:45 PM   #1
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default /wantedcars list Command is bugging

Hey,

i have a command that shows all wanted cars that pd can save into a database, but the command shows the only car that is in the database like 10000 times, and the others but the first are bugged, i changed some things in my script an it only shows "sultan" now at the very bottom, without licenseplate and wanted reason


My Loading Function
Code:
new query2[128];
format(query2,sizeof(query2),"SELECT * FROM wantedcars");
mysql_function_query(dbhandle,query2,true,"LoadWantedCars","i",playerid);
My Command
Code:
CMD:wantedcars(playerid)
{
	new string[1024];
	for(new w=0; w<sizeof(wInfo); w++)
	{
		format(string,sizeof(string),"%s\t%s\t%s\n%s",wInfo[w][CarModel],wInfo[w][WantedKennzeichen],wInfo[w][WantedGrund],string);
	}
	ShowPlayerDialog(playerid, WANTEDCARSDIALOG, DIALOG_STYLE_TABLIST,"Gesuchte Fahrzeuge", string, "Okay", "");
	return 1;
}
My Loading Function public:

Code:
forward LoadWantedCars(playerid);
public LoadWantedCars(playerid)
{
	new num_rows,num_fields;
	cache_get_data(num_rows,num_fields,dbhandle);
	if(!num_rows)return 1;
	new tmp_wantedkennzeichen[128];
	new tmp_wantedgrund[1024];
	new tmp_carmodel[128];
	for(new i=0; i<num_rows; i++)
	{
		new wID = getFreeWantedCarID();
		cache_get_field_content(0,"wantedkennzeichen",tmp_wantedkennzeichen,dbhandle,128);
		cache_get_field_content(0,"wantedgrund",tmp_wantedgrund,dbhandle,1024);
		cache_get_field_content(0,"model",tmp_carmodel,dbhandle,128);
		strcpy(wInfo[wID][WantedKennzeichen],tmp_wantedkennzeichen,128);
		strcpy(wInfo[wID][WantedGrund],tmp_wantedgrund,1024);
		wInfo[wID][db_id] = cache_get_field_content_int(0,"id",dbhandle); 
		strcpy(wInfo[wID][CarModel],tmp_carmodel,128);
	}
	return 1;
}

thats two of the bugs:



ImTobi is offline   Reply With Quote
Old 06/11/2019, 01:52 PM   #2
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 121
Reputation: 43
Default Re: /wantedcars list Command is bugging

Code:
cache_get_field_content(0,"
You should be fetching the row number i, not 0. You're fetching the same first row, num_row amount of times.
Markski is offline   Reply With Quote
Old 06/11/2019, 01:53 PM   #3
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

i tried i before, did the same thing, it put the thing at the very bottom, without the wanted reason and license plate
ImTobi is offline   Reply With Quote
Old 06/11/2019, 01:59 PM   #4
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 121
Reputation: 43
Default Re: /wantedcars list Command is bugging

By the way, you don't need all those tmp_ strings and copy from them, you can just fetch the data straight into the main strings.

Quote:
Originally Posted by ImTobi View Post
i tried i before, did the same thing, it put the thing at the very bottom, without the wanted reason and license plate
Try running that query on your sql client and see what the result looks like from there.
Markski is offline   Reply With Quote
Old 06/11/2019, 02:09 PM   #5
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

What query? If i copy it and paste it in the sql thing, it says syntax error
ImTobi is offline   Reply With Quote
Old 06/11/2019, 02:53 PM   #6
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

idk how that works, and why my command buggs
ImTobi is offline   Reply With Quote
Old 06/11/2019, 04:22 PM   #7
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging





Now, i made a command to add wanted cars, it works, but the command still doesn't it displays nothing, just empty fields
ImTobi is offline   Reply With Quote
Old 06/11/2019, 05:18 PM   #8
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

Code:
for(new i=0; i<sizeof(wInfo); i++)
{
         format(string,sizeof(string),"%s\t%s\t%s\n%s",wInfo[i][CarModel],wInfo[i][WantedKennzeichen],wInfo[i][WantedGrund],string);
}
ShowPlayerDialog(playerid, WANTEDCARSDIALOG, DIALOG_STYLE_TABLIST,"Gesuchte Fahrzeuge - SFPD | LSPD", string, "Okay", "");
it works if i break the loop, then it shows the first car in the database and the lcense plate and the reason, but if i dont break the loop, it buggs
ImTobi is offline   Reply With Quote
Old 07/11/2019, 01:41 PM   #9
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

bump
ImTobi is offline   Reply With Quote
Old 07/11/2019, 04:21 PM   #10
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 433
Reputation: 120
Default Re: /wantedcars list Command is bugging

You shouldn't put all your array in the dialog, not all of them have the records.
Is there any reason you are appending the string of formatted dialog instead of prepending it?
Also watch your buffer and array size, you should set it to the necessary amount, same to the MySQL field column size +1.

How is one item with 128 + 1024 + 128 line gonna fit into 1024 characters dialog capacity?

Can you post the wInfo enum and declaration?
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X 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
Bug List Command Keyhead Scripting Help 0 13/03/2014 03:19 AM
2 in 1 Command List kbalor Scripting Help 6 16/07/2012 03:18 PM
command debugging/bugging/halting(not crashing) the server. The_Gangstas Help Archive 3 27/12/2010 08:21 PM
Command list [asg]davo Help Archive 4 26/05/2010 12:16 PM
list command Schock Help Archive 0 01/03/2009 02:54 PM


All times are GMT. The time now is 09:13 PM.


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