Help getting vehicleID number
#1

Hey guys, I have a problem with this code,
This code should read the licensesplate number on the vehicles and at the same time it has confirmed its the correct ID number it should get the vehicle ID number but some how it doesn't work. Anyone that are able to help me?

Код:
stock GetVehicleIDFromPlate(plate)
{
	for(new i = 0; i < sizeof(CarInfo); i++)
	{
	    if(plate == CarInfo[i][cLicense])
	    {
	        return i;
	    }
	}
	return 0;
}
Reply
#2

Paste the part of code where you create the variable 'cLicense' and paste a part of your code that uses this function.
Reply
#3

here are the part for the MDC

Код:
if(dialogid == DIALOGID_MDC_VEH)
    {
        new MDC[1000];
        new hour,minuite;
		gettime(hour,minuite);
		FixHour(hour);
		hour = shifthour;
        if(response)
        {
            new carid = GetVehicleIDFromPlate(strval(inputtext));
            /*format(MDC, sizeof(MDC), "~b~              Mobile Data Computer~n~          		Vehicle Database ~n~~n~~w~Vehicle Model: %s~n~Vehicle Owner: %s~n~Vehicle Plate: %s~n~~n~~n~~y~|v1.0|								   |%d:%d|", ArIsim[carid -400], CarInfo[carid][cOwned], CarInfo[carid][cLicense], hour, minuite);
 			TextDrawSetString(InfoBox[playerid], MDC);
			TextDrawShowForPlayer(playerid, InfoBox[playerid]);*/
			SendClientMessage(playerid, TEAM_BLUE_COLOR,"______-=MOBILE DATA COMPUTER=-_______");
			format(string, 128, "Vehicle Model: %s", ArIsim[carid -400]);
			SendClientMessage(playerid, COLOR_WHITE, string);
			format(string, 128, "Vehicle Owner: %s", CarInfo[carid][cOwned]);
			SendClientMessage(playerid, COLOR_WHITE, string);
			format(string, 128, "Vehicle Plate: %d", CarInfo[carid][cLicense]);
			SendClientMessage(playerid, COLOR_WHITE, string);
        }
        else
		{
		    format(MDC, sizeof(MDC), "~b~              Mobile Data Computer~n~          		Vehicle Database ~n~~n~~r~   Error: 405~n~");
   			TextDrawSetString(InfoBox[playerid], MDC);
			TextDrawShowForPlayer(playerid, InfoBox[playerid]);
   		}
    }
the clicense are the same for the godfather.
But I have done so the car has different plates made by me, For example 4WBN137
Reply
#4

License plates (and I assume that the godfather usage is a string, too.) are strings and not purely integers.

pawn Код:
stock GetVehicleIDFromPlate(plate[])
{
    for(new i = 0; i < sizeof(CarInfo); i++)
    {
            if(!strcmp(plate, CarInfo[i][cLicense], true)) return i;
    }
    return 0;
}
You also need to change how you're using the function:

pawn Код:
GetVehicleIDFromPlate(inputtext);
Reply
#5

Now I get this error.

Код:
G:\Skrivbord\Skrivbord 3\Ny mapp\gamemodes\DICE.pwn(6725) : error 035: argument type mismatch (argument 1)
this code
Код HTML:
new carid = GetVehicleIDFromPlate(strval(inputtext));
Reply
#6



Remove the strval function from the function and leave 'inputtext' in there.
Reply
#7

Hmm, I still have same problem the codes doesn't work ingame some how :S

Do only get this message.
Код:
SendClientMessage(playerid, TEAM_BLUE_COLOR,"______-=MOBILE DATA COMPUTER=-_______");
The rest doesn't appear in the screen...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)