01.11.2013, 01:54
Hey guys so Im creating a dynamic payphone command /createpayphone. The Savephone() writes to the file but for some reason its not loading them. Do you guys see an issue you here?
LOAD PHONE
SAVE PHONE
COMMAND
LOAD PHONE
Код:
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; }