Car problem
#1

Hy everyone,in my car system i put a function,when a player disconnect from server, his personal car(s) just destroy and when they connect back,the car reapper(because for 400+ cars it makes lag ...so..)
The car destroyes fine when a player disconnect but the problem si with creating the car when they came back.

at OnPlayerConnect i putt this:
Код:
LoadCar();
    new carkey = PlayerInfo[playerid][pPcarkey];
    if(PlayerInfo[playerid][pPcarkey] > -1)
    {
		AddStaticVehicleEx(CarInfo[carkey][cModel],CarInfo[carkey][cLocationx],CarInfo[carkey][cLocationy],CarInfo[carkey][cLocationz]+1.0,CarInfo[carkey][cAngle],CarInfo[carkey][cColorOne],CarInfo[carkey][cColorTwo],60000);
		LoadComponents(carkey);
    }
This is just for personal car 1,i do the same for 2 and 3 but i did not post the rest here.

And at OnPlayerDisconnect i put:
Код:
if(PlayerInfo[playerid][pPcarkey] != -1)
	{
	    DestroyVehicle(carkey);
	}
	if(PlayerInfo[playerid][pPcarkey2] != -1)
	{
	    DestroyVehicle(carkey2);
	}
	if(PlayerInfo[playerid][pPcarkey3] != -1)
	{
	    DestroyVehicle(carkey3);
	}
SO,what is the problem guys?
Reply
#2

Is the information required to re-create the vehicle saved anywhere?
Reply
#3

sorry, but not really understand what did u want to say,can u repeat please?
Reply
#4

pawn Код:
AddStaticVehicleEx(CarInfo[carkey][cModel],CarInfo[carkey][cLocationx],CarInfo[carkey][cLocationy],CarInfo[carkey][cLocationz]+1.0,CarInfo[carkey][cAngle],CarInfo[carkey][cColorOne],CarInfo[carkey][cColorTwo],60000);
Are these values saved anywhere?
Reply
#5

yeah, in this.
Quote:

public LoadCar()
{
new arrCoords[33][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][cValue] = strval(arrCoords[9]);
CarInfo[idx][cOwned] = strval(arrCoords[10]);
CarInfo[idx][mod1] = strval(arrCoords[11]);
CarInfo[idx][mod2] = strval(arrCoords[12]);
CarInfo[idx][mod3] = strval(arrCoords[13]);
CarInfo[idx][mod4] = strval(arrCoords[14]);
CarInfo[idx][mod5] = strval(arrCoords[15]);
CarInfo[idx][mod6] = strval(arrCoords[16]);
CarInfo[idx][mod7] = strval(arrCoords[17]);
CarInfo[idx][mod8] = strval(arrCoords[18]);
CarInfo[idx][mod9] = strval(arrCoords[19]);
CarInfo[idx][mod10] = strval(arrCoords[20]);
CarInfo[idx][mod11] = strval(arrCoords[21]);
CarInfo[idx][mod12] = strval(arrCoords[22]);
CarInfo[idx][mod13] = strval(arrCoords[23]);
CarInfo[idx][mod14] = strval(arrCoords[24]);
CarInfo[idx][mod15] = strval(arrCoords[25]);
CarInfo[idx][mod16] = strval(arrCoords[26]);
CarInfo[idx][mod17] = strval(arrCoords[27]);
CarInfo[idx][paintjob] = strval(arrCoords[28]);
CarInfo[idx][cLicense] = strval(arrCoords[29]);
CarInfo[idx][cTimed] = strval(arrCoords[30]);
CarInfo[idx][cLicense2] = strval(arrCoords[31]);
LoadComponents(idx);
idx++;
}
}
return 1;
}

What is wrong there? if i put to ongamemodeinit to load ALL personal vehicles it loads sucesfully,
Quote:

LoadCar();
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],60000);
LoadComponents(h);
format(TextCar, sizeof(TextCar), "{0D80F2}LS-%d-%s", CarInfo[h][cLicense], CarInfo[h][cLicense2]);
TextUpCar[h] = Create3DTextLabel(TextCar, 0x33AAFFFF, 0.0, 0.0, 0.0, 25, 0, 1);
Attach3DTextLabelToVehicle(TextUpCar[h], h, 0.0, 0.0, 0.1);
}

But i don`t want to load all on gamemodeinit,just load the car of player that connect...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)