Finding vehicle by plate stock problem.
#1

I have this stock:

pawn Код:
stock FindVehicleByPlate(plate[])
{
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(!strcmp(VehicleInfo[i][carPlate], plate, true))
        {
            return i;
        }
    }
    return 0;
}
And this is the dialog:

pawn Код:
if(response)
    {
        new plate[64], vehicle;
        if(sscanf(inputtext, "s[64]", plate)) return ShowDialog(playerid, Show:<MDCVehicle>, DIALOG_STYLE_INPUT, "LSPD Mobile Data Computer - Vehicle Search", ""EMBED_WHITE"Please enter the vehicle plate you wish to search for below", "Enter", "Escape");
        vehicle = FindVehicleByPlate(plate);
        if(vehicle == 0) return ShowDialog(playerid, Show:<MDCVehicle>, DIALOG_STYLE_INPUT, "LSPD Mobile Data Computer - Vehicle Search", ""EMBED_RED"Invalid vehicle plate\n\n"EMBED_WHITE"Please enter the vehicle plate you wish to search for below", "Enter", "Escape");
        ActionMessage(playerid, 10.0, "logs on the MDC.");
        format(msg, sizeof(msg), ""EMBED_LIGHTBLUE"%s info\n"EMBED_WHITE"Owner: %s\nRegistered: %d\nEND OF TRANSMISSION", VehicleNames[VehicleInfo[vehicle][carModel]-400], VehicleInfo[vehicle][carOwner], VehicleInfo[vehicle][carRegistered]);
        ShowDialog(playerid, Show:<MDCResult>, DIALOG_STYLE_MSGBOX, "LSPD MDC - Result", msg, "Escape", "");
    }
The thing is that is always shows invalid vehicle plate... even though the vehicle is spawned and the variable:
VehicleInfo[vehicleid][carPlate] is good, I checked it by printing it.
Reply
#2

sscanf with dialogs worked a bit dodgy for me, try strlen and how about using strcmp ( .. ) == 0 (quite the same, try it)
Reply
#3

nevermind, it works now with sscanf.
thanks though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)