21.02.2009, 14:02
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
Thanks in advance
Originally Posted by CruncH
No, but you can create one..(but you must use SetVehiclePlate first).
|
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;
}
#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;
}
Originally Posted by Mikep
You can use this function to return a random letter:
pawn Код:
|
randchar()
{
return random(26) + 'A';
}
new chr[200];
....
format(chr,200,"%s","A");