Jump to content
  • 0

Bug dealership


TheGodfather

Question

Daca cumpar o masina, ii pun vip+, dupa o vand si cumpar orice alta masina, aceasta din urma o sa primeasca vip, si nu ar trebui. Las mai jos locurile in care pot sa fie probleme. In baza de date se updateaza corect toate valorile

------------------------------------------

function InsertVehicle(playerid, modelid, vip, rainbow, legendary, stage, temporar) {
    new idd = Iter_Free(PersonalVehicles);
    Iter_Add(MyVehicle[playerid], idd);
    Iter_Add(PersonalVehicles, idd);
    CarInfo[idd][Userid] = PlayerInfo[playerid][pSQLID];
    CarInfo[idd][cID] = cache_insert_id();
    CarInfo[idd][cModel] = modelid;
    CarInfo[idd][cValue] = 1;
    CarInfo[idd][cOnline] = playerid;

    if(CarInfo[idd][cModel] == 487 || CarInfo[idd][cModel] == 447) {
        new randspawn = random(sizeof(DealerCarPos1));
        CarInfo[idd][cLocationx] = DealerCarPos1[randspawn][0];    CarInfo[idd][cLocationy] = DealerCarPos1[randspawn][1];    CarInfo[idd][cLocationz] = DealerCarPos1[randspawn][2];
        CarInfo[idd][cAngle] = DealerCarPos1[randspawn][3];
    }
    else if(CarInfo[idd][cModel] == 519) {
        new randspawn = random(sizeof(DealerCarPos2));
        CarInfo[idd][cLocationx] = DealerCarPos2[randspawn][0];    CarInfo[idd][cLocationy] = DealerCarPos2[randspawn][1];    CarInfo[idd][cLocationz] = DealerCarPos2[randspawn][2];
        CarInfo[idd][cAngle] = DealerCarPos2[randspawn][3];
    }
    else {
        new randspawn = random(sizeof(DealerCarPos));
        CarInfo[idd][cLocationx] = DealerCarPos[randspawn][0];    CarInfo[idd][cLocationy] = DealerCarPos[randspawn][1];    CarInfo[idd][cLocationz] = DealerCarPos[randspawn][2];
        CarInfo[idd][cAngle] = DealerCarPos[randspawn][3];
    }
    CarInfo[idd][cColorOne] = 1;    CarInfo[idd][cColorTwo] = 1;
    strmid(CarInfo[idd][cOwner], PlayerInfo[playerid][pUsername], 0, strlen(PlayerInfo[playerid][pUsername]), 255);
    strmid(CarInfo[idd][cLicense], "NewCar", 0, 6, 255);
    CarInfo[idd][cAlarm] = 0;    CarInfo[idd][cLock] = 0;    CarInfo[idd][cRainBow] = false; CarInfo[idd][cLegendary] = 0;    CarInfo[idd][cStage] = 0;
    for(new i = 0; i < 14; i++) CarInfo[idd][cMod] = 0;
    CarInfo[idd][cVip] = 0; CarInfo[idd][cNeon] = 0; CarInfo[idd][cFuel] = 100;
    CarInfo[idd][paintjob] = 3;    CarInfo[idd][KM] = 0;
    CarInfo[idd][cPoints] = 5;  CarInfo[idd][cTax] = 3000;  CarInfo[idd][cTime] = gettime()+600;
    
    CarInfo[idd][cPoints] = 5; CarInfo[idd][cTax] = 50;
    saveCar(idd);
    gQuery[0] = EOS;
    mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `MaxSpeed`='%d' WHERE ID=%d", GetVehicleMaxSpeed(CarInfo[idd][cModel]-400), CarInfo[idd][cID]);
    mysql_tquery(SQL, gQuery, "", "");    

-------------------------------------------------

function InsertDsCars(playerid, modelid) {

    new idd = Iter_Free(PersonalVehicles);
    Iter_Add(MyVehicle[playerid], idd);
    Iter_Add(PersonalVehicles, idd);
    gQuery[0] = EOS;

    CP[playerid] = 53;
    CarInfo[idd][Userid] = PlayerInfo[playerid][pSQLID];
    CarInfo[idd][cID] = cache_insert_id();
    CarInfo[idd][cModel] = modelid;
    new randspawn = random(34);
    CarInfo[idd][cLocationx] = DealerCarPos[randspawn][0];    
    CarInfo[idd][cLocationy] = DealerCarPos[randspawn][1];    
    CarInfo[idd][cLocationz] = DealerCarPos[randspawn][2];
    CarInfo[idd][cAngle] = DealerCarPos[randspawn][3];
    CarInfo[idd][cOnline] = playerid;
    //test
    CarInfo[idd][cVip] = 0;
    CarInfo[idd][cNeon] = 0;
    //test
    mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET MaxSpeed='%d' WHERE ID=%d", GetVehicleMaxSpeed(CarInfo[idd][cModel]-400), CarInfo[idd][cID]);
    mysql_tquery(SQL, gQuery, "", "");
    CarInfo[idd][cMaxSpeed] = GetVehicleMaxSpeed(CarInfo[idd][cModel]);


    CarInfo[idd][cColorOne] = DealerCarColor1[playerid];    
    CarInfo[idd][cColorTwo] = DealerCarColor2[playerid];
    strmid(CarInfo[idd][cOwner], PlayerInfo[playerid][pUsername], 0, strlen(PlayerInfo[playerid][pUsername]), 255);
    CarInfo[idd][cValue] = DSModels[SelectedCar[playerid][DealerID[playerid]]][dPrice];
    strmid(CarInfo[idd][cLicense], "NewCar", 0, 6, 255);
    CarInfo[idd][cAlarm] = 0;    CarInfo[idd][cLock] = 0;    CarInfo[idd][cRainBow] = false; CarInfo[idd][cLegendary] = 0;    CarInfo[idd][cStage] = 0;
    for(new i = 0; i < 14; i++) CarInfo[idd][cMod] = 0;
    CarInfo[idd][paintjob] = 3;    CarInfo[idd][KM] = 0;       CarInfo[idd][cFuel] = 100;
    CarInfo[idd][cPoints] = 5;  CarInfo[idd][cTax] = 3000;
    saveCar(idd);

    if(MyVehicleSpawn[playerid] != 5) SpawnPlayerCar(idd);
    DestroyVehicle(DealerCar[playerid]);
    TogglePlayerControllable(playerid, 1);
    SetCameraBehindPlayer(playerid);
    SetPlayerVirtualWorld(playerid,0);
    SetPlayerPosEx(false, playerid, 1487.0498,-2287.2930,13.7529);
    SetPlayerInterior(playerid, 0);
    new LastMoney[40];
    format(LastMoney, 40, GetCashStr(playerid));
    GivePlayerCash(playerid, 0, DSModels[SelectedCar[playerid][DealerID[playerid]]][dPrice]);

    gString[0] = EOS;
    format(gString, sizeof(gString), "Felicitari! Ai cumparat un %s pentru %s$.",aVehicleNames[modelid-400],FormatNumber(CarInfo[idd][cValue]));
    SCM(playerid, COLOR_MONEY, gString);
    format(gString, sizeof(gString), "%s si-a cumparat un %s[%d], (last money: $%s / new money: $%s)", GetName(playerid), aVehicleNames[modelid-400], idd, LastMoney, GetCashStr(playerid));
    SendAdminMessage(COLOR_YELLOW, gString, 1); 
    InsertLog(playerid, gString, LOG_CAR);    
    finishAchievement(playerid, 1);    
    return true;
}

Edited by TheGodfather
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.