Tuniranje i Cuvanje tuninga na autu !


Započeo c0x, Maj 10, 2019, 19:23:42 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

c0x

*

Problem(error/warning): Uradio sam sistem da se tunira auto i da se cuva tuning medjutim, nece da ga sacuva i da ga tunira..
Deo skripte:
Funkcije tuniraj i sacuvaj tuning!
public TunirajVozilo(vehid, v)
{
	if(VoziloInfo[v][vKomponenta1] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta1]);
	}
	if(VoziloInfo[v][vKomponenta2] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta2]);
	}
	if(VoziloInfo[v][vKomponenta3] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta3]);
	}
	if(VoziloInfo[v][vKomponenta4] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta4]);
	}
	if(VoziloInfo[v][vKomponenta5] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta5]);
	}
	if(VoziloInfo[v][vKomponenta6] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta6]);
	}
	if(VoziloInfo[v][vKomponenta7] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta7]);
	}
	if(VoziloInfo[v][vKomponenta8] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta8]);
	}
	if(VoziloInfo[v][vKomponenta9] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta9]);
	}
	if(VoziloInfo[v][vKomponenta10] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta10]);
	}
	if(VoziloInfo[v][vKomponenta11] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta11]);
	}
	if(VoziloInfo[v][vKomponenta12] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta12]);
	}
	if(VoziloInfo[v][vKomponenta13] > 0)
	{
	    AddVehicleComponent(vehid, VoziloInfo[v][vKomponenta13]);
	}
	if(VoziloInfo[v][vPaintJob] > 0)
	{
	    ChangeVehiclePaintjob(vehid, VoziloInfo[v][vPaintJob]-1);
	}
}

SacuvajTuning
public SacuvajTuning(vehid, v)
{
    new komponenta1 = GetVehicleComponentInSlot(vehid, CARMODTYPE_SPOILER);
	new komponenta2 = GetVehicleComponentInSlot(vehid, CARMODTYPE_HOOD);
	new komponenta3 = GetVehicleComponentInSlot(vehid, CARMODTYPE_ROOF);
	new komponenta4 = GetVehicleComponentInSlot(vehid, CARMODTYPE_SIDESKIRT);
	new komponenta5 = GetVehicleComponentInSlot(vehid, CARMODTYPE_LAMPS);
	new komponenta6 = GetVehicleComponentInSlot(vehid, CARMODTYPE_NITRO);
	new komponenta7 = GetVehicleComponentInSlot(vehid, CARMODTYPE_EXHAUST);
	new komponenta8 = GetVehicleComponentInSlot(vehid, CARMODTYPE_WHEELS);
	new komponenta9 = GetVehicleComponentInSlot(vehid, CARMODTYPE_HYDRAULICS);
	new komponenta10 = GetVehicleComponentInSlot(vehid, CARMODTYPE_FRONT_BUMPER);
	new komponenta11 = GetVehicleComponentInSlot(vehid, CARMODTYPE_REAR_BUMPER);
	new komponenta12 = GetVehicleComponentInSlot(vehid, CARMODTYPE_VENT_RIGHT);
	new komponenta13 = GetVehicleComponentInSlot(vehid, CARMODTYPE_VENT_LEFT);
	VoziloInfo[v][vKomponenta1] = komponenta1;
	VoziloInfo[v][vKomponenta2] = komponenta2;
	VoziloInfo[v][vKomponenta3] = komponenta3;
	VoziloInfo[v][vKomponenta4] = komponenta4;
	VoziloInfo[v][vKomponenta5] = komponenta5;
	VoziloInfo[v][vKomponenta6] = komponenta6;
	VoziloInfo[v][vKomponenta7] = komponenta7;
	VoziloInfo[v][vKomponenta8] = komponenta8;
	VoziloInfo[v][vKomponenta9] = komponenta9;
	VoziloInfo[v][vKomponenta10] = komponenta10;
	VoziloInfo[v][vKomponenta11] = komponenta11;
	VoziloInfo[v][vKomponenta12] = komponenta12;
	VoziloInfo[v][vKomponenta13] = komponenta13;
}

