SetVehicleNumberPlate
#1

Hello everyone,
I hope you can help me again with another problem.
I've made my own dynamic house/car system now but I still have a bug in it.
So what I want to do ingame: I buy a car, type in the specific command and get a question in which I get asked which color I want the car to have. So it starts a function to create a .dini file for this car. Everything works fine, the cars are loaded when the server starts, but not when I save my car. Here's the scriptcode:
pawn Код:
// DIALOG TO ASK FOR THE COLOR
            case DIALOG_FARBE:
            {
                new carcol, name[MAX_PLAYER_NAME], id, plat[256], plate[34], path[50], rnd;
                GetPlayerName(playerid,name,sizeof(name));
                id = GetPlayerVehicleID(playerid);
                new mdl = GetVehicleModel(id);
                switch(listitem)
                {
                    case 0: carcol = 1;
                    case 1: carcol = 0;
                    case 2: carcol = 2;
                    case 3: carcol = 3;
                    case 4: carcol = 6;
                    case 5: carcol = 13;
                    case 6: carcol = 55;
                    case 7: carcol = 126;
                }
                format(path,sizeof(path),"/spieler/%s.ini",name);
                plat = dini_Get(path,"Gebiet");
                rnd = random(999);
                format(plate,sizeof(plate),"%s-%i",plat,rnd);
                GetNewPrivateCar(playerid,name,mdl,carcol,carcol,plate);
//                              .....

// FUNCTION TO LOAD THE CARS ON GAMEMODEINIT
public LoadCars()
{
    new path[128];
    new  Float:cx, Float:cy, Float:cz, Float:cf, ID, C1, C2, Plate[256];
    for(new i=1; i<MAX_CARS; i++)
    {
        if(VehicleLoaded[i] == 0)
        {
        format(path,sizeof(path),"/autos/%i.ini",i);
        if(fexist(path))
        {
            cx = dini_Float(path,"X");
            cy = dini_Float(path,"Y");
            cz = dini_Float(path,"Z");
            cf = dini_Float(path,"Face");
            ID = dini_Int(path,"ID");
            C1 = dini_Int(path,"C1");
            C2 = dini_Int(path,"C2");
            Plate = dini_Get(path,"Plate");
            SetVehicleNumberPlate(CreateVehicle(ID, cx, cy, cz, cf, C1, C2, -1),Plate);
            VehicleLoaded[i] = 1;
        }
        }
        else break;
    }
    return 1;
}

// FUNCTION TO CREATE THE CAR
public GetNewPrivateCar(playerid,Owner[],CarID,Color1,Color2,Kennung[])
{
    new path[128], Float:px, Float:py, Float:pz, Float:pf, car;
    Wagenanzahl ++;
    format(path,sizeof(path),"/autos/%i.ini",Wagenanzahl);
    dini_Create(path);
    GetPlayerPos(playerid,px,py,pz);
    car = GetPlayerVehicleID(playerid);
    GetVehicleZAngle(car,pf);
    dini_FloatSet(path,"X",px);
    dini_FloatSet(path,"Y",py);
    dini_FloatSet(path,"Z",pz);
    dini_FloatSet(path,"Face",pf);
    dini_IntSet(path,"ID",CarID);
    dini_IntSet(path,"C1",Color1);
    dini_IntSet(path,"C2",Color2);
    dini_Set(path,"Owner",Owner);
    dini_Set(path,"Owner2","");
    dini_Set(path,"Plate",Kennung);
    SetVehicleNumberPlate(CreateVehicle(CarID, px, py, pz, pf, Color1, Color2, -1),Kennung);
    format(path,sizeof(path),"/autos/anzahl.ini");
    dini_IntSet(path,"anzahl",Wagenanzahl);
    return 1;
}
I hope you can help
Padarom
Reply
#2

Can noone help?
Reply
#3

Код:
      
        new string[12];
        format(string, sizeof(string),"%d",plate);
        SetVehicleNumberPlate(CreateVehicle(ID, cx, cy, cz, cf, C1, C2, -1), string);
EDIT: New loadcars

Код:
public LoadCars()
{
    new string[12];
    new path[128];
    new  Float:cx, Float:cy, Float:cz, Float:cf, ID, C1, C2, Plate[256];
    for(new i=1; i<MAX_CARS; i++)
    {
        if(VehicleLoaded[i] == 0)
        {
        format(path,sizeof(path),"/autos/%i.ini",i);
        if(fexist(path))
        {
            cx = dini_Float(path,"X");
            cy = dini_Float(path,"Y");
            cz = dini_Float(path,"Z");
            cf = dini_Float(path,"Face");
            ID = dini_Int(path,"ID");
            C1 = dini_Int(path,"C1");
            C2 = dini_Int(path,"C2");
            Plate = dini_Get(path,"Plate");
            format(string, sizeof(string),"%d",Plate);
            SetVehicleNumberPlate(CreateVehicle(ID, cx, cy, cz, cf, C1, C2, -1), string);
            VehicleLoaded[i] = 1;
            }
        }
        else break;
    }
    return 1;
}
Reply
#4

Thank you for your answer, but the LoadCars is in OnGameModeInit and works, my main problem is the next callback GetNewPrivateCar where a new vehicle should be created. Because there isn't any car created. The LoadCars callback works fine.

Padarom
Reply
#5

Can still nobody help me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)