Vehicle Plate
#1

So i tryed to add like each player would have their own license plate with random numbers in end but it's not working

Photo - http://www.bildites.lv/images/uy1c99ajnail517pa8ji.png

Code
PHP код:
format(PlayerVehicleInfo[playerid][v][pvNumberPlate], 32"%s%d"FirstNameLetters(GetPlayerNameEx(playerid)), randomEx(1000099999)); 
Reply
#2

Maximum number of characters that license plate can contain is 13, and since MAX_PLAYER_NAME can be max. 24 characters plus random numbers, you should put lower number of characters on each license plate.
Reply
#3

My code.
PHP код:
stock FirstNameLetters(name[MAX_PLAYER_NAME])
{
    new 
        
strpos strfind(name"_"true),
        
string[4];
    
    
format(stringsizeof(string), "%c%c"name[0], name[strpos+1]);
    return 
string;
}
stock randomEx(minmax)
{     
    new 
rand random(max-min)+min;    
    return 
rand;
}
public 
OnPlayerConnect(playerid)
{
format(PlayerVehicleInfo[playerid][v][pvNumberPlate], 13"%s%d"FirstNameLetters(GetPlayerNameEx(playerid)), randomEx(1000099999));

It's still not working
Reply
#4

Change these things:
pawn Код:
FirstNameLetters(name[])
{


"%s%s"

Also about that license plate lenght, you can use colors on plates, so its not always [13], like {ff0000}IKEY would show IKEY in red color on the plate, and its not 4 chars, its 12.
Reply
#5

When i set like this
PHP код:
format(PlayerVehicleInfo[playerid][v][pvNumberPlate], 32"CL-%d"randomEx(100999)); 
It's still not working
Reply
#6

After you set a plate, vehicle needs to be respawned.

https://sampwiki.blast.hk/wiki/SetVehicleNumberPlate
Reply
#7

It's not like custom vehicle plate. I made it to set all server used vehicle plate.

Before it was
PHP код:
format(PlayerVehicleInfo[playerid][v][pvNumberPlate], 32"CL31 {FF0000}F7W"); 
And was working
Just now i made it like this, more realistic
PHP код:
format(PlayerVehicleInfo[playerid][v][pvNumberPlate], 32"CL-%d"randomEx(100999)); 
Reply
#8

or you can use the UK License Plate I Made
PHP код:
new UKFirstLetter[21][] = {
"A""B""C""D""E""F""G""H""K""L""M""N""O",
"P""R""S""U""V""W""X""Y"
};
new 
UKSecondLetter[23][] = {
"A""B""C""D""E""F""G""H""J""K""L""M""N",
"O""P""R""S""T""U""V""W""X""Y"
};
new 
UKLastFirstLetter[23][] = {
"A""B""C""D""E""F""G""H""J""K""L""M""N",
"O""P""R""S""T""U""V""W""X""Y"
};
new 
UKLastSecondLetter[23][] = {
"A""B""C""D""E""F""G""H""J""K""L""M""N",
"O""P""R""S""T""U""V""W""X""Y"
};
new 
UKLastThirdLetter[23][] = {
"A""B""C""D""E""F""G""H""J""K""L""M""N",
"O""P""R""S""T""U""V""W""X""Y"
};
public 
OnVehicleSpawn(vehicleid)
{
  new 
string[9], yearmonthday,number;
  
getdate(yearmonthday);
  if(
year >= 2013 && month >= 2){number 13;}
  if(
year >= 2013 && month >= 9){number 63;}
  if(
year >= 2014 && month >= 2){number 14;}
  if(
year >= 2014 && month >= 9){number 64;}
  if(
year >= 2015 && month >= 2){number 15;}
  if(
year >= 2015 && month >= 9){number 65;}
  if(
year >= 2016 && month >= 2){number 16;}
  if(
year >= 2016 && month >= 9){number 66;}
  if(
year >= 2017 && month >= 2){number 17;}
  if(
year >= 2017 && month >= 9){number 67;}
  
format(stringsizeof(string), "%s%s%d %s%s%s",UKFirstLetter[random(sizeof(UKFirstLetter))],UKSecondLetter[random(sizeof(UKSecondLetter))],number,UKLastFirstLetter[random(sizeof(UKLastFirstLetter))],UKLastSecondLetter[random(sizeof(UKLastSecondLetter))],UKLastThirdLetter[random(sizeof(UKLastThirdLetter))]);
  
SetVehicleNumberPlate(vehicleidstring);
  
//new engine, lights, alarm, doors, bonnet, boot, objective;
  //GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  //SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, 0);
  //GearDamage[vehicleid] = 0;
  //VehicleInfo[vehicleid][Engine] = 0;
  
return 1;

Reply
#9

pawn Код:
new PlateVehicle[MAX_VEHICLES][10];

new result[10];
RandomText(result, 8);
format(PlateVehicle[vehicleid],8,"%s",result);
SetVehicleNumberPlate(vehicleid,PlateVehicle[vehicleid]);

stock RandomText(strDest[],strLen=8)
{while(strLen--) strDest[strLen]=random(2)?(random(26)+(random(2)?'a':'A')):(random(10)+'0');}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)