Jump to content
  • 0

Bug masini personale bhood HPQ123


Question

Salut, am gasit o problema la gamemde-ul bhood de HPQ123. Cand cineva isi cumpara o masina din dealership, uneori aceasta primeste random sistemele vip sau rainbow, totodata cand masina nu primeste aceste sisteme, in /v o sa spuna ca e ocupata chiar daca ea nu e ocupata iar playerul nu o poate despawna pentru ca ii spune ca este ocupata. Voi da cateva functii la care cred ca ar putea sa fie problema, daca nu, pun si gamemodeul sa va uitati in el daca doriti.

YCMD:buycar(playerid, params[], help) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", aspam[playerid]);
    if(PlayerInfo[playerid][pLevel] < 3) return SCM(playerid, COLOR_GREY, "Nu ai nivel 3!");
    if(InDealer[playerid] != 0) return 1;
    if(!PlayerToPoint(3,playerid,1487.0498,-2287.2930,13.7529)) return SCM(playerid, COLOR_GREY, "Nu esti la dealership.");
    if(TestingModel[playerid] == 1) return true;
    LoadDsVehs(playerid);
    if(PlayerInfo[playerid][pWantedLevel] > 0) return SCM(playerid, -1, "Ai wanted, nu poti folosi aceasta comanda!");
    TestingModel[playerid] = 0;
    DealerCarType[playerid] = 1;
    InDealer[playerid] = 1;
    TogglePlayerControllable(playerid, 0);
    SetPlayerVirtualWorld(playerid, playerid+1);
    SetPlayerInterior(playerid, 0);
    DealerID[playerid] = 1;
    DealerCarColor1[playerid] = 1;
    DealerCarColor2[playerid] = 1;
    DealerCar[playerid] = CreateVehicleEx(DSModels[DealerID[playerid]][dModel],1463.3318,-2299.0806,13.6845,281.2260,DealerCarColor1[playerid],DealerCarColor2[playerid], -1, 0);
    SetVehicleVirtualWorld(DealerCar[playerid],playerid+1);
    LinkVehicleToInterior(DealerCar[playerid], 0);
    PlayerTextDrawSetPreviewModel(playerid, DSTds[4], DSModels[DealerID[playerid]][dModel]);
    PlayerTextDrawShow(playerid, DSTds[4]);
    ShowDealershipTextdraws(playerid);
    SelectTextDraw(playerid, 0x15B864FF);
    ShowCamera(playerid);    
    return true;
}

stock ShowPlayerVehicle(playerid, bool: type) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", aspam[playerid]);
    new szTitle[2000], szDialog[2000], x = 0;
    if(Iter_Count(MyVehicle[playerid]) == 0) 
        return SCM(playerid, COLOR_LGREEN, "Eroare: Nu ai un vehicul personal!");
    
    format(szTitle, sizeof(szTitle), "Your Vehicles {E3DE31}%d/%d", Iter_Count(MyVehicle[playerid]), GetSlots(playerid));
    strcat(szDialog, "Vehicul\tStatus\tDespawn Time\tOthers details\n");
    foreach(MyVehicle[playerid], car) {
        format(szDialog, sizeof(szDialog), "%s%s\t%s\t%s\t%s\n", szDialog, aVehicleNames[CarInfo[car][cModel]-400], CarInfo[car][Spawned] != 0 ? IsVehicleOccupied(CarInfo[car][Spawned]) ? ("{FFFF00}[occupied]") : ("{26B309}[spawned]") : ("{FF0000}[despawned]"), CheckDespawnCar(car), TotalUp(car)); 
        PlayerInfo[playerid][pCarKey][x] = car;
        x++;
    }
    ShowPlayerDialog(playerid, type ? DIALOG_STICKET : DIALOG_GARAGE, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog, "Ok", "Exit");
    return true;
}

B-HOOD.pwn

Link to post
Share on other sites

Recommended Posts

  • 0