stock SacuvajVozilo(id)
{
    new vFile[80];
    format(vFile, sizeof(vFile), AUTO_FILE, id);
	new INI:File = INI_Open(vFile);
    INI_WriteInt(File,"Model", VoziloInfo[id][vModel]);
    INI_WriteFloat(File,"X", VoziloInfo[id][vPozX]);
    INI_WriteFloat(File,"Y", VoziloInfo[id][vPozY]);
    INI_WriteFloat(File,"Z", VoziloInfo[id][vPozZ]);
    INI_WriteFloat(File,"A", VoziloInfo[id][vPozA]);
    INI_WriteInt(File,"Boja1", VoziloInfo[id][vBoja1]);
    INI_WriteInt(File,"Boja2", VoziloInfo[id][vBoja2]);
    INI_WriteString(File,"Vlasnik", VoziloInfo[id][vVlasnik]);
    INI_WriteInt(File,"ImaVlasnika", VoziloInfo[id][vImaVlasnika]);
    INI_WriteInt(File,"ID", VoziloInfo[id][vID]);
	INI_WriteInt(File,"Zakljucan", VoziloInfo[id][vZakljucan]);
	INI_WriteInt(File,"Droga", VoziloInfo[id][vDroga]);
	INI_WriteInt(File,"Mats", VoziloInfo[id][vMats]);
	INI_WriteInt(File,"Oruzije", VoziloInfo[id][vOruzije]);
	INI_WriteInt(File,"Municija", VoziloInfo[id][vMunicija]);
	INI_WriteInt(File,"Radio", VoziloInfo[id][vRadio]);
	INI_WriteInt(File, "vPaintJob", VoziloInfo[id][vPaintJob]);
	INI_WriteInt(File, "vKomponenta1", VoziloInfo[id][vKomponenta1]);
	INI_WriteInt(File, "vKomponenta2", VoziloInfo[id][vKomponenta2]);
	INI_WriteInt(File, "vKomponenta3", VoziloInfo[id][vKomponenta3]);
	INI_WriteInt(File, "vKomponenta4", VoziloInfo[id][vKomponenta4]);
	INI_WriteInt(File, "vKomponenta5", VoziloInfo[id][vKomponenta5]);
	INI_WriteInt(File, "vKomponenta6", VoziloInfo[id][vKomponenta6]);
	INI_WriteInt(File, "vKomponenta7", VoziloInfo[id][vKomponenta7]);
	INI_WriteInt(File, "vKomponenta8", VoziloInfo[id][vKomponenta8]);
	INI_WriteInt(File, "vKomponenta9", VoziloInfo[id][vKomponenta9]);
	INI_WriteInt(File, "vKomponenta10", VoziloInfo[id][vKomponenta10]);
	INI_WriteInt(File, "vKomponenta11", VoziloInfo[id][vKomponenta11]);
	INI_WriteInt(File, "vKomponenta12", VoziloInfo[id][vKomponenta12]);
	INI_WriteInt(File, "vKomponenta13", VoziloInfo[id][vKomponenta13]);
	INI_Close(File);
	return 1;
}

    INI_Int("Model", VoziloInfo[id][vModel]);
    INI_Float("X", VoziloInfo[id][vPozX]);
    INI_Float("Y", VoziloInfo[id][vPozY]);
    INI_Float("Z", VoziloInfo[id][vPozZ]);
    INI_Float("A", VoziloInfo[id][vPozA]);
    INI_Int("Boja1", VoziloInfo[id][vBoja1]);
    INI_Int("Boja2", VoziloInfo[id][vBoja2]);
    INI_String("Vlasnik", VoziloInfo[id][vVlasnik],60);
    INI_Int("ImaVlasnika", VoziloInfo[id][vImaVlasnika]);
    INI_Int("ID", VoziloInfo[id][vID]);
	INI_Int("Zakljucan", VoziloInfo[id][vZakljucan]);
	INI_Int("Droga", VoziloInfo[id][vDroga]);
	INI_Int("Mats", VoziloInfo[id][vMats]);
	INI_Int("Oruzije", VoziloInfo[id][vOruzije]);
	INI_Int("Municija", VoziloInfo[id][vMunicija]);
	INI_Int("Radio", VoziloInfo[id][vRadio]);
	INI_Int( "vPaintJob", VoziloInfo[id][vPaintJob]);
	INI_Int( "vKomponenta1", VoziloInfo[id][vKomponenta1]);
	INI_Int( "vKomponenta2", VoziloInfo[id][vKomponenta2]);
	INI_Int( "vKomponenta3", VoziloInfo[id][vKomponenta3]);
	INI_Int( "vKomponenta4", VoziloInfo[id][vKomponenta4]);
	INI_Int( "vKomponenta5", VoziloInfo[id][vKomponenta5]);
	INI_Int( "vKomponenta6", VoziloInfo[id][vKomponenta6]);
	INI_Int( "vKomponenta7", VoziloInfo[id][vKomponenta7]);
	INI_Int( "vKomponenta8", VoziloInfo[id][vKomponenta8]);
	INI_Int( "vKomponenta9", VoziloInfo[id][vKomponenta9]);
	INI_Int( "vKomponenta10", VoziloInfo[id][vKomponenta10]);
	INI_Int( "vKomponenta11", VoziloInfo[id][vKomponenta11]);
	INI_Int( "vKomponenta12", VoziloInfo[id][vKomponenta12]);
	INI_Int( "vKomponenta13", VoziloInfo[id][vKomponenta13]);

