LoadPhones()
{
// new string[256];
new arrCoords[4][64];
new strFromFile2[260];
new File: file = fopen("payphones.cfg", io_read);
if(file)
{
new idx;
while (idx < sizeof(PhoneInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
PhoneIDTaken[idx] = strval(arrCoords[0]);
PhoneInfo[idx][PhoneX] = floatstr(arrCoords[1]);
PhoneInfo[idx][PhoneY] = floatstr(arrCoords[2]);
PhoneInfo[idx][PhoneZ] = floatstr(arrCoords[3]);
if(HouseIDTaken[idx])
{
CreateStreamed3DTextLabel(PAYPHONE_LABEL, HOUSE_COLOR,PhoneInfo[idx][PhoneX],PhoneInfo[idx][PhoneY],PhoneInfo[idx][PhoneZ] , 10.0, idx);
phones++;
}
idx++;
}
}
return 1;
}
SavePhones()
{
new idx = 1;
new File: file2;
while (idx < sizeof(GarageInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "|%d|%f|%f|%f|\n",
GarageIDTaken[idx],
PhoneInfo[idx][PhoneX],
PhoneInfo[idx][PhoneY],
PhoneInfo[idx][PhoneZ]);
if(idx == 0)
{
file2 = fopen("payphones.cfg", io_write);
}
else
{
file2 = fopen("payphones.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
if(strcmp(cmd, "/createphone", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new id = GetAvailableID(TYPE_PHONE);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PhoneIDTaken[id] = 1;
PhoneInfo[id][PhoneX] = x;
PhoneInfo[id][PhoneY] = y;
PhoneInfo[id][PhoneZ] = z;
SavePhones();
CreateStreamed3DTextLabel(PAYPHONE_LABEL, HOUSE_COLOR, x, y, z, 10.0, 0);
}
return 1;
}
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;
}
LoadPhones();
printf("[OnGameModeInit] payphone.cfg loaded.(gate count: %d)", phones);
[22:47:47] |1|2308.125488|-1636.242431|14.827047| = 14, 1.0000, 2308.1254, -1636.2424 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:47] |1|2308.125488|-1636.242431|14.827047| = 14, 1.0000, 2308.1254, -1636.2424 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] |1|0.000000|0.000000|0.000000| = 0, 1.0000, 0.0000, 0.0000 [22:47:48] |0|0.000000|0.000000|0.000000| = 0, 0.0000, 0.0000, 0.0000 [22:47:48] [OnGameModeInit] payphone.cfg loaded.(gate count: 2)
SavePhones()
{
new idx = 1;
new File:file = fopen("payphones.cfg", io_write);
while (idx < sizeof(PhoneInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d|%.4f|%.4f|%.4f\r\n",PhoneIDTaken[idx],PhoneInfo[idx][PhoneX],PhoneInfo[idx][PhoneY],PhoneInfo[idx][PhoneZ]);
}
fclose(file);
return;
}
|
pawn Код:
|