Tot ce trebuia sa faci era sa setezi valoriile de la rainbow si vip pe 0

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][i] = 0;
	CarInfo[idd][cVip] = 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][cRainBow] = 0;
	CarInfo[idd][cStage] = 0; CarInfo[idd][cText] = 0;
	
	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, "", "");	

	CarInfo[idd][cMaxSpeed] = GetVehicleMaxSpeed(CarInfo[idd][cModel]-400);

	if(legendary == 1) {
	    CarInfo[idd][cLegendary] = 1;
	    gQuery[0] = EOS;
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Legendary`='%d',`MaxSpeed`='300'  WHERE ID=%d", CarInfo[idd][cLegendary], CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(stage > 0) {
		gQuery[0] = EOS;
    	CarInfo[idd][cStage] = stage;
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Stage`='%d' WHERE ID=%d", stage, CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(rainbow == 1) {
		gQuery[0] = EOS;
	    CarInfo[idd][cRainBow] = true;
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `RainBow`='%d' WHERE ID=%d", CarInfo[idd][cRainBow], CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(vip == 1) {
		gQuery[0] = EOS;
	    format(CarInfo[idd][cText], 32, GetName(playerid));
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Text`='%s' WHERE ID=%d", GetName(playerid), CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(MyVehicleSpawn[playerid] != 5) SpawnPlayerCar(idd);
	return true;
}

modifica functia asta cu functia ta din gamemode

Link to post
Share on other sites
  • 0
Acum 7 ore, hanako a spus:

Tot ce trebuia sa faci era sa setezi valoriile de la rainbow si vip pe 0

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][i] = 0;
	CarInfo[idd][cVip] = 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][cRainBow] = 0;
	CarInfo[idd][cStage] = 0; CarInfo[idd][cText] = 0;
	
	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, "", "");	

	CarInfo[idd][cMaxSpeed] = GetVehicleMaxSpeed(CarInfo[idd][cModel]-400);

	if(legendary == 1) {
	    CarInfo[idd][cLegendary] = 1;
	    gQuery[0] = EOS;
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Legendary`='%d',`MaxSpeed`='300'  WHERE ID=%d", CarInfo[idd][cLegendary], CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(stage > 0) {
		gQuery[0] = EOS;
    	CarInfo[idd][cStage] = stage;
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Stage`='%d' WHERE ID=%d", stage, CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(rainbow == 1) {
		gQuery[0] = EOS;
	    CarInfo[idd][cRainBow] = true;
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `RainBow`='%d' WHERE ID=%d", CarInfo[idd][cRainBow], CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(vip == 1) {
		gQuery[0] = EOS;
	    format(CarInfo[idd][cText], 32, GetName(playerid));
		mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Text`='%s' WHERE ID=%d", GetName(playerid), CarInfo[idd][cID]);
		mysql_tquery(SQL, gQuery, "", "");
	}
	if(MyVehicleSpawn[playerid] != 5) SpawnPlayerCar(idd);
	return true;
}

modifica functia asta cu functia ta din gamemode

Am pus si tot asa face, nu e tot timpul de aia zis ca e ciudat, uneori nu pune sistemele alea pe masina.

Link to post
Share on other sites
  • 0

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][i] = 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, "", "");    

    CarInfo[idd][cMaxSpeed] = GetVehicleMaxSpeed(CarInfo[idd][cModel]-400);

    if(legendary == 1) {
        CarInfo[idd][cLegendary] = 1;
        gQuery[0] = EOS;
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Legendary`='%d' WHERE ID=%d", legendary, CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(stage > 0) {
        gQuery[0] = EOS;
        CarInfo[idd][cStage] = stage;
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Stage`='%d' WHERE ID=%d", stage, CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(rainbow == 1) {
        gQuery[0] = EOS;
        CarInfo[idd][cRainBow] = true;
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `RainBow`='%d' WHERE ID=%d", CarInfo[idd][cRainBow], CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(vip == 1) {
        gQuery[0] = EOS;
        format(CarInfo[idd][cText], 32, GetName(playerid));
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Text`='%s' WHERE ID=%d", GetName(playerid), CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(MyVehicleSpawn[playerid] != 5) SpawnPlayerCar(idd);
    return true;
}

Link to post
Share on other sites
  • 0

Uneori ii apare pe masina sistemul VIP si raindow, iar alte ori cand cumpara masina chiar daca nu e nimeni in ea ii spune ca e occupied in /v si nu o poate despawna

Link to post
Share on other sites
  • 0

InsertVehicle(playerid, modelid, vip, rainbow, legendary, stage, temporar) 

 

Cand apelezi functia trebuie sa ai vip & rainbow pe 0, la incarcare vehiculelor personale, trebuie sa ai valoarea setata din baza de date, daca e pe 0/1 la vip/rainbow

Functia de "ocupat" in vehicul trebuie sa fie ceva de genul acesta:

forward IsVehicleOccupied(vehicleid);
public IsVehicleOccupied(vehicleid)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
		if(IsPlayerInVehicle(i, vehicleid)) return 1;
    }
    return 0;                  
}

Functia trebuie apelata mereu la /v daca ai in meniu statusul de "ocupat" sau nu

Link to post
Share on other sites
  • 0
Posted (edited)
Acum 1 oră, iSkull a spus:

InsertVehicle(playerid, modelid, vip, rainbow, legendary, stage, temporar) 

 

Cand apelezi functia trebuie sa ai vip & rainbow pe 0, la incarcare vehiculelor personale, trebuie sa ai valoarea setata din baza de date, daca e pe 0/1 la vip/rainbow

Functia de "ocupat" in vehicul trebuie sa fie ceva de genul acesta:


forward IsVehicleOccupied(vehicleid);
public IsVehicleOccupied(vehicleid)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
		if(IsPlayerInVehicle(i, vehicleid)) return 1;
    }
    return 0;                  
}

Functia trebuie apelata mereu la /v daca ai in meniu statusul de "ocupat" sau nu

function IsVehicleOccupied(vehicleid) return VehicleOccupied[vehicleid] != 0 ? (true) : (false);

stock ShowPlayerVehicle(playerid, bool: type) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", aspam[playerid]);
    new szTitle[2000], szDialog[2000], x = 0;
    if(Iter_Count(MyVehicle[playerid]) == 0) 
        return SCM(playerid, COLOR_LGREEN, "Eroare: Nu ai un vehicul personal!");
    
    format(szTitle, sizeof(szTitle), "Your Vehicles {E3DE31}%d/%d", Iter_Count(MyVehicle[playerid]), GetSlots(playerid));
    strcat(szDialog, "Vehicul\tStatus\tDespawn Time\tOthers details\n");
    foreach(MyVehicle[playerid], car) {
        format(szDialog, sizeof(szDialog), "%s%s\t%s\t%s\t%s\n", szDialog, aVehicleNames[CarInfo[car][cModel]-400], CarInfo[car][Spawned] != 0 ? IsVehicleOccupied(CarInfo[car][Spawned]) ? ("{FFFF00}[occupied]") : ("{26B309}[spawned]") : ("{FF0000}[despawned]"), CheckDespawnCar(car), TotalUp(car)); 
        PlayerInfo[playerid][pCarKey][x] = car;
        x++;
    }
    ShowPlayerDialog(playerid, type ? DIALOG_STICKET : DIALOG_GARAGE, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog, "Ok", "Exit");
    return true;
}

YCMD:buycar(playerid, params[], help) {
    if(aspam[playerid] > 0) return SCMEx(playerid, COLOR_LIGHTRED, "[Command Anti-Spam] {FFFFFF}Asteapta %d secunde.", aspam[playerid]);
    if(PlayerInfo[playerid][pLevel] < 3) return SCM(playerid, COLOR_GREY, "Nu ai nivel 3!");
    if(InDealer[playerid] != 0) return 1;
    if(!PlayerToPoint(3,playerid,1487.0498,-2287.2930,13.7529)) return SCM(playerid, COLOR_GREY, "Nu esti la dealership.");
    if(TestingModel[playerid] == 1) return true;
    //test
    SCM(playerid, COLOR_GREY, "Erorile aparute in urma cumpararii unei masini se pot rezolva printr-un relog.");
    SCM(playerid, COLOR_GREY, "Dupa ce parcati masina prima data dupa ce o cumparati, trebuie sa dati relog.");
    //test
    LoadDsVehs(playerid);
    if(PlayerInfo[playerid][pWantedLevel] > 0) return SCM(playerid, -1, "Ai wanted, nu poti folosi aceasta comanda!");
    TestingModel[playerid] = 0;
    DealerCarType[playerid] = 1;
    InDealer[playerid] = 1;
    TogglePlayerControllable(playerid, 0);
    SetPlayerVirtualWorld(playerid, playerid+1);
    SetPlayerInterior(playerid, 0);
    DealerID[playerid] = 1;
    DealerCarColor1[playerid] = 1;
    DealerCarColor2[playerid] = 1;
    DealerCar[playerid] = CreateVehicleEx(DSModels[DealerID[playerid]][dModel],1463.3318,-2299.0806,13.6845,281.2260,DealerCarColor1[playerid],DealerCarColor2[playerid], -1, 0);
    SetVehicleVirtualWorld(DealerCar[playerid],playerid+1);
    LinkVehicleToInterior(DealerCar[playerid], 0);
    PlayerTextDrawSetPreviewModel(playerid, DSTds[4], DSModels[DealerID[playerid]][dModel]);
    PlayerTextDrawShow(playerid, DSTds[4]);
    ShowDealershipTextdraws(playerid);
    SelectTextDraw(playerid, 0x15B864FF);
    ShowCamera(playerid);    
    return true;
}

function GiveVehicle(playerid, modelid, vip, rainbow, legendary, stage, temporar) {
    gQuery[0] = EOS;
    mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO cars (Model) VALUES (%d)", modelid);
    mysql_tquery(SQL, gQuery, "InsertVehicle", "iiiiiii", playerid, modelid, vip, rainbow, legendary, stage, temporar);
    return true;
}
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][i] = 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, "", "");    

    CarInfo[idd][cMaxSpeed] = GetVehicleMaxSpeed(CarInfo[idd][cModel]-400);

    if(legendary == 1) {
        CarInfo[idd][cLegendary] = 1;
        gQuery[0] = EOS;
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Legendary`='%d' WHERE ID=%d", legendary, CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(stage > 0) {
        gQuery[0] = EOS;
        CarInfo[idd][cStage] = stage;
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Stage`='%d' WHERE ID=%d", stage, CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(rainbow == 1) {
        gQuery[0] = EOS;
        CarInfo[idd][cRainBow] = true;
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `RainBow`='%d' WHERE ID=%d", CarInfo[idd][cRainBow], CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(vip == 1) {
        gQuery[0] = EOS;
        format(CarInfo[idd][cText], 32, GetName(playerid));
        mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE cars SET `Text`='%s' WHERE ID=%d", GetName(playerid), CarInfo[idd][cID]);
        mysql_tquery(SQL, gQuery, "", "");
    }
    if(MyVehicleSpawn[playerid] != 5) SpawnPlayerCar(idd);
    return true;
}

Nu imi dau seama sincer, am dat aici toate aparitiile functiei insertvehicle.

EDIT: daca dau restart la server nu o sa mai apara eronat ca masina respectiva are acele sisteme. Dar as vrea sa nu fiu nevoit sa dau restart :D

Edited by TheGodfather
Link to post
Share on other sites
  • 0

Ai spus ca acest lucru se intampla atunci cand cineva cumpara un vehicul din dealership.
Vezi ca nu functia InsertVehicle se apeleaza atunci cand cumperi din dealership, se apeleaza functia InsertDsCars.
In functia InsertDsCars trebuie sa adaugi ce lipseste, de exemplu: CarInfo[idd][cVip] = 0, CarInfo[idd][cNeon] = 0;

Link to post
Share on other sites
  • 0
Acum 22 minute, Akan a spus:

Ai spus ca acest lucru se intampla atunci cand cineva cumpara un vehicul din dealership.
Vezi ca nu functia InsertVehicle se apeleaza atunci cand cumperi din dealership, se apeleaza functia InsertDsCars.
In functia InsertDsCars trebuie sa adaugi ce lipseste, de exemplu: CarInfo[idd][cVip] = 0, CarInfo[idd][cNeon] = 0;

Exista deja aceste lucruri in acea functie si tot asa face.

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][i] = 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]);
    //
    Update(playerid, pCashx);
    //

    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;
}

Link to post
Share on other sites
  • 0
Acum 45 minute, iSkull a spus:

În loc de funcția ta de occupied o poți înlocui cu a mea

Ok, o sa incerc. Legat de vip si rainbow care apar random cand playerii cumpara masini ai ceva idei?

Link to post
Share on other sites
  • 0
Acum 10 ore, TheGodfather a spus:

Ok, o sa incerc. Legat de vip si rainbow care apar random cand playerii cumpara masini ai ceva idei?

In ultimul post am vazut ca ai pus acel //test e ok, dar se intampla dupa restart sau?

Link to post
Share on other sites
  • 0
La 27.05.2021 la 10:29, iSkull a spus:

In ultimul post am vazut ca ai pus acel //test e ok, dar se intampla dupa restart sau?

Se intampla doar dupa ce playerul cumpara masina.

Link to post
Share on other sites
  • 0
La 27.05.2021 la 14:02, hanako a spus:

trimite functia savecar aici

stock saveCar(idd) {
    if(idd == 0) return true;
    new query[1000];
    mysql_format(SQL, query, sizeof(query),
        "UPDATE cars SET Model='%d', Locationx='%f', Locationy='%f', Locationz='%f', Angle='%f', ColorOne='%d', ColorTwo='%d', Owner='%s', Value='%d', License='%s', Userid='%d', `Virtual`='%d'  WHERE ID=%d",
    CarInfo[idd][cModel], CarInfo[idd][cLocationx], CarInfo[idd][cLocationy], CarInfo[idd][cLocationz], CarInfo[idd][cAngle], CarInfo[idd][cColorOne], CarInfo[idd][cColorTwo], CarInfo[idd][cOwner], CarInfo[idd][cValue],
    CarInfo[idd][cLicense], CarInfo[idd][Userid], CarInfo[idd][cVirtual], CarInfo[idd][cID]);
    mysql_tquery(SQL, query, "", "");
    return true;
}

Link to post
Share on other sites
  • 0
Acum 13 minute, TheGodfather a spus:

stock saveCar(idd) {
    if(idd == 0) return true;
    new query[1000];
    mysql_format(SQL, query, sizeof(query),
        "UPDATE cars SET Model='%d', Locationx='%f', Locationy='%f', Locationz='%f', Angle='%f', ColorOne='%d', ColorTwo='%d', Owner='%s', Value='%d', License='%s', Userid='%d', `Virtual`='%d'  WHERE ID=%d",
    CarInfo[idd][cModel], CarInfo[idd][cLocationx], CarInfo[idd][cLocationy], CarInfo[idd][cLocationz], CarInfo[idd][cAngle], CarInfo[idd][cColorOne], CarInfo[idd][cColorTwo], CarInfo[idd][cOwner], CarInfo[idd][cValue],
    CarInfo[idd][cLicense], CarInfo[idd][Userid], CarInfo[idd][cVirtual], CarInfo[idd][cID]);
    mysql_tquery(SQL, query, "", "");
    return true;
}

Functia asta nu cred ca are legatura cu acest bug pentru ca doar sistemele vip si rainbow apar random, restul se salveaza ok, precum stage sau neon. Niciunul din acestea nu apare in functia saveCar.

Link to post
Share on other sites
  • 0
Acum 8 ore, iSkull a spus:

Arata SpawnPlayerCar, acolo in functie e ok

stock SpawnPlayerCar(dbid) {
    new string[180];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    if(dbid == -1) return true;
    if(CarInfo[dbid][Confiscated] == 1) return true;
    CarInfo[dbid][Spawned] = CreateVehicleEx(CarInfo[dbid][cModel],CarInfo[dbid][cLocationx],CarInfo[dbid][cLocationy],CarInfo[dbid][cLocationz],CarInfo[dbid][cAngle],CarInfo[dbid][cColorOne],CarInfo[dbid][cColorTwo], -1, 0);
    SetVehicleVirtualWorld(CarInfo[dbid][Spawned], CarInfo[dbid][cVirtual]);
    VehicleOwned[CarInfo[dbid][Spawned]] = CarInfo[dbid][Spawned];
    VehicleSQL[CarInfo[dbid][Spawned]] = dbid;

    SetVehicleHealth(CarInfo[dbid][Spawned], CarInfo[dbid][cVip] ? 2000 : 1000);

    Iter_Add(PersonalVSpawned, dbid);
    MyVehicleSpawn[CarInfo[dbid][cOnline]] ++;
    attach_vip_text(dbid);
    AttachNeon(dbid);

    Gas[CarInfo[dbid][Spawned]] = CarInfo[dbid][cFuel];
    GetVehicleParamsEx(CarInfo[dbid][Spawned],engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(CarInfo[dbid][Spawned],0,lights,alarm,CarInfo[dbid][cLock],bonnet,boot,objective);
    CarInfo[dbid][cTime] = gettime()+600;
    SetTunning(dbid);
    mysql_format(SQL, string, sizeof(string), "UPDATE cars SET Spawned='%d' WHERE ID=%d", CarInfo[dbid][Spawned], CarInfo[dbid][cID]);
    mysql_tquery(SQL, string, "", "");
    return true;
}

Link to post
Share on other sites
  • 0

stock SpawnPlayerCar(dbid) {
    new string[180];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    if(dbid == -1) return true;
    if(CarInfo[dbid][Confiscated] == 1) return true;
    CarInfo[dbid][Spawned] = CreateVehicleEx(CarInfo[dbid][cModel],CarInfo[dbid][cLocationx],CarInfo[dbid][cLocationy],CarInfo[dbid][cLocationz],CarInfo[dbid][cAngle],CarInfo[dbid][cColorOne],CarInfo[dbid][cColorTwo], -1, 0);
    SetVehicleVirtualWorld(CarInfo[dbid][Spawned], CarInfo[dbid][cVirtual]);
    VehicleOwned[CarInfo[dbid][Spawned]] = CarInfo[dbid][Spawned];
    VehicleSQL[CarInfo[dbid][Spawned]] = dbid;

    SetVehicleHealth(CarInfo[dbid][Spawned], CarInfo[dbid][cVip] ? 2000 : 1000);

    Iter_Add(PersonalVSpawned, dbid);
    MyVehicleSpawn[CarInfo[dbid][cOnline]] ++;
    attach_vip_text(dbid);
    AttachNeon(dbid);

    if(!CarInfo[dbid][cRainBow]) return true;
    else {Iter_Add(Rainbows[1], playerid);}

    Gas[CarInfo[dbid][Spawned]] = CarInfo[dbid][cFuel];
    GetVehicleParamsEx(CarInfo[dbid][Spawned],engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(CarInfo[dbid][Spawned],0,lights,alarm,CarInfo[dbid][cLock],bonnet,boot,objective);
    CarInfo[dbid][cTime] = gettime()+600;
    SetTunning(dbid);
    mysql_format(SQL, string, sizeof(string), "UPDATE cars SET Spawned='%d' WHERE ID=%d", CarInfo[dbid][Spawned], CarInfo[dbid][cID]);
    mysql_tquery(SQL, string, "", "");
    return true;
}

asta ar trebui sa-ti rezolve problema la rainbow

Link to post
Share on other sites
  • 0
La 30.05.2021 la 8:54, hanako a spus:

stock SpawnPlayerCar(dbid) {
    new string[180];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    if(dbid == -1) return true;
    if(CarInfo[dbid][Confiscated] == 1) return true;
    CarInfo[dbid][Spawned] = CreateVehicleEx(CarInfo[dbid][cModel],CarInfo[dbid][cLocationx],CarInfo[dbid][cLocationy],CarInfo[dbid][cLocationz],CarInfo[dbid][cAngle],CarInfo[dbid][cColorOne],CarInfo[dbid][cColorTwo], -1, 0);
    SetVehicleVirtualWorld(CarInfo[dbid][Spawned], CarInfo[dbid][cVirtual]);
    VehicleOwned[CarInfo[dbid][Spawned]] = CarInfo[dbid][Spawned];
    VehicleSQL[CarInfo[dbid][Spawned]] = dbid;

    SetVehicleHealth(CarInfo[dbid][Spawned], CarInfo[dbid][cVip] ? 2000 : 1000);

    Iter_Add(PersonalVSpawned, dbid);
    MyVehicleSpawn[CarInfo[dbid][cOnline]] ++;
    attach_vip_text(dbid);
    AttachNeon(dbid);

    if(!CarInfo[dbid][cRainBow]) return true;
    else {Iter_Add(Rainbows[1], playerid);}

    Gas[CarInfo[dbid][Spawned]] = CarInfo[dbid][cFuel];
    GetVehicleParamsEx(CarInfo[dbid][Spawned],engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(CarInfo[dbid][Spawned],0,lights,alarm,CarInfo[dbid][cLock],bonnet,boot,objective);
    CarInfo[dbid][cTime] = gettime()+600;
    SetTunning(dbid);
    mysql_format(SQL, string, sizeof(string), "UPDATE cars SET Spawned='%d' WHERE ID=%d", CarInfo[dbid][Spawned], CarInfo[dbid][cID]);
    mysql_tquery(SQL, string, "", "");
    return true;
}

asta ar trebui sa-ti rezolve problema la rainbow

Legat de VIP? Tocmai azi a zis un player ca a cumparat un nrg din ds si i-a dat VIP pe vehicul

Link to post
Share on other sites
  • 0

Sa fie cumva problema de la functia asta?

stock TotalUp(carid) {
    new up, stage[200], neon[200];
    gString[0] = EOS;

    if(CarInfo[carid][cLegendary] == 1) up ++;
    if(CarInfo[carid][cVip] != 0) up ++;
    else if(strlen(CarInfo[carid][cText]) > 3) up ++;
    if(CarInfo[carid][cNeon]) up++;
    if(CarInfo[carid][cRainBow]) up ++;
    if(CarInfo[carid][cStage] > 0) up ++;
    
    format(stage, sizeof(stage), "{509AE4}[S: %d/3] ", CarInfo[carid][cStage]);
    if(CarInfo[carid][cNeon]) format(neon, sizeof(neon), "{%s}[N] ", NeonColor[CarInfo[carid][cNeon]-1]);

    format(gString, 200, "%s%s%s%s%s", CarInfo[carid][cLegendary] ? ("{F28644}[P] ") : (""), CarInfo[carid][cVip] ? ("{FFE802}[VP] ") : strlen(CarInfo[carid][cText]) > 3 ? ("{E3DE31}[V] ") : (""), CarInfo[carid][cRainBow] ? ("{791DD5}[R] ") : (""), CarInfo[carid][cStage] ? stage : (""), CarInfo[carid][cNeon] ? neon : (""));
    return up != 0 ? gString : ("none");
}

Link to post
Share on other sites

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.