01.11.2013, 02:13
pawn Код:
SavePhones()
{
new coordsstring[50],idx = -1;
new File:file = fopen("payphones.cfg", io_write);
while(++idx < sizeof(GarageInfo))
{
format(coordsstring, sizeof(coordsstring), "%d|%.4f|%.4f|%.4f\r\n",GarageIDTaken[idx],PhoneInfo[idx][PhoneX],PhoneInfo[idx][PhoneY],PhoneInfo[idx][PhoneZ]);
fwrite(file, coordsstring);
}
fclose(file);
return;
}
LoadPhones()
{
new arrCoords[4][64];
new strFromFile[100];
new File:file = fopen("payphones.cfg", io_read);
if(file)
{
new idx = -1;
while(++idx < sizeof(PhoneInfo) && fread(file, strFromFile))
{
split(strFromFile, arrCoords, '|');
PhoneIDTaken[idx] = strval(arrCoords[0]);
PhoneInfo[idx][PhoneX] = floatstr(arrCoords[1]);
PhoneInfo[idx][PhoneY] = floatstr(arrCoords[2]);
PhoneInfo[idx][PhoneZ] = floatstr(arrCoords[3]);
printf("%s = %d, %.4f, %.4f, %.4f",strFromFile,PhoneIDTaken[idx],PhoneInfo[idx][PhoneX],PhoneInfo[idx][PhoneY],PhoneInfo[idx][PhoneZ]);
if(HouseIDTaken[idx])
{
CreateStreamed3DTextLabel(PAYPHONE_LABEL, HOUSE_COLOR, PhoneInfo[idx][PhoneX], PhoneInfo[idx][PhoneY], PhoneInfo[idx][PhoneZ], 10.0, idx);
phones++;
}
}
}
return;
}
if(strcmp(cmd, "/createphone", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new id = GetAvailableID(TYPE_PHONE); // must returns 0 - sizeof(PhoneInfo)-1
PhoneIDTaken[id] = 1;
GetPlayerPos(playerid, PhoneInfo[id][PhoneX], PhoneInfo[id][PhoneY], PhoneInfo[id][PhoneZ]);
CreateStreamed3DTextLabel(PAYPHONE_LABEL, HOUSE_COLOR, PhoneInfo[id][PhoneX], PhoneInfo[id][PhoneY], PhoneInfo[id][PhoneZ], 10.0, 0);
SavePhones();
}
return 1;
}