Stavio sam kada ga parkiram da sacuva tuning!
new i = PlayerInfo[playerid][pPosedovanjeAuta];
case 3: 
			{
			    new Float:PozAS[4], Float:HP;
			    if(GetPlayerVehicleID(playerid) != VoziloInfo[i][vID]) return Error(playerid, "Niste u svom vozilu!");
			    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return Error(playerid, "Niste na mestu vozaca!");
			    if(IsPlayerInArea(playerid, 837.1461,-1328.1970, 802.9177,-1353.6825)) return Error(playerid, "Ne mozete parkirati auto u blizini spawna!");
				if(IsPlayerInArea(playerid, 1486.062, -1776.608, 1653.387, -1567.377)) return Error(playerid, "Ne mozete parkirati auto u blizini policije!");
				if(IsPlayerInArea(playerid, 1136.201, -1014.694, 1311.132, -856.7839)) return Error(playerid, "Ne mozete parkirati auto u blizini burga!");
				if(IsPlayerInArea(playerid, 1383.386, -1077.857, 1554.513, -947.582)) return Error(playerid, "Ne mozete parkirati auto u blizini banke!");
				GetVehicleHealth(GetPlayerVehicleID(playerid), HP);
				if(HP < 400.0) return Error(playerid, "Vozilo vam je previse osteceno, ne mozete ga parkirati!");
				GetVehiclePos(VoziloInfo[i][vID], PozAS[0], PozAS[1], PozAS[2]);
				GetVehicleZAngle(VoziloInfo[i][vID], PozAS[3]);
				VoziloInfo[i][vPozX] = PozAS[0]; VoziloInfo[i][vPozY] = PozAS[1]; VoziloInfo[i][vPozZ] = PozAS[2];
				VoziloInfo[i][vPozA] = PozAS[3]; DestroyVehicle(VoziloInfo[i][vID]);
				VoziloInfo[i][vID] = CreateVehicle(VoziloInfo[i][vModel],VoziloInfo[i][vPozX],VoziloInfo[i][vPozY],VoziloInfo[i][vPozZ],VoziloInfo[i][vPozA],VoziloInfo[i][vBoja1],VoziloInfo[i][vBoja2],30000);
				INFO(playerid, "Vozilo je uspesno parkirano!");
				SacuvajVozilo(i); SetVehicleToRespawn(VoziloInfo[i][vID]);
				SacuvajTuning(GetPlayerVehicleID(playerid), i);
			}

OnVehicleSpawn - Pretpostavljam da tu nesto ne valja..
public OnVehicleSpawn(vehicleid)
{
	for(new i; i < sizeof VoziloInfo; i++)
	{
	    if(vehicleid == VoziloInfo[i][vImaVlasnika]) TunirajVozilo(vehicleid, i);
	}
	return 1;
}

Pokusao sam i ovako kod parkiranja opet je isto..
new i = PlayerInfo[playerid][pPosedovanjeAuta];
new x = VoziloInfo[i][vImaVlasnika];
SacuvajTuning(GetPlayerVehicleID(playerid), x);
Ali opet nece
Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): [ code ]//[ /code ]
Slika/video ingame problema(obavezno ako je ingame problem): //
Poslednja Izmena: Maj 10, 2019, 19:26:28 POSLE PODNE od c0x

U OnVehicleSpawn imaš prob
VImaVlasnika je 1 ili 0 a to ti ne daje id vozila tako da
pogledaj u gamemodeinit kad ucitaje vozila i spawna koja je varijabla pored = CreateVehicle

69

c0x

*

Citat: youngdeal poslato Maj 10, 2019, 20:01:37 POSLE PODNE
U OnVehicleSpawn imaš prob
VImaVlasnika je 1 ili 0 a to ti ne daje id vozila tako da
pogledaj u gamemodeinit kad ucitaje vozila i spawna koja je varijabla pored = CreateVehicle
To je kad ucitava vozila..
for(new i = 0; i < sizeof(VoziloInfo); i++)
	{
		new vFile[50];
        format(vFile, sizeof(vFile), AUTO_FILE, i);
        if(fexist(vFile))
        {
            INI_ParseFile(vFile, "UcitajVozila", .bExtra = true, .extra = i);
            VoziloInfo[i][vID] = CreateVehicle(VoziloInfo[i][vModel],VoziloInfo[i][vPozX],VoziloInfo[i][vPozY],VoziloInfo[i][vPozZ],VoziloInfo[i][vPozA],VoziloInfo[i][vBoja1],VoziloInfo[i][vBoja2],30000);
		}
	}

public OnVehicleSpawn(vehicleid)
{
	for(new i; i < sizeof VoziloInfo; i++)
	{
	    if(vehicleid == VoziloInfo[i][vID]) TunirajVozilo(vehicleid, i);
	}
	return 1;
}

s tim da imas na umu public OnVehicleSpawn se poziva pri respawnu vozila to jest kad se respawna vozilo
stavi TunirajVozilo u ongamemodeinit  tj ovako

for(new i = 0; i < sizeof(VoziloInfo); i++)
	{
		new vFile[50];
        format(vFile, sizeof(vFile), AUTO_FILE, i);
        if(fexist(vFile))
        {
            INI_ParseFile(vFile, "UcitajVozila", .bExtra = true, .extra = i);
            VoziloInfo[i][vID] = CreateVehicle(VoziloInfo[i][vModel],VoziloInfo[i][vPozX],VoziloInfo[i][vPozY],VoziloInfo[i][vPozZ],VoziloInfo[i][vPozA],VoziloInfo[i][vBoja1],VoziloInfo[i][vBoja2],30000);
            TunirajVozilo(VoziloInfo[i][vID],i);
		}
	}

i stavi kad se destroya vozilo il sta da brise komponente te nakon respawna opet stavlja  - moj prijedlog
69

c0x

*