Dynamic vehicle plate system
#1

pawn Код:
new __a = CreateVehicle(Vehicles[i][carmodel],Vehicles[i][fx], Vehicles[i][fy],Vehicles[i][fz],Vehicles[i][fa], Vehicles[i][color1],Vehicles[i][color2] , Vehicles[i][respawn]);
    SetVehicleVirtualWorld(__a, Vehicles[i][vw]);
    if(Vehicles[i][carprice]) UnlockVehicle(i);
    format(iStr, sizeof(iStr), "%s", Vehicles[i][plate]);
    SetVehicleNumberPlate(i, Vehicles[i][plate]);
    SetVehicleToRespawn(i);
}
What's wrong in this code?
Reply
#2

What's it not doing?
Reply
#3

Probably that the vehicle respawns in the default virtual world: 0.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Probably that the vehicle respawns in the default virtual world: 0.
The vehicle respawns, just the custom plate text doesn't appear.
This is the whole public:
pawn Код:
stock LoadVehicle(i)
{
    Vehicles[i][carmodel] = dini_Int(CarFile(i), "model");
    Vehicles[i][fx] = dini_Float(CarFile(i), "x");
    Vehicles[i][fy] = dini_Float(CarFile(i), "y");
    Vehicles[i][fz] = dini_Float(CarFile(i), "z");
    Vehicles[i][fa] = dini_Float(CarFile(i), "a");
    Vehicles[i][color1] = dini_Int(CarFile(i), "color1");
    Vehicles[i][color2] = dini_Int(CarFile(i), "color2");
    Vehicles[i][nitro] = dini_Int(CarFile(i), "nitro");
    Vehicles[i][paintjob] = dini_Int(CarFile(i), "paintjob");
    Vehicles[i][carteam] = dini_Int(CarFile(i), "carteam");
    Vehicles[i][cartype] = dini_Int(CarFile(i), "cartype");
    Vehicles[i][modeltype] = dini_Int(CarFile(i), "modeltype");
    Vehicles[i][biznumber] = dini_Int(CarFile(i), "biznumber");
    Vehicles[i][reset] = dini_Int(CarFile(i), "resetted");
 Vehicles[i][plate] = dini_Int(CarFile(i), "plate");
    Vehicles[i][vw] = dini_Int(CarFile(i), "vw");
    Vehicles[i][carprice] = dini_Int(CarFile(i), "price");
    myStrcpy(Vehicles[i][jobname], dini_Get(CarFile(i), "jobname"));
    myStrcpy(Vehicles[i][carowner],dini_Get(CarFile(i), "owner"));
    myStrcpy(Vehicles[i][dupekey],dini_Get(CarFile(i), "dupekey"));
    sscanf(dini_Get(CarFile(i), "components"), "p<,>iiiiiiiiiiiiii",
                Vehicles[i][Components][0],
                Vehicles[i][Components][1],
                Vehicles[i][Components][2],
                Vehicles[i][Components][3],
                Vehicles[i][Components][4],
                Vehicles[i][Components][5],
                Vehicles[i][Components][6],
                Vehicles[i][Components][7],
                Vehicles[i][Components][8],
                Vehicles[i][Components][9],
                Vehicles[i][Components][10],
                Vehicles[i][Components][11],
                Vehicles[i][Components][12],
                Vehicles[i][Components][13]
            );
    SetTimerEx("ModCar", 2000, 0, "d", i);
    if(Vehicles[i][carprice] == -1)
    {
        dini_IntSet(CarFile(i), "price", 0);
        Vehicles[i][carprice] = 0;
    }
    new __a = CreateVehicle(Vehicles[i][carmodel],Vehicles[i][fx], Vehicles[i][fy],Vehicles[i][fz],Vehicles[i][fa], Vehicles[i][color1],Vehicles[i][color2] , Vehicles[i][respawn]);
    SetVehicleVirtualWorld(__a, Vehicles[i][vw]);
    if(Vehicles[i][carprice]) UnlockVehicle(i);
    format(iStr, sizeof(iStr), "%s", Vehicles[i][plate]);
    SetVehicleNumberPlate(i, Vehicles[i][plate]);
    SetVehicleToRespawn(i);
}
Reply
#5

Код:
Vehicles[i][plate] = dini_Int(CarFile(i), "plate");
This should be a string I suspect?

Should check what it was putting out first with print so you can see.


If this also is a case, you'll probably need to check your save function, and reset the plates in the database.
Reply
#6

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
What's it not doing?
It isn't showing the plate, it's just putting the normal plate on it, (samp default plate)
Reply
#7

As I said, is it supposed to be a string, or is it simply containing numbers... because that's where the problem lies.

If you put a string longer than 32 to the plate, it'll simply put a "normal plate" on.
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
As I said, is it supposed to be a string, or is it simply containing numbers... because that's where the problem lies.

If you put a string longer than 32 to the plate, it'll simply put a "normal plate" on.
aha, i think i get the problem now.
hmm
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
As I said, is it supposed to be a string, or is it simply containing numbers... because that's where the problem lies.

If you put a string longer than 32 to the plate, it'll simply put a "normal plate" on.
Ah, it works now, abit.
The plate that is now shown shows: 0,0,0,0,0,0,0
This is my public:
pawn Код:
stock LoadVehicle(i)
{
    Vehicles[i][carmodel] = dini_Int(CarFile(i), "model");
    Vehicles[i][fx] = dini_Float(CarFile(i), "x");
    Vehicles[i][fy] = dini_Float(CarFile(i), "y");
    Vehicles[i][fz] = dini_Float(CarFile(i), "z");
    Vehicles[i][fa] = dini_Float(CarFile(i), "a");
    Vehicles[i][color1] = dini_Int(CarFile(i), "color1");
    Vehicles[i][color2] = dini_Int(CarFile(i), "color2");
    Vehicles[i][nitro] = dini_Int(CarFile(i), "nitro");
    Vehicles[i][paintjob] = dini_Int(CarFile(i), "paintjob");
    Vehicles[i][carteam] = dini_Int(CarFile(i), "carteam");
    Vehicles[i][cartype] = dini_Int(CarFile(i), "cartype");
    Vehicles[i][modeltype] = dini_Int(CarFile(i), "modeltype");
    Vehicles[i][biznumber] = dini_Int(CarFile(i), "biznumber");
    Vehicles[i][reset] = dini_Int(CarFile(i), "resetted");
    Vehicles[i][vw] = dini_Int(CarFile(i), "vw");
    Vehicles[i][plate] = dini_Int(CarFile(i), "plate");
    Vehicles[i][carprice] = dini_Int(CarFile(i), "price");
    myStrcpy(Vehicles[i][jobname], dini_Get(CarFile(i), "jobname"));
    myStrcpy(Vehicles[i][carowner],dini_Get(CarFile(i), "owner"));
    myStrcpy(Vehicles[i][dupekey],dini_Get(CarFile(i), "dupekey"));
    sscanf(dini_Get(CarFile(i), "components"), "p<,>iiiiiiiiiiiiii",
                Vehicles[i][Components][0],
                Vehicles[i][Components][1],
                Vehicles[i][Components][2],
                Vehicles[i][Components][3],
                Vehicles[i][Components][4],
                Vehicles[i][Components][5],
                Vehicles[i][Components][6],
                Vehicles[i][Components][7],
                Vehicles[i][Components][8],
                Vehicles[i][Components][9],
                Vehicles[i][Components][10],
                Vehicles[i][Components][11],
                Vehicles[i][Components][12],
                Vehicles[i][Components][13]
            );
    SetTimerEx("ModCar", 2000, 0, "d", i);
    if(Vehicles[i][carprice] == -1)
    {
        dini_IntSet(CarFile(i), "price", 0);
        Vehicles[i][carprice] = 0;
    }
    new __a = CreateVehicle(Vehicles[i][carmodel],Vehicles[i][fx], Vehicles[i][fy],Vehicles[i][fz],Vehicles[i][fa], Vehicles[i][color1],Vehicles[i][color2] , Vehicles[i][respawn]);
    new iStr [128];
    SetVehicleVirtualWorld(__a, Vehicles[i][vw]);
    if(Vehicles[i][carprice]) UnlockVehicle(i);
    format(iStr, sizeof(iStr), "%s", plate);
    SetVehicleNumberPlate(i, iStr);
    SetVehicleToRespawn(i);
}
This is the car file:
Код:
model=431
x=1799.267456
y=-1930.024047
z=13.491653
a=359.965728
color1=41
color2=41
nitro=0
plate=Taxi
paintjob=-1
carteam=0
cartype=0
modeltype=0
biznumber=0
vw=0
jobname=None
owner=Unity_Station
dupekey=NoBodY
price=0
resetted=0
components=0,0,0,0,0,0,0,0,0,0,0,0,0,0
Anything wrong here?
Reply
#10

Change
pawn Код:
Vehicles[i][plate] = dini_Int(CarFile(i), "plate");
to
pawn Код:
format(Vehicles[i][plate], 32, "%s", dini_Get(CarFile(i), "plate"));
Then remove the
pawn Код:
new iStr;
format(iStr, sizeof(iStr), "%s", plate);
And set the plate:
pawn Код:
SetVehicleNumberPlate(i, Vehicles[i][plate]);
Also make sure that Vehicles[i][plate] is defined a String in the enum.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)