SA-MP Forums Archive
Finding vehicle by plate stock problem. - 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: Finding vehicle by plate stock problem. (/showthread.php?tid=426844)



Finding vehicle by plate stock problem. - PaulDinam - 30.03.2013

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.


Re: Finding vehicle by plate stock problem. - RajatPawar - 30.03.2013

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


Re: Finding vehicle by plate stock problem. - PaulDinam - 30.03.2013

nevermind, it works now with sscanf.
thanks though.