Problem on vehicles
#1

Hello sa-mp.com . I have a problem and asking you guys can manage to help me. The problem is the following: I did a system of registration for personal cars with 3dtext. Everything works perfectly if you're alone on the server, or if you're the only one who uses command but for the moment all players begin to gather even more use command the registration number transfer from one vehicle to another , i mean if I put my number , for example B-04-DNY , when someone puts their number , my number disappears from the car and move to the one using the command but for me the number of his choice . After this happens , if i try to put another number it changes , but changes on the car of the person who used the command after me and the number remains at him ) . The number appears on my vehicle if I only give relog.

I will post all all lines related to register system.


Variables and defines :

Code:
new PlateCar1[256], Text3D:PlateUpCar1[MAX_VEHICLES];
new PlateCar2[256], Text3D:PlateUpCar2[MAX_VEHICLES];
new PlateCar3[256], Text3D:PlateUpCar3[MAX_VEHICLES];
new PlateCar4[256], Text3D:PlateUpCar4[MAX_VEHICLES];

#define DialogPlate1 3364
#define DialogPlate2 3365
#define DialogPlate3 3366

new TextCar[256], Text3D:TextUpCar[MAX_VEHICLES];
new OffTextCar[256], Text3D:OffTextUpCar[MAX_VEHICLES];
At OnPlayerDisconnect I have a function to do that when a player comes off the server to delete the number from the car and his car set 255 as the virtual world not to be crowded streets from cars.

OnPlayerDisconnect :

Code:
if (PlayerInfo[playerid][pPcarkey] != -1)
    {
        new vehicleid1 = PlayerInfo[playerid][pPcarkey];
        SetVehicleVirtualWorld(PlayerInfo[playerid][pPcarkey], 255); Delete3DTextLabel(TextUpCar[CarInfo[vehicleid1][cLicense]]);
    }
    if (PlayerInfo[playerid][pPcarkey2] != -1)
    {
        new vehicleid2 = PlayerInfo[playerid][pPcarkey2];
        SetVehicleVirtualWorld(PlayerInfo[playerid][pPcarkey2], 255); Delete3DTextLabel(TextUpCar[CarInfo[vehicleid2][cLicense]]);
    }
    if (PlayerInfo[playerid][pPcarkey3] != -1)
    {
        new vehicleid3 = PlayerInfo[playerid][pPcarkey3];
        SetVehicleVirtualWorld(PlayerInfo[playerid][pPcarkey3], 255); Delete3DTextLabel(TextUpCar[CarInfo[vehicleid3][cLicense]]);
    }
At OnPlayerLogin I have a function that when a player connects to check if he has his car or cars and I set VW + 0 if he has to check whether the number and if it's not in the default set.

OnPlayerLogin :

Code:
 if (PlayerInfo[playerid][pPcarkey] != -1)
        {
            new vehicleid = PlayerInfo[playerid][pPcarkey];
            if(CarInfo[vehicleid][cPlate] >= 1)
            {
                   format(OffTextCar, sizeof(OffTextCar), "%s", CarInfo[vehicleid][cLicense]);
                OffTextUpCar[vehicleid] = Create3DTextLabel(OffTextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                Attach3DTextLabelToVehicle(Text3D:OffTextUpCar[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                SetVehicleVirtualWorld(vehicleid, 0);
            }
            else
            {
                format(TextCar, sizeof(TextCar), "LS-666-BNZ", CarInfo[vehicleid][cLicense]);
                TextUpCar[vehicleid] = Create3DTextLabel(TextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                Attach3DTextLabelToVehicle(Text3D:TextUpCar[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                SetVehicleVirtualWorld(vehicleid, 0);
            }
        }
        if (PlayerInfo[playerid][pPcarkey2] != -1)
        {
            new vehicleid = PlayerInfo[playerid][pPcarkey2];
            if(CarInfo[vehicleid][cPlate] >= 1)
            {
                   format(OffTextCar, sizeof(OffTextCar), "%s", CarInfo[vehicleid][cLicense]);
                OffTextUpCar[vehicleid] = Create3DTextLabel(OffTextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                Attach3DTextLabelToVehicle(Text3D:OffTextUpCar[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                SetVehicleVirtualWorld(vehicleid, 0);
            }
            else
            {
                format(TextCar, sizeof(TextCar), "LS-666-BNZ", CarInfo[vehicleid][cLicense]);
                TextUpCar[vehicleid] = Create3DTextLabel(TextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                Attach3DTextLabelToVehicle(Text3D:TextUpCar[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                SetVehicleVirtualWorld(vehicleid, 0);
            }
        }
        if (PlayerInfo[playerid][pPcarkey3] != -1)
        {
            new vehicleid = PlayerInfo[playerid][pPcarkey3];
            if(CarInfo[vehicleid][cPlate] >= 1)
            {
                   format(OffTextCar, sizeof(OffTextCar), "%s", CarInfo[vehicleid][cLicense]);
                OffTextUpCar[vehicleid] = Create3DTextLabel(OffTextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                Attach3DTextLabelToVehicle(Text3D:OffTextUpCar[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                SetVehicleVirtualWorld(vehicleid, 0);
            }
            else
            {
                format(TextCar, sizeof(TextCar), "LS-666-BNZ", CarInfo[vehicleid][cLicense]);
                TextUpCar[vehicleid] = Create3DTextLabel(TextCar, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                Attach3DTextLabelToVehicle(Text3D:TextUpCar[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                SetVehicleVirtualWorld(vehicleid, 0);
            }
        }
Then after checking the command it will show:

Code:
if(strcmp(x_nr,"plate",true) == 0)
            {
                GetPlayerMoney(playerid);
                if(PlayerInfo[playerid][pCash] < 15000)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You don't have enough moneys .");
                    return 1;
                }
                if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
                {
                    SendClientMessage(playerid, COLOR_GREY,"  You don't have a personal car .");
                    return 1;
                }
                new carid;
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
                else { return 1; }
                if(IsPlayerInVehicle(playerid, carid))
                {
                    ShowPlayerDialog(playerid, DialogPlate1, DIALOG_STYLE_INPUT, "Inmatriculare", "Pune initialele orasului\nExemplu: LS", "Next","Close");
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "You must be in a personal car.");
                }
            }
And answers to further dialogues:

Code:
if(PlayerInfo[playerid][pPcarkey] != 1)
    {
        if(dialogid == DialogPlate1)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    if(strlen(inputtext) < 3 && strlen(inputtext) > 0)
                    {
                        format(PlateCar1[0], sizeof(PlateCar1), "%s", inputtext);
                        PlateCar1 = strtoupper(PlateCar1);
                        PlateUpCar1[vehicleid] = Create3DTextLabel(PlateCar1, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                        SetVehicleVirtualWorld(vehicleid, 0);
                        ShowPlayerDialog(playerid, DialogPlate2, DIALOG_STYLE_INPUT, "Inmatriculari", "Alege maxim trei numere pe care le doresi\nExemplu : 666", "Next","Close");
                    }
                    else { }
                }
            }
        }
        if(dialogid == DialogPlate2)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    if(strlen(inputtext) == 2 || strlen(inputtext) == 3)
                    {
                        format(PlateCar2, sizeof(PlateCar2), "%s", inputtext);
                        PlateUpCar2[vehicleid] = Create3DTextLabel(PlateCar2, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                        SetVehicleVirtualWorld(vehicleid, 0);
                         if(Numbers(inputtext)) return ShowPlayerDialog(playerid, DialogPlate3, DIALOG_STYLE_INPUT, "Inmatriculari", "Alege trei initiale pe care le vrei\nExemplu : CVL", "Done","Close");
                        else { }
                    }
                    else { }
                }
            }
        }
        if(dialogid == DialogPlate3)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey];
                new carid = GetPlayerVehicleID(playerid);
                if(IsPlayerInVehicle(playerid, vehicleid))
                //if(Numbers(inputtext)) { return }
                {
                    if(strlen(inputtext) == 3)
                    {
                        Delete3DTextLabel(TextUpCar[vehicleid]);
                        format(PlateCar3, sizeof(PlateCar3), "%s", inputtext);
                        PlateCar3 = strtoupper(PlateCar3);
                        PlateUpCar3[vehicleid] = Create3DTextLabel(PlateCar3, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                        format(PlateCar4, sizeof(PlateCar4), "%s-%s-%s", PlateCar1[0], PlateCar2, PlateCar3[0]);
                        Delete3DTextLabel(Text3D:PlateUpCar4[vehicleid]);
                        PlateUpCar4[vehicleid] = Create3DTextLabel(PlateCar4, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                        SetVehicleToRespawn(vehicleid);
                        Attach3DTextLabelToVehicle(Text3D:PlateUpCar4[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                        PutPlayerInVehicle(playerid, carid, 2);
                        SetVehicleVirtualWorld(vehicleid, 0);
                        CarInfo[vehicleid][cPlate] = 1;
                        CarInfo[vehicleid][cLicense] = PlateCar4;
                        GivePlayerMoney(playerid, -15000);
                        SendClientMessage(playerid, COLOR_WHITE, "Ti-ai schimbat numarul de inmatriculare si ai platit {FF0000}$15.000 !");
                        SBizzInfo[13][sbTill] += 5000;//plate buisness
                        ExtortionSBiz(13, 5000);
                        OnCarUpdate();
                    }
                    else { }
                }
            }
        }
    }
    if(PlayerInfo[playerid][pPcarkey2] != 1)
    {
        if(dialogid == DialogPlate1)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey2];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    format(PlateCar1, sizeof(PlateCar1), "%s", inputtext);
                    PlateCar1 = strtoupper(PlateCar1);
                    PlateUpCar1[vehicleid] = Create3DTextLabel(PlateCar1, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    SetVehicleVirtualWorld(vehicleid, 0);
                    ShowPlayerDialog(playerid, DialogPlate2, DIALOG_STYLE_INPUT, "Inmatriculari", "Alege maxim trei numere pe care le doresi\nExemplu : 666", "Next","Close");
                }
            }
        }
        if(dialogid == DialogPlate2)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey2];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    format(PlateCar2, sizeof(PlateCar2), "%s", inputtext);
                    PlateUpCar2[vehicleid] = Create3DTextLabel(PlateCar2, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    SetVehicleVirtualWorld(vehicleid, 0);
                     if(Numbers(inputtext)) return ShowPlayerDialog(playerid, DialogPlate3, DIALOG_STYLE_INPUT, "Inmatriculari", "Alege trei initiale pe care le vrei\nExemplu : CVL", "Done","Close");
                    else { }
                }
            }
        }
        if(dialogid == DialogPlate3)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey2];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    Delete3DTextLabel(TextUpCar[vehicleid]);
                    format(PlateCar3, sizeof(PlateCar3), "%s", inputtext);
                    PlateCar3 = strtoupper(PlateCar3);
                    PlateUpCar3[vehicleid] = Create3DTextLabel(PlateCar3, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    format(PlateCar4, sizeof(PlateCar4), "%s-%s-%s", PlateCar1, PlateCar2, PlateCar3);
                    Delete3DTextLabel(Text3D:PlateUpCar4[vehicleid]);
                    PlateUpCar4[vehicleid] = Create3DTextLabel(PlateCar4, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    Delete3DTextLabel(Text3D:TextUpCar[vehicleid]);
                    Attach3DTextLabelToVehicle(Text3D:PlateUpCar4[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                    SetVehicleToRespawn(vehicleid);
                    SetVehicleVirtualWorld(vehicleid, 0);
                    CarInfo[vehicleid][cPlate] = 1;
                    CarInfo[vehicleid][cLicense] = PlateCar4;
                    GivePlayerMoney(playerid, -15000);
                    SendClientMessage(playerid, COLOR_WHITE, "Ti-ai schimbat numarul de inmatriculare si ai platit {FF0000}$15.000 !");
                    OnCarUpdate();
                }
            }
        }
    }
    if(PlayerInfo[playerid][pPcarkey3] != 1)
    {
        if(dialogid == DialogPlate1)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey3];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    format(PlateCar1, sizeof(PlateCar1), "%s", inputtext);
                    PlateCar1 = strtoupper(PlateCar1);
                    PlateUpCar1[vehicleid] = Create3DTextLabel(PlateCar1, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    SetVehicleVirtualWorld(vehicleid, 0);
                    ShowPlayerDialog(playerid, DialogPlate2, DIALOG_STYLE_INPUT, "Inmatriculari", "Alege maxim trei numere pe care le doresi\nExemplu : 666", "Next","Close");
                }
            }
        }
        if(dialogid == DialogPlate2)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey3];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    format(PlateCar2, sizeof(PlateCar2), "%s", inputtext);
                    PlateUpCar2[vehicleid] = Create3DTextLabel(PlateCar2, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    SetVehicleVirtualWorld(vehicleid, 0);
                     if(Numbers(inputtext)) return ShowPlayerDialog(playerid, DialogPlate3, DIALOG_STYLE_INPUT, "Inmatriculari", "Alege trei initiale pe care le vrei\nExemplu : CVL", "Done","Close");
                    else { }
                }
            }
        }
        if(dialogid == DialogPlate3)
        {
            if(response)
            {
                new vehicleid = PlayerInfo[playerid][pPcarkey3];
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    Delete3DTextLabel(TextUpCar[vehicleid]);
                    format(PlateCar3, sizeof(PlateCar3), "%s", inputtext);
                    PlateCar3 = strtoupper(PlateCar3);
                    PlateUpCar3[vehicleid] = Create3DTextLabel(PlateCar3, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    format(PlateCar4, sizeof(PlateCar4), "%s-%s-%s", PlateCar1, PlateCar2, PlateCar3);
                    Delete3DTextLabel(Text3D:PlateUpCar4[vehicleid]);
                    PlateUpCar4[vehicleid] = Create3DTextLabel(PlateCar4, 0x33AAFFFF , 0.0, 0.0, 0.0, 25, 0, 1);
                    Delete3DTextLabel(Text3D:TextUpCar[vehicleid]);
                    Attach3DTextLabelToVehicle(Text3D:PlateUpCar4[vehicleid], vehicleid, 0.0, 0.0, 0.1);
                    SetVehicleToRespawn(vehicleid);
                    SetVehicleVirtualWorld(vehicleid, 0);
                    CarInfo[vehicleid][cPlate] = 1;
                    CarInfo[vehicleid][cLicense] = PlateCar4;
                    GivePlayerMoney(playerid, -15000);
                    SendClientMessage(playerid, COLOR_WHITE, "Ti-ai schimbat numarul de inmatriculare si ai platit {FF0000}$15.000 !");
                    OnCarUpdate();
                }
            }
        }
    }
This is all. I'm almost 100% sure that the dialogues and the way of creating the text's problem is, but I can't realize ... I tried everything I know, but ... nothing. I do not think that's the way to save data, yet it and show it on defined variables for save number:

Variables created intro a enum:

Code:
cLicense[256],
  cPlate[14],
How to save:

Code:
public OnCarUpdate()
{
    new idx;
    new File: file2;
    idx = carsonserver;
     while (idx < sizeof(CarInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%s\n",
        CarInfo[idx][cModel],
        CarInfo[idx][cLocationx],
        CarInfo[idx][cLocationy],
        CarInfo[idx][cLocationz],
        CarInfo[idx][cAngle],
        CarInfo[idx][cColorOne],
        CarInfo[idx][cColorTwo],
        CarInfo[idx][cOwner],
        CarInfo[idx][cDescription],
        CarInfo[idx][cOwned],
        CarInfo[idx][cLicense],
        CarInfo[idx][cPlate]);
        if(idx == carsonserver)
        {
            file2 = fopen("masini.cfg", io_write);
        }
        else
        {
            file2 = fopen("masini.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
}
Loading mode:

Code:
public LoadCar()
{
    new arrCoords[12][64];
    new strFromFile2[256];
    new File: file = fopen("masini.cfg", io_read);
    if (file)
    {
        new idx = carsonserver;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            CarInfo[idx][cModel] = strval(arrCoords[0]);
            CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][cColorOne] = strval(arrCoords[5]);
            CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][cOwned] = strval(arrCoords[9]);
            strmid(CarInfo[idx][cLicense], arrCoords[10], 0, strlen(arrCoords[10]), 255);
            CarInfo[idx][cPlate] = strval(arrCoords[11]);
            idx++;
        }
        for(new h = carsonserver; h < sizeof(CarInfo); h++)
        {
            AddStaticVehicleEx(CarInfo[h][cModel], CarInfo[h][cLocationx], CarInfo[h][cLocationy], CarInfo[h][cLocationz]+1.0, CarInfo[h][cAngle], CarInfo[h][cColorOne], CarInfo[h][cColorTwo], -1);
            SetVehicleVirtualWorld(h, 255);
        }
    }
    return 1;
}
The vehicle system is started from that of I'm_BanK. Thank you again!

Sorry for my bad english, i'm Romanian . Please, try to help me , i give rep . Thank's .
Reply
#2

I don't understand, but try to set an ID for each car with the string as an enum, the issue's probably in incorrect vehicle ids..
Reply
#3

Quote:
Originally Posted by xVIP3Rx
View Post
I don't understand, but try to set an ID for each car with the string as an enum, the issue's probably in incorrect vehicle ids..
How ? I don't understand ...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)