10.08.2011, 06:06
Hello guys, I need help making a "/buycar" command.. firstly you'd need to see the car system so far, and here it is:
I'm not sure how to make a buycar command.. like the code to buy a car and set the players vinfo information so when they disconnect it does the SaveCars() function but yeah, hard to explain.
pawn Код:
//==============================================================================
public LoadCar()
{
new arrCoords[13][64];
new strFromFile2[256];
new File: file = fopen("CarOwnership.cfg", io_read);
if (file)
{
new idx = 0;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo[idx][vModel] = strval(arrCoords[0]);
CarInfo[idx][vLocationx] = floatstr(arrCoords[1]);
CarInfo[idx][vLocationy] = floatstr(arrCoords[2]);
CarInfo[idx][vLocationz] = floatstr(arrCoords[3]);
CarInfo[idx][vAngle] = floatstr(arrCoords[4]);
CarInfo[idx][vColorOne] = strval(arrCoords[5]);
CarInfo[idx][vColorTwo] = strval(arrCoords[6]);
strmid(CarInfo[idx][vOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
strmid(CarInfo[idx][vDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
CarInfo[idx][vValue] = strval(arrCoords[9]);
CarInfo[idx][vLicense] = strval(arrCoords[10]);
CarInfo[idx][vOwned] = strval(arrCoords[11]);
CarInfo[idx][vLock] = strval(arrCoords[12]);
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][vOwner],CarInfo[idx][vLicense]);
idx++;
}
}
return 1;
}
//==============================================================================
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
CarInfo[idx][vModel],
CarInfo[idx][vLocationx],
CarInfo[idx][vLocationy],
CarInfo[idx][vLocationz],
CarInfo[idx][vAngle],
CarInfo[idx][vColorOne],
CarInfo[idx][vColorTwo],
CarInfo[idx][vOwner],
CarInfo[idx][vDescription],
CarInfo[idx][vValue],
CarInfo[idx][vLicense],
CarInfo[idx][vOwned],
CarInfo[idx][vLock]);
if(idx == 0)
{
file2 = fopen("CarOwnership.cfg", io_write);
}
else
{
file2 = fopen("CarOwnership.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
//==============================================================================
pawn Код:
enum vInfo
{
vModel,
Float:vLocationx,
Float:vLocationy,
Float:vLocationz,
Float:vAngle,
vColorOne,
vColorTwo,
vOwner[MAX_PLAYER_NAME],
vDescription[MAX_PLAYER_NAME],
vValue,
vLicense,
vRegistration,
vOwned,
vLock,
ownedvehicle,
};
new CarInfo[456][vInfo];