SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   /wantedcars list Command is bugging (https://forum.sa-mp.com/showthread.php?t=670419)

ImTobi 06/11/2019 01:45 PM

/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:

https://cdn.discordapp.com/attachmen...88/unknown.png

https://cdn.discordapp.com/attachmen...68/unknown.png

Markski 06/11/2019 01:52 PM

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.

ImTobi 06/11/2019 01:53 PM

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

Markski 06/11/2019 01:59 PM

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 (Post 4120807)
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.

ImTobi 06/11/2019 02:09 PM

Re: /wantedcars list Command is bugging
 
What query? If i copy it and paste it in the sql thing, it says syntax error

ImTobi 06/11/2019 02:53 PM

Re: /wantedcars list Command is bugging
 
idk how that works, and why my command buggs

ImTobi 06/11/2019 04:22 PM

Re: /wantedcars list Command is bugging
 
https://cdn.discordapp.com/attachmen...16/unknown.png



Now, i made a command to add wanted cars, it works, but the command still doesn't it displays nothing, just empty fields

ImTobi 06/11/2019 05:18 PM

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 07/11/2019 01:41 PM

Re: /wantedcars list Command is bugging
 
bump

RoboN1X 07/11/2019 04:21 PM

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?


All times are GMT. The time now is 12:33 PM.

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