Quote:
Originally Posted by js
Выложи код.
|
Ну собственно вот
LoadAuto
PHP Code:
public LoadAuto()
{
new arrCoords[26][64];
new strFromFile2[256];
new File: file = fopen("auto.cfg", io_read);
if (file)
{
new idx;
while (idx < CAR_PROD)
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
AutoInfo[idx+1][aStats] = strval(arrCoords[0]);
AutoInfo[idx+1][aModel] = strval(arrCoords[1]);
AutoInfo[idx+1][aAutoX] = floatstr(arrCoords[2]);
AutoInfo[idx+1][aAutoY] = floatstr(arrCoords[3]);
AutoInfo[idx+1][aAutoZ] = floatstr(arrCoords[4]);
AutoInfo[idx+1][aAutoAngle] = floatstr(arrCoords[5]);
AutoInfo[idx+1][aColor1] = strval(arrCoords[6]);
AutoInfo[idx+1][aColor2] = strval(arrCoords[7]);
strmid(AutoInfo[idx+1][aOwner], arrCoords[8], 0, strlen(arrCoords[8]), 255);
AutoInfo[idx+1][aPrice] = strval(arrCoords[9]);
AutoInfo[idx+1][aKey] = strval(arrCoords[10]);
AutoInfo[idx+1][a0] = strval(arrCoords[11]);
AutoInfo[idx+1][a1] = strval(arrCoords[12]);
AutoInfo[idx+1][a2] = strval(arrCoords[13]);
AutoInfo[idx+1][a3] = strval(arrCoords[14]);
AutoInfo[idx+1][a4] = strval(arrCoords[15]);
AutoInfo[idx+1][a5] = strval(arrCoords[16]);
AutoInfo[idx+1][a6] = strval(arrCoords[17]);
AutoInfo[idx+1][a7] = strval(arrCoords[18]);
AutoInfo[idx+1][a8] = strval(arrCoords[19]);
AutoInfo[idx+1][a9] = strval(arrCoords[20]);
AutoInfo[idx+1][a10] = strval(arrCoords[21]);
AutoInfo[idx+1][a11] = strval(arrCoords[22]);
AutoInfo[idx+1][a12] = strval(arrCoords[23]);
AutoInfo[idx+1][a13] = strval(arrCoords[24]);
AutoInfo[idx+1][aPaintJob] = strval(arrCoords[25]);
idx++;
}
fclose(file);
}
return 1;
}
SaveAuto
PHP Code:
public SaveAuto()
{
new idx;
new File: file2;
while (idx < CAR_PROD)
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%d,%f,%f,%f,%f,%d,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
AutoInfo[idx+1][aStats],
AutoInfo[idx+1][aModel],
AutoInfo[idx+1][aAutoX],
AutoInfo[idx+1][aAutoY],
AutoInfo[idx+1][aAutoZ],
AutoInfo[idx+1][aAutoAngle],
AutoInfo[idx+1][aColor1],
AutoInfo[idx+1][aColor2],
AutoInfo[idx+1][aOwner],
AutoInfo[idx+1][aPrice],
AutoInfo[idx+1][aKey],
AutoInfo[idx+1][aLock],
AutoInfo[idx+1][a0],
AutoInfo[idx+1][a1],
AutoInfo[idx+1][a2],
AutoInfo[idx+1][a3],
AutoInfo[idx+1][a4],
AutoInfo[idx+1][a5],
AutoInfo[idx+1][a6],
AutoInfo[idx+1][a7],
AutoInfo[idx+1][a8],
AutoInfo[idx+1][a9],
AutoInfo[idx+1][a10],
AutoInfo[idx+1][a11],
AutoInfo[idx+1][a12],
AutoInfo[idx+1][a13],
AutoInfo[idx+1][aPaintJob]);
if(idx == 0)
{
file2 = fopen("auto.cfg", io_write);
}
else
{
file2 = fopen("auto.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
И команда /park , после которой происходит данная проблема
PHP Code:
if (strcmp(cmd, "/park", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pCarKey2] == 0 && PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid,COLOR_GREY,"Ó âàñ íåò òà÷êè");
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
new cari = GetPlayerVehicleID(playerid);
if(cari == PlayerInfo[playerid][pCarKey2] || cari == PlayerInfo[playerid][pCarKey]|| cari == PlayerInfo[playerid][pCarKey3])
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
new Float:xcar, Float:ycar, Float:zcar, Float:ancar;
new mods = GetVehicleModel(cari);
GetVehicleZAngle(cari, ancar);
GetVehiclePos(cari,xcar,ycar,zcar);
DestroyVehicle(cari);
CreateVehicle(mods,xcar,ycar,zcar,ancar,AutoInfo[cari][aColor1],AutoInfo[cari][aColor2],SPAWN_CARS);
AutoInfo[cari][aAutoX] = xcar;
AutoInfo[cari][aAutoY] = ycar;
AutoInfo[cari][aAutoZ] = zcar;
AutoInfo[cari][aAutoAngle] = ancar;
SaveAuto();
if(AutoInfo[cari][a0] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a0]);
}
if(AutoInfo[cari][a1] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a1]);
}
if(AutoInfo[cari][a2] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a2]);
}
if(AutoInfo[cari][a3] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a3]);
}
if(AutoInfo[cari][a4] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a4]);
}
if(AutoInfo[cari][a5] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a5]);
}
if(AutoInfo[cari][a6] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a6]);
}
if(AutoInfo[cari][a7] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a7]);
}
if(AutoInfo[cari][a8] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a8]);
}
if(AutoInfo[cari][a9] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a9]);
}
if(AutoInfo[cari][a10] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a10]);
}
if(AutoInfo[cari][a11] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a11]);
}
if(AutoInfo[cari][a12] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a12]);
}
if(AutoInfo[cari][a13] != 0)
{
AddVehicleComponent(cari, AutoInfo[cari][a13]);
}
if(AutoInfo[cari][aPaintJob] != 0)
{
ChangeVehiclePaintjob(cari,AutoInfo[cari][aPaintJob]);
}
SendClientMessage(playerid,COLOR_YELLOW,"Òðàíñïîðò ïðèïàðêîâàí!");
}
else
{
SendClientMessage(playerid,COLOR_GREY,"Âû íå â ñâîåé êóïëåííîé òà÷êå");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY,"Âû íå â òà÷êå");
}
}
return 1;
}