[Help] Owned Car Problems on Spawning :(
#1

Alright, on my server that I am scripting I have made it where the players may own up to three vehicles they can buy from a dealership. I did it a little differently than most people probably but I used dini.

pawn Код:
new OwnedCar1[MAX_PLAYERS];
new OwnedCar2[MAX_PLAYERS];
new OwnedCar3[MAX_PLAYERS];
And later in the script I check if dini exists for each of these slots and create them, that's no problem. Works fairly perfectly.

On my spawn command "/spawnmycars" is spawns all three cars at the same time and loads all their mods and health etc all neat and nicely as it should and gets the vehicles in the right order.

I have a garage/impound like setup on my server and when you /spawnmycars if they're in there they won't spawn which is what I want and the idea is you have to go to the dialog at the place and pay the bill and it'll spawn the vehicle outside of the garage door (I saved the coordinates when the vehicle was impounded to the vehicles file). Alright. This works good, now here is my problem.

Dialog list allows you to pick Slot 1, Slot 2, Slot 3. Whichever slot you pick gives you ChosenSlot[playerid] = 1; 2 or 3 whichever slot it might be. So for whichever slot it loads what the fee is (tow + repairs) and it does this correctly for each vehicle. But if I have more than one vehicle in there at one time say all 3 for instance.. if I click slot 3 first and buy it out, it will become OwnerCar1[playerid] for some reason instead of OwnerCar3[playerid] like it should be so if I /parkcar it, it saves the coordinates in OwnerCar1's file instead of OwnerCar3's. Then when I go back and buy OwnerCar1[playerid] out of the impound it becomes OwnerCar1 like it's supposed to be and spawns wherever I saved OwnerCar3 earlier, which was for some reason considered OwnerCar1..... I can't figure it out hmmm. Probably something simple but I'm really tired and I'm sure you fellas are a lot brighter than I am!

pawn Код:
if(response)
        {
            new string[256];
            new money = GetPlayerMoney(playerid);
            new name[MAX_PLAYERS];
            GetPlayerName(playerid, name, sizeof(name));
            if(ChosenSlot[playerid] == 1)
            {
                if(money >= TowBill[playerid])
                {
                    CarIsBroken[OwnedCar1[playerid]] = 0;
                    GivePlayerMoney2(playerid, -TowBill[playerid]);
                    format(string, sizeof(string), "%s1.ini", name);
                    format(file6, sizeof(file6), USER_CAR_FILE, string);
                    new vehmodel = dini_Int(file6, "Model");
                    new vehX = dini_Int(file6, "carX");
                    new vehY = dini_Int(file6, "carY");
                    new vehZ = dini_Int(file6, "carZ");
                    new vehA = dini_Int(file6, "carA");
                    new modification1 = dini_Int(file6, "Mod1");
                    new modification2 = dini_Int(file6, "Mod2");
                    new modification3 = dini_Int(file6, "Mod3");
                    new modification4 = dini_Int(file6, "Mod4");
                    new modification5 = dini_Int(file6, "Mod5");
                    new modification6 = dini_Int(file6, "Mod6");
                    new modification7 = dini_Int(file6, "Mod7");
                    new modification8 = dini_Int(file6, "Mod8");
                    new modification9 = dini_Int(file6, "Mod9");
                    new modification10 = dini_Int(file6, "Mod10");
                    new modification11 = dini_Int(file6, "Mod11");
                    new modification12 = dini_Int(file6, "Mod12");
                    new modification13 = dini_Int(file6, "Mod13");
                    new modification14 = dini_Int(file6, "Mod14");
                    new modification15 = dini_Int(file6, "Mod15");
                    new modification16 = dini_Int(file6, "Mod16");
                    new modification17 = dini_Int(file6, "Mod17");
                    new vehcol1 = dini_Int(file6, "color01");
                    new vehcol2 = dini_Int(file6, "color02");
                    OwnedCar1[playerid] = CreateVehicle(vehmodel, vehX, vehY, vehZ, vehA, vehcol1, vehcol2, -1);
                    SetVehicleNumberPlate(OwnedCar1[playerid], dini_Get(file6, "plate"));
                    ChangeVehiclePaintjob(OwnedCar1[playerid], dini_Int(file6, "paint"));
                    if(modification1 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification1); }
                    if(modification2 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification2); }
                    if(modification3 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification3); }
                    if(modification4 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification4); }
                    if(modification5 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification5); }
                    if(modification6 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification6); }
                    if(modification7 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification7); }
                    if(modification8 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification8); }
                    if(modification9 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification9); }
                    if(modification10 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification10); }
                    if(modification11 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification11); }
                    if(modification12 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification12); }
                    if(modification13 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification13); }
                    if(modification14 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification14); }
                    if(modification15 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification15); }
                    if(modification16 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification16); }
                    if(modification17 != 0){ AddVehicleComponent(OwnedCar1[playerid], modification17); }
                    new engine, lights, alarm, doors, bonnet, boot, objective;
                    GetVehicleParamsEx(OwnedCar1[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(OwnedCar1[playerid], dini_Int(file6, "engine"), lights, alarm, dini_Int(file6, "locked"), bonnet, boot, objective);
                    dini_IntSet(file6, "IsTowed", 0);
                    dini_IntSet(file6, "TowBill", 0);
                    return 1;
                }
                if(money < TowBill[playerid])
                {
                    SendClientMessage(playerid, COLOR_RED, "[Server]: You don't have enough money!");
                }
            }
            if(ChosenSlot[playerid] == 2)
            {
                if(money >= TowBill[playerid])
                {
                    CarIsBroken[OwnedCar2[playerid]] = 0;
                    GivePlayerMoney2(playerid, -TowBill[playerid]);
                    format(string, sizeof(string), "%s2.ini", name);
                    format(file6, sizeof(file6), USER_CAR_FILE, string);
                    new vehmodel = dini_Int(file6, "Model");
                    new vehX = dini_Int(file6, "carX");
                    new vehY = dini_Int(file6, "carY");
                    new vehZ = dini_Int(file6, "carZ");
                    new vehA = dini_Int(file6, "carA");
                    new modification1 = dini_Int(file6, "Mod1");
                    new modification2 = dini_Int(file6, "Mod2");
                    new modification3 = dini_Int(file6, "Mod3");
                    new modification4 = dini_Int(file6, "Mod4");
                    new modification5 = dini_Int(file6, "Mod5");
                    new modification6 = dini_Int(file6, "Mod6");
                    new modification7 = dini_Int(file6, "Mod7");
                    new modification8 = dini_Int(file6, "Mod8");
                    new modification9 = dini_Int(file6, "Mod9");
                    new modification10 = dini_Int(file6, "Mod10");
                    new modification11 = dini_Int(file6, "Mod11");
                    new modification12 = dini_Int(file6, "Mod12");
                    new modification13 = dini_Int(file6, "Mod13");
                    new modification14 = dini_Int(file6, "Mod14");
                    new modification15 = dini_Int(file6, "Mod15");
                    new modification16 = dini_Int(file6, "Mod16");
                    new modification17 = dini_Int(file6, "Mod17");
                    new vehcol1 = dini_Int(file6, "color01");
                    new vehcol2 = dini_Int(file6, "color02");
                    OwnedCar2[playerid] = CreateVehicle(vehmodel, vehX, vehY, vehZ, vehA, vehcol1, vehcol2, -1);
                    SetVehicleNumberPlate(OwnedCar2[playerid], dini_Get(file6, "plate"));
                    ChangeVehiclePaintjob(OwnedCar2[playerid], dini_Int(file6, "paint"));
                    if(modification1 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification1); }
                    if(modification2 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification2); }
                    if(modification3 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification3); }
                    if(modification4 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification4); }
                    if(modification5 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification5); }
                    if(modification6 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification6); }
                    if(modification7 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification7); }
                    if(modification8 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification8); }
                    if(modification9 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification9); }
                    if(modification10 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification10); }
                    if(modification11 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification11); }
                    if(modification12 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification12); }
                    if(modification13 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification13); }
                    if(modification14 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification14); }
                    if(modification15 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification15); }
                    if(modification16 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification16); }
                    if(modification17 != 0){ AddVehicleComponent(OwnedCar2[playerid], modification17); }
                    new engine, lights, alarm, doors, bonnet, boot, objective;
                    GetVehicleParamsEx(OwnedCar2[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(OwnedCar2[playerid], dini_Int(file6, "engine"), lights, alarm, dini_Int(file6, "locked"), bonnet, boot, objective);
                    dini_IntSet(file6, "IsTowed", 0);
                    dini_IntSet(file6, "TowBill", 0);
                    return 1;
                }
                if(money < TowBill[playerid])
                {
                    SendClientMessage(playerid, COLOR_RED, "[Server]: You don't have enough money!");
                }
            }
            if(ChosenSlot[playerid] == 3)
            {
                if(money >= TowBill[playerid])
                {
                    CarIsBroken[OwnedCar3[playerid]] = 0;
                    GivePlayerMoney2(playerid, -TowBill[playerid]);
                    format(string, sizeof(string), "%s3.ini", name);
                    format(file6, sizeof(file6), USER_CAR_FILE, string);
                    new vehmodel = dini_Int(file6, "Model");
                    new vehX = dini_Int(file6, "carX");
                    new vehY = dini_Int(file6, "carY");
                    new vehZ = dini_Int(file6, "carZ");
                    new vehA = dini_Int(file6, "carA");
                    new modification1 = dini_Int(file6, "Mod1");
                    new modification2 = dini_Int(file6, "Mod2");
                    new modification3 = dini_Int(file6, "Mod3");
                    new modification4 = dini_Int(file6, "Mod4");
                    new modification5 = dini_Int(file6, "Mod5");
                    new modification6 = dini_Int(file6, "Mod6");
                    new modification7 = dini_Int(file6, "Mod7");
                    new modification8 = dini_Int(file6, "Mod8");
                    new modification9 = dini_Int(file6, "Mod9");
                    new modification10 = dini_Int(file6, "Mod10");
                    new modification11 = dini_Int(file6, "Mod11");
                    new modification12 = dini_Int(file6, "Mod12");
                    new modification13 = dini_Int(file6, "Mod13");
                    new modification14 = dini_Int(file6, "Mod14");
                    new modification15 = dini_Int(file6, "Mod15");
                    new modification16 = dini_Int(file6, "Mod16");
                    new modification17 = dini_Int(file6, "Mod17");
                    new vehcol1 = dini_Int(file6, "color01");
                    new vehcol2 = dini_Int(file6, "color02");
                    OwnedCar3[playerid] = CreateVehicle(vehmodel, vehX, vehY, vehZ, vehA, vehcol1, vehcol2, -1);
                    SetVehicleNumberPlate(OwnedCar3[playerid], dini_Get(file6, "plate"));
                    ChangeVehiclePaintjob(OwnedCar3[playerid], dini_Int(file6, "paint"));
                    if(modification1 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification1); }
                    if(modification2 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification2); }
                    if(modification3 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification3); }
                    if(modification4 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification4); }
                    if(modification5 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification5); }
                    if(modification6 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification6); }
                    if(modification7 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification7); }
                    if(modification8 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification8); }
                    if(modification9 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification9); }
                    if(modification10 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification10); }
                    if(modification11 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification11); }
                    if(modification12 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification12); }
                    if(modification13 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification13); }
                    if(modification14 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification14); }
                    if(modification15 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification15); }
                    if(modification16 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification16); }
                    if(modification17 != 0){ AddVehicleComponent(OwnedCar3[playerid], modification17); }
                    new engine, lights, alarm, doors, bonnet, boot, objective;
                    GetVehicleParamsEx(OwnedCar3[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(OwnedCar3[playerid], dini_Int(file6, "engine"), lights, alarm, dini_Int(file6, "locked"), bonnet, boot, objective);
                    dini_IntSet(file6, "IsTowed", 0);
                    dini_IntSet(file6, "TowBill", 0);
                    return 1;
                }
                if(money < TowBill[playerid])
                {
                    SendClientMessage(playerid, COLOR_RED, "[Server]: You don't have enough money!");
                }
            }
        }
    }
This is the code that spawns them out of the garage, as you can see they're clearly labeled OwnerCar1[playerid] for ChosenSlot[playerid] = 1, OwnerCar2[playerid] for ChosenSlot[playerid] = 2, and OwnerCar3[playerid] for ChosenSlot[playerid] = 3! D: But as I stated above, they come out all mixed up, but once they're all out they are in order like they should be somehow, I mean it's not the worst thing but it's a bug that's "bugging me" haha... pun..

pawn Код:
new string[256];
new name[MAX_PLAYERS];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s1.ini", name);// OwnerCar1[playerid]
format(file6, sizeof(file6), USER_CAR_FILE, string);//OwnerCar1[playerid]'s file
Could it be because I'm using file6 on all of them, should I try using a different string name, maybe they're interfering somehow??

Let me know if you need more code or info! Any help is appreciated, wouldn't ask if I didn't really need it!

If no one can think of anything I guess I could just make it spawn them all 3 at the same time so it will get them in order
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)