SetVehicleNumberPlate
#1

Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
new const NumeriuSkaiciai[] =    "0123456789";
Код:
new string[6],msg[10];
    string[0] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[1] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[2] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[3] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    string[4] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    string[5] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,msg);
What's bad that I do not normally numbers?:

Reply
#2

1. You are required to format a string to insert some data into it. You can not use assignment operator deirectly.
2. You are required to respawn the vehicle to take effect.

EDIT: WIll post the fixed code
Reply
#3

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
1. You are required to format a string to insert some data into it. You can not use assignment operator deirectly.
2. You are required to respawn the vehicle to take effect.

EDIT: WIll post the fixed code
EG. please.
Reply
#4

Here you go!

There are two methods to this!

The First Method:
pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
    format( string[0],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    format( string[1],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    format( string[2],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    format( string[3],1,"%d",NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))]);
    format( string[4],1,"%d",NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))]);
    format( string[5],1,"%d",NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))]);
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
Or the Second Method:

pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
    for(new i=0;i<3;i++)
    {
          format( string[i],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    }
    for(new i=3;i<=5;i++)
    {
          format( string[i],1,"%s",NumeriuRaides[random(sizeof(NumeriuSkaiciai))]);
    }  
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
Reply
#5

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Here you go!

There are two methods to this!

The First Method:
pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
    format( string[0],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    format( string[1],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    format( string[2],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    format( string[3],1,"%d",NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))]);
    format( string[4],1,"%d",NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))]);
    format( string[5],1,"%d",NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))]);
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
Or the Second Method:

pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
    for(new i=0;i<3;i++)
    {
          format( string[i],1,"%s",NumeriuRaides[random(sizeof(NumeriuRaides))]);
    }
    for(new i=3;i<=5;i++)
    {
          format( string[i],1,"%s",NumeriuRaides[random(sizeof(NumeriuSkaiciai))]);
    }  
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
And with a first and a second representative as follows:




P.S. All vehicles come with such numbers.
Reply
#6

Not all vehicles should come with such number.

There is a problem with in the code! What i think is we need the char datatype to step out here. Let me think for a while. Ill post you a new code.

You know what wait! Try this its an edit of your original code: I want to know what do you get when you do this.

pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
     string[0] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[1] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[2] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[3] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    string[4] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    string[5] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
I think you will be having sscanf , click here if you want to download it..

I made this code to use it with sscanf. Try this too:

pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
    new randletter = random(sizeof(NumeriuRaides));
    new randdigit = random(sizeof(NumeriuSkaiciai));
    sscanf(NumeriuRaides[randletter], "s[1]", string[0]);
    sscanf(NumeriuRaides[randletter], "s[1]", string[1]);
    sscanf(NumeriuRaides[randletter], "s[1]", string[2]);
    sscanf(NumeriuRaides[randdigit], "s[1]", string[3]);
    sscanf(NumeriuRaides[randdigit], "s[1]", string[4]);
    sscanf(NumeriuRaides[randdigit], "s[1]", string[5]);
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
Reply
#7

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Not all vehicles should come with such number.

There is a problem with in the code! What i think is we need the char datatype to step out here. Let me think for a while. Ill post you a new code.

You know what wait! Try this its an edit of your original code: I want to know what do you get when you do this.

pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
     string[0] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[1] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[2] = NumeriuRaides[random(sizeof(NumeriuRaides))];
    string[3] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    string[4] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    string[5] = NumeriuSkaiciai[random(sizeof(NumeriuSkaiciai))];
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
I think you will be having sscanf , click here if you want to download it..

I made this code to use it with sscanf. Try this too:

pawn Код:
new const NumeriuRaides[] =    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   new const NumeriuSkaiciai[] =    "0123456789";

    new string[6],msg[10];
    new randletter = random(sizeof(NumeriuRaides));
    new randdigit = random(sizeof(NumeriuSkaiciai));
    sscanf(NumeriuRaides[randletter], "s[1]", string[0]);
    sscanf(NumeriuRaides[randletter], "s[1]", string[1]);
    sscanf(NumeriuRaides[randletter], "s[1]", string[2]);
    sscanf(NumeriuRaides[randdigit], "s[1]", string[3]);
    sscanf(NumeriuRaides[randdigit], "s[1]", string[4]);
    sscanf(NumeriuRaides[randdigit], "s[1]", string[5]);
    format(msg,8,"%s%s%s:%d%d%d",string[0],string[1],string[2],string[3],string[4],string[5]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
[13:11:56] sscanf warning: String buffer overflow.
[13:11:56] sscanf warning: String buffer overflow....
Reply
#8

Quote:
Originally Posted by elvinas02
Посмотреть сообщение
[13:11:56] sscanf warning: String buffer overflow.
[13:11:56] sscanf warning: String buffer overflow....
Not a big problem. But does it works in game. Go and check it in game. Warnings are not a big problem.

We will fix the string buffer overflow if it works in game.
Reply
#9

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Not a big problem. But does it works in game. Go and check it in game. Warnings are not a big problem.

We will fix the string buffer overflow if it works in game.
I can't show all vehicles : :000
Reply
#10

Okay i found the solution. Give me a minute to post it! Your array was the problems.

EDIT:

Change your arrays first.
pawn Код:
new const NumeriuRaides[][] = { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z" };
new const NumeriuSkaiciai[] = {0,1,2,3,4,5,6,7,8,9};
Then change this portion as it is!
pawn Код:
new msg[10],randletter = random(sizeof(NumeriuRaides)),randdigit = random(sizeof(NumeriuSkaiciai));
    format(msg,sizeof(msg),"%s%s%s:%d%d%d",NumeriuRaides[randletter],NumeriuRaides[randletter],NumeriuRaides[randletter],NumeriuSkaiciai[randdigit],NumeriuSkaiciai[randdigit],NumeriuSkaiciai[randdigit]);
    format(tInfo[nuomTransp][Numeriai],8,"%s",msg);
    SetVehicleNumberPlate(nuomTransp,tInfo[nuomTransp][Numeriai]);
    SetVehicleToRespawn(nuomTransp);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)