SA-MP Forums Archive
Problem with MySQL/dialog. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with MySQL/dialog. (/showthread.php?tid=550573)



Problem with MySQL/dialog. - Baltimore - 13.12.2014

Hello.

I have a command to list the player vehicles.

pawn Код:
mysql_format(MySQLConnect, query, 256, "SELECT * FROM vehs WHERE Proprio = '%s'", NameRequete[playerid]);
mysql_tquery(MySQLConnect, query, "CarTaxi", "i", playerid);
Then the player can choose the vehicle he wants to turn it into a taxi.

But if I have 3 vehicles I select the second, it will be the third to be transformed ...

pawn Код:
forward CarTaxi(playerid);
public CarTaxi(playerid)
{
    new rows = cache_num_rows(),
        string_total[256],
        stringveh[50];

    for(new i = 1; i < rows+1; i++)
    {
        if(!IsABike(i))
        {
            format(stringveh, sizeof(stringveh), "%s\n", GetVehicleName(i));
            strins(string_total, stringveh, strlen(string_total));
            IdVehTaxi[playerid] = i;
        }
    }
    return ShowPlayerDialog(playerid, 11, DIALOG_STYLE_LIST, "Taxi:", string_total, "Ok", "Quit");
}



Re : Problem with MySQL/dialog. - Baltimore - 13.12.2014

IdVehTaxi[playerid] = The id of the selected vehicle in the dialog...

How can it be that?
Because in my loop will IdVehTaxi the last vehicle ... not the one selected in the dialog.


Re : Problem with MySQL/dialog. - Baltimore - 14.12.2014

up please...


Re : Problem with MySQL/dialog. - Baltimore - 19.12.2014

upppppppppp


Re: Problem with MySQL/dialog. - Sawalha - 19.12.2014

your loop is wrong.. you increased the variable while it shouldn't be increased, so it will select the row which is next to the row which is wanted.
Try:
pawn Код:
for(new i; i < rows; i++)