Unknown Plate Showing
#1

I made a vehicle by myself, but when I made a command to check the vehicle's registration including the vehicle's plate, it shows different plate from what it really is.

COMMAND THAT SHOWS DIFFERENT PLATE
PHP код:
CMD:vreg(playeridparams[])
{
    if(
IsACop(playerid) || IsALVMPDCop(playerid) || (PlayerInfo[playerid][pMember] == && PlayerInfo[playerid][pRank] >= 1) || PlayerInfo[playerid][pMember] == 20 || PlayerInfo[playerid][pMember] == 14)
    {
        if(
isnull(params)) return Syntax(playerid,"vreg""[vehicle registration]");
        new 
FloatxFloatyFloatzcext[32], vehicleid strval(params);
        
GetVehiclePos(vehicleidxyz);
        if(
vehicleid != INVALID_VEHICLE_ID)
        {
            foreach(
Playeri)
            {
                new 
GetPlayerVehicle(ivehicleid);
                if(
!= -1)
                {
                    new 
string[78 MAX_PLAYER_NAME];
                    if(
PlayerVehicleInfo[i][v][pvInsurance] == 1) { cext "Valid"; } else { cext "Invalid"; }
                    
format(stringsizeof(string), "Vehicle registration: %d | Make/Model: %s | Plate: %d  | Owner: %s | Insurance: %s",vehicleid,GetVehicleName(PlayerVehicleInfo[i][v][pvId]),PlayerVehicleInfo[i][v][pvPlate],GetPlayerNameEx(i),cext); // LINE WHERE PLATE IS LISTED
                    
SendClientMessageEx(playeridCOLOR_WHITEstring);
                    return 
1;
                }
            }
            for(new 
0MAX_FAMILYf++)
            {
                new 
GetGangVehicle(fvehicleid);
                if(
!= -1)
                {
                    new 
string[72 MAX_PLAYER_NAME];
                    
format(stringsizeof(string), "Vehicle registration: %d | Make/Model: %s | Family Owner: %s",vehicleid,GetVehicleName(FamilyVehicleInfo[f][v][fvId]), FamilyInfo[f][FamilyLeader]);
                    
SendClientMessageEx(playeridCOLOR_WHITEstring);
                    return 
1;
                }
            }
           
SendClientMessageEx(playeridCOLOR_GRAD2"This vehicle does not have any registration!");
        }
    }
    return 
1;


POSSIBLE CONNECTED CODES
PHP код:
stock LoadPlayerVehicles(playerid)
{
    new 
plate random(899999)+100000;
    new 
playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    
printf(" Loading %s's vehicles."playername);
    for(new 
0MAX_PLAYERVEHICLESv++)
    {
        if(
PlayerVehicleInfo[playerid][v][pvModelId] != && PlayerVehicleInfo[playerid][v][pvImpounded] == 0)
        {
            
PlayerCars++;
            new 
carcreated AddStaticVehicleEx(PlayerVehicleInfo[playerid][v][pvModelId], PlayerVehicleInfo[playerid][v][pvPosX], PlayerVehicleInfo[playerid][v][pvPosY], PlayerVehicleInfo[playerid][v][pvPosZ], PlayerVehicleInfo[playerid][v][pvPosAngle],PlayerVehicleInfo[playerid][v][pvColor1], PlayerVehicleInfo[playerid][v][pvColor2], -1);
            
PlayerVehicleInfo[playerid][v][pvId] = carcreated;
            if(
PlayerVehicleInfo[playerid][v][pvPlate] != 0)
            {
                
SetVehicleNumberPlate(carcreatedPlayerVehicleInfo[playerid][v][pvPlate]);
            }
            else
            {
                
format(PlayerVehicleInfo[playerid][v][pvPlate], 32"%d"plate);
                   
SetVehicleNumberPlate(carcreatedPlayerVehicleInfo[playerid][v][pvPlate]);
            }
            
SetVehicleNumberPlate(carcreatedPlayerVehicleInfo[playerid][v][pvPlate]);
            if(
PlayerVehicleInfo[playerid][v][pvLocked] == && !IsABike(PlayerVehicleInfo[playerid][v][pvId])) LockPlayerVehicle(playeridPlayerVehicleInfo[playerid][v][pvId], PlayerVehicleInfo[playerid][v][pvLock]);
        }
        else if(
PlayerVehicleInfo[playerid][v][pvModelId] == && PlayerVehicleInfo[playerid][v][pvImpounded] != 0)
            
PlayerVehicleInfo[playerid][v][pvImpounded] = 0;
    }
    
//LoadAllPlayerVehicleMods(playerid);
}
stock UnloadPlayerVehicles(playerid)
{
    new 
playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    
printf(" Unloading %s's vehicles."playername);
    for(new 
0MAX_PLAYERVEHICLESv++)
    {
        if(
PlayerVehicleInfo[playerid][v][pvId] != INVALID_PLAYER_VEHICLE_ID && PlayerVehicleInfo[playerid][v][pvImpounded] == 0)
        {
            
//new Float:x, Float:y, Float:z, Float:angle;
            //GetVehiclePos(PlayerVehicleInfo[playerid][v][pvId], x, y, z);
            //GetVehicleZAngle(PlayerVehicleInfo[playerid][v][pvId], angle);
            //UpdatePlayerVehicleParkPosition(playerid, v, x, y, z, angle);
            
PlayerCars--;
            if(
LockStatus[PlayerVehicleInfo[playerid][v][pvId]] != 0LockStatus[PlayerVehicleInfo[playerid][v][pvId]] = 0;
            
//UpdatePlayerVehicleMods(playerid, v);
            
DestroyVehicle(PlayerVehicleInfo[playerid][v][pvId]);
            
Gas[PlayerVehicleInfo[playerid][v][pvId]] = 100.0;
            
PlayerVehicleInfo[playerid][v][pvId] = INVALID_PLAYER_VEHICLE_ID;
            if(
PlayerVehicleInfo[playerid][v][pvAllowedPlayerId] != INVALID_PLAYER_ID)
            {
                
PlayerInfo[PlayerVehicleInfo[playerid][v][pvAllowedPlayerId]][pVehicleKeys] = INVALID_PLAYER_VEHICLE_ID;
                
PlayerInfo[PlayerVehicleInfo[playerid][v][pvAllowedPlayerId]][pVehicleKeysFrom] = INVALID_PLAYER_ID;
                
PlayerVehicleInfo[playerid][v][pvAllowedPlayerId] = INVALID_PLAYER_ID;
            }
        }
    }
}
stock UpdatePlayerVehicleParkPosition(playeridplayervehicleidFloat:newxFloat:newyFloat:newzFloat:newangleFloat:health)
{
    new 
playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    if(
PlayerVehicleInfo[playerid][playervehicleid][pvId] != INVALID_PLAYER_VEHICLE_ID)
    {
        if(
PlayerVehicleInfo[playerid][playervehicleid][pvPlate] != 0) {
            
SetVehicleNumberPlate(playervehicleidPlayerVehicleInfo[playerid][playervehicleid][pvPlate]);
        }
         new 
Float:oldxFloat:oldyFloat:oldzFloatoldfuel;
         
oldx PlayerVehicleInfo[playerid][playervehicleid][pvPosX];
         
oldy PlayerVehicleInfo[playerid][playervehicleid][pvPosY];
         
oldz PlayerVehicleInfo[playerid][playervehicleid][pvPosZ];
         if(
oldx == newx && oldy == newy && oldz == newz) return 0;
         
PlayerVehicleInfo[playerid][playervehicleid][pvPosX] = newx;
         
PlayerVehicleInfo[playerid][playervehicleid][pvPosY] = newy;
         
PlayerVehicleInfo[playerid][playervehicleid][pvPosZ] = newz;
         
PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle] = newangle;
         
Gas[PlayerVehicleInfo[playerid][playervehicleid][pvId]] = 100.0;
         for(new 
c=0c<12c++) {
             
RemoveVehicleComponent(playervehicleidc);
         }
         
//UpdatePlayerVehicleMods(playerid, playervehicleid);
         
DestroyVehicle(PlayerVehicleInfo[playerid][playervehicleid][pvId]);
         new 
carcreated AddStaticVehicleEx(PlayerVehicleInfo[playerid][playervehicleid][pvModelId], PlayerVehicleInfo[playerid][playervehicleid][pvPosX], PlayerVehicleInfo[playerid][playervehicleid][pvPosY], PlayerVehicleInfo[playerid][playervehicleid][pvPosZ],
         
PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle],PlayerVehicleInfo[playerid][playervehicleid][pvColor1], PlayerVehicleInfo[playerid][playervehicleid][pvColor2], -1);
         
PlayerVehicleInfo[playerid][playervehicleid][pvId] = carcreated;
         
Gas[carcreated] = oldfuel;
         
SetVehicleNumberPlate(carcreatedPlayerVehicleInfo[playerid][playervehicleid][pvPlate]);
         
SetVehicleHealth(carcreatedhealth);
         if(
PlayerVehicleInfo[playerid][playervehicleid][pvLocked] == 1LockPlayerVehicle(playeridPlayerVehicleInfo[playerid][playervehicleid][pvId], PlayerVehicleInfo[playerid][playervehicleid][pvLock]);
         
//LoadPlayerVehicleMods(playerid, playervehicleid);
         
return 1;
    }
    return 
0;

Reply
#2

PlayerVehicleInfo[i][v][pvPlate] is a string so use %s instead of %d specifier in format.
Reply
#3

Thankyou! One last question, how can I do xxx-000 format?
Reply
#4

Currently your plate is generated as a 6-digit number. Are you planning on keeping the number generated and just add "-000" to it or are you going to use a 3-digit number as displayed above?
Reply
#5

I want to do something like "SDA-221" but I don't know how to random letters not like what I've done to the digits.
Reply
#6

Try like this:

Код:
new plate[15];
new LetterList[26][] =
{
 "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 stringpl[5];
for(new i=0; i < 3; i++)
{
 format(stringpl, 5, "%s", LetterList[random(26)]);
 strcat(plate, stringpl);
}
strcat(plate, "-");
for(new i=0; i < 3; i++)
{
 format(stringpl, 5, "%d", random(9));
 strcat(plate, stringpl);
}
I am not sure if this works but try it
Reply
#7

pawn Код:
RandomEx(min, max)
{
    return random(max - min) + min;
}
pawn Код:
format(PlayerVehicleInfo[playerid][v][pvPlate], 32, "%c%c%c-%i", RandomEx('A', 'Z' + 1), RandomEx('A', 'Z' + 1), RandomEx('A', 'Z' + 1), RandomEx(100, 1000));
If that format will be permanent, you may want to change the size of pvPlate to 8.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)