GetVehiclePlate -
Coicatak - 21.02.2009
Well I've seen in the basics includes that there's the function SetVehiclePlate, but is there a function to get the vehicle plate?
Thanks in advance
Re: GetVehiclePlate -
Sandra18[NL] - 21.02.2009
Nope
Re: GetVehiclePlate -
CruncH - 21.02.2009
No, but you can create one..(but you must use SetVehiclePlate first).
Re: GetVehiclePlate -
Coicatak - 22.02.2009
Quote:
|
Originally Posted by CruncH
No, but you can create one..(but you must use SetVehiclePlate first).
|
Arf, ok thanks for the answer but the problem is that I'd like to make random plates with numbers & letters, is it possible?
Re: GetVehiclePlate -
Danut - 22.02.2009
with numbers i don't think so will works
Maximum letters are 8-10
Re: GetVehiclePlate -
Mikep - 22.02.2009
You can use this function to return a random letter:
pawn Код:
stock randomchar()
{
new rand; rand = random(26);
new chr[200];
switch(rand)
{
case 0: format(chr,200,"%s","A");
case 1: format(chr,200,"%s","B");
case 2: format(chr,200,"%s","C");
case 3: format(chr,200,"%s","D");
case 4: format(chr,200,"%s","E");
case 5: format(chr,200,"%s","F");
case 6: format(chr,200,"%s","G");
case 7: format(chr,200,"%s","H");
case 8: format(chr,200,"%s","I");
case 9: format(chr,200,"%s","J");
case 10: format(chr,200,"%s","K");
case 11: format(chr,200,"%s","L");
case 12: format(chr,200,"%s","M");
case 13: format(chr,200,"%s","N");
case 14: format(chr,200,"%s","O");
case 15: format(chr,200,"%s","P");
case 16: format(chr,200,"%s","Q");
case 17: format(chr,200,"%s","R");
case 18: format(chr,200,"%s","S");
case 19: format(chr,200,"%s","T");
case 20: format(chr,200,"%s","U");
case 21: format(chr,200,"%s","V");
case 22: format(chr,200,"%s","W");
case 23: format(chr,200,"%s","X");
case 24: format(chr,200,"%s","Y");
case 25: format(chr,200,"%s","Z");
}
return chr;
}
Re: GetVehiclePlate -
maij - 22.02.2009
yees possible, only thing you need, a 1 new callback, and an variable for each car (array?) ,
for example:
pawn Код:
#define MAX_PLATE_STRINGLENGTH 11 //real value = 10
#define MAX_USED_CARS 700
new Getvehicleplate[MAX_USED_CARS][MAX_PLATE_STRINGLENGTH];
forward Setvehicleplate(carid, plate_string[10]);
public Setvehicleplate(carid, plate_string[10])
{
Getvehicleplate[carid] = plate_string;
SetVehicleNumberPlate(carid, plate_string);
return carid;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx,cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/getcarplate", true) == 0)
{
new platestring[11];
platestring = Getvehicleplate[GetPlayerVehicleID(playerid)];
return 1;
}
return 0;
}
//strtok::
stock strtok(const string[], &index,seperator=' ')
{
new length = strlen(string);
new offset = index;
new result[256];
while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
if ((index < length) && (string[index] == seperator))
{
index++;
}
return result;
}
it should work, though i havent tested thus debugged it::
NOTE: a public cannot return a string, so if you want to use strings in plate names, this is the only fast way
Re: GetVehiclePlate -
boylett - 22.02.2009
Quote:
|
Originally Posted by Mikep
You can use this function to return a random letter:
pawn Код:
stock randomchar() { new rand; rand = random(26); new chr[200]; switch(rand) { case 0: format(chr,200,"%s","A"); case 1: format(chr,200,"%s","B"); case 2: format(chr,200,"%s","C"); case 3: format(chr,200,"%s","D"); case 4: format(chr,200,"%s","E"); case 5: format(chr,200,"%s","F"); case 6: format(chr,200,"%s","G"); case 7: format(chr,200,"%s","H"); case 8: format(chr,200,"%s","I"); case 9: format(chr,200,"%s","J"); case 10: format(chr,200,"%s","K"); case 11: format(chr,200,"%s","L"); case 12: format(chr,200,"%s","M"); case 13: format(chr,200,"%s","N"); case 14: format(chr,200,"%s","O"); case 15: format(chr,200,"%s","P"); case 16: format(chr,200,"%s","Q"); case 17: format(chr,200,"%s","R"); case 18: format(chr,200,"%s","S"); case 19: format(chr,200,"%s","T"); case 20: format(chr,200,"%s","U"); case 21: format(chr,200,"%s","V"); case 22: format(chr,200,"%s","W"); case 23: format(chr,200,"%s","X"); case 24: format(chr,200,"%s","Y"); case 25: format(chr,200,"%s","Z"); } return chr; }
|
pawn Код:
randchar()
{
return random(26) + 'A';
}
lol.
Re: GetVehiclePlate -
Finn - 22.02.2009
pawn Код:
new chr[200];
....
format(chr,200,"%s","A");
You need 200 cells to store one single character. Coool.
Re: GetVehiclePlate -
Mikep - 22.02.2009
I didn't make it, blewert did.
Bitch at him!