SA-MP Forums

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

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

Quote:
Originally Posted by RoboN1X View Post
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?
Code:
enum WantedCarsEnum{
	id,
	WantedKennzeichen[128],
	WantedGrund[128],
	CarModel[128]
}
Code:
new wInfo[100][WantedCarsEnum];

i don't get what you are saying with mysql and the string, i understand normal english words lol xD
ImTobi is offline   Reply With Quote
Old 07/11/2019, 05:44 PM   #12
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 435
Reputation: 128
Default Re: /wantedcars list Command is bugging

Quote:
Originally Posted by ImTobi View Post
Code:
enum WantedCarsEnum{
	id,
	WantedKennzeichen[128],
	WantedGrund[128],
	CarModel[128]
}
Code:
new wInfo[100][WantedCarsEnum];

i don't get what you are saying with mysql and the string, i understand normal english words lol xD
I meant you format the string like this (appended):
pawn Code:
format(string,sizeof(string),"%s\t%s\t%s\n%s",wInfo[i][CarModel],wInfo[i][WantedKennzeichen],wInfo[i][WantedGrund],string);
Instead of this: (preppended)
pawn Code:
format(string,sizeof(string),"%s%s\t%s\t%s\n",string,wInfo[i][CarModel],wInfo[i][WantedKennzeichen],wInfo[i][WantedGrund]);
Well i can understand if your reason is to list from bottom to top...

And that why you use 128 128 128 for that sizes in the enums? Are the wanted vehicle model names actually very long up to 128 characters? The samp command input is only max to 128 characters, are you sure you can add all 128+128+128 parameters in command that only fit 128 characters? No... So distribute the size accordingly...

Sorry since i dont speak deutsch, idk the meaning of enums and purpose for it...

How do you assign the ID when it has no data loaded?

You should also check first if the array index is not empty, either you mark the id with some special value or maybe use strlen on the CarModel before formatting it as dialog item.
So like
pawn Code:
if (strlen(wInfo[i][CarModel]))
{
     format( ... )
}
With this, only entries of wanted car that has car model name will be added into the dialog list
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Old 07/11/2019, 06:48 PM   #13
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

it works now, but how can i do the dialog with DIALOG_STYLE_TABLIST_HEADER? because if i do the Column Names, it repeats them aswell
ImTobi is offline   Reply With Quote
Old 07/11/2019, 06:52 PM   #14
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: /wantedcars list Command is bugging

Set a name for each column only once and then concatenate the rest.

pawn Code:
new string[1024] = "column1\tcolumn2\tcolumn3\n"; // change 1024 to a reasonable size to fit the whole text.
// loop + format
// show dialog
Calisthenics is offline   Reply With Quote
Old 07/11/2019, 07:24 PM   #15
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

well, i changed something, and now it only shows 1 car again. And i did a delete command but it buggs too.
ImTobi is offline   Reply With Quote
Old 07/11/2019, 07:45 PM   #16
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

Code:
				case 2:
				{
					if(!eingeloggt[playerid])return NOT_LOGGEDIN(playerid);
					if(!IsPlayerInFraktion(playerid,1) && !IsPlayerInFraktion(playerid,4))return SendClientMessage(playerid, COLOR_RED, "Du bist kein Mitglied vom SFPD oder LSPD.");
					if(pInfo[playerid][duty] != 1)return SendClientMessage(playerid, COLOR_RED, "Du bist nicht im Dienst.");
					new string[4096];
					for(new i=0; i<sizeof(wInfo); i++)
					{
						if (strlen(wInfo[i][CarModel]))
						{
							format(string,sizeof(string),"ID\tBeschreibung\tKennzeichen\tGrund\n");
						 	format(string,sizeof(string),"%s%i\t%s\t%s\t%s\n",string,wInfo[i][db_id],wInfo[i][CarModel],wInfo[i][WantedKennzeichen],wInfo[i][WantedGrund]);   
						 	ShowPlayerDialog(playerid, WANTEDCARSDIALOG, DIALOG_STYLE_TABLIST_HEADERS,"Gesuchte Fahrzeuge - SFPD | LSPD", string, "Okay", "");
						}
					}
					//ShowPlayerDialog(playerid, WANTEDCARSDIALOG, DIALOG_STYLE_TABLIST_HEADERS,"Gesuchte Fahrzeuge - SFPD | LSPD", string, "Okay", "");
				}

Now the Dialog only Shows 1 of the 2 Cars in the database. -.- i'm tampering with this for like 3 hours

and if there are no cars, it still shows the 1 car
ImTobi is offline   Reply With Quote
Old 07/11/2019, 07:47 PM   #17
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: /wantedcars list Command is bugging

You are overwriting the string. Headers must be set once, before the loop.
Calisthenics is offline   Reply With Quote
Old 07/11/2019, 07:52 PM   #18
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: /wantedcars list Command is bugging

it works now. but when i delete a car from the database, i can still delete it, and the other ids that i type in the command are n working
ImTobi is offline   Reply With Quote
Old 07/11/2019, 07:59 PM   #19
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: /wantedcars list Command is bugging

Can you explain what is the problem exactly?
Calisthenics is offline   Reply With Quote
Old 08/11/2019, 07:17 AM   #20
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 435
Reputation: 128
Default Re: /wantedcars list Command is bugging

I think you better go with ORM instead, Why? I see that you always assume the wInfo arrays always containing the same data in your database, like how you assume that after loading the data from mysql, the array is all filled then you expect it to show just same list as you do in database... No! If you do query like this, it is all copied to your server script memory, and so to keep it tied, you cannot just delete the item from database when you leave it in your wInfo memory... That's not how it work, you need to keep the both things synchronized if you wanted to achieve that. As the wInfo is just a basic stack, it is not the actual database... That's why we here almost did not understand what you wanted to do...

So if you don't want to change your mind on how treating these wInfo, use ORM instead, you still need to apply some changes however it will be easier.
https://forum.sa-mp.com/showthread.php?t=461766

Otherwise, please explain your scenario clearly what you wanted to do, what that code do, and what you expect it to do... Don't just give part of codes, and mentioning "i changed something" or "i type in the command are n working", we don't even know what command you meant without posting the code. especially it is non english (you can ask the deutsch scripters if you wish). I didn't mean to offend you but you need to learn and look for tutorials around here..
__________________
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 06:37 AM.


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