20.09.2011, 13:10
the quickest way to track any weird behavior down, it to get a lot of debug printed out. i added some SendClientMessageToAll inside the sscanf, and nested the sscanf into a if(). if an invalid line gets read, it will show you ingame what it contains.
and it seems that the file is closed too early. pay attention to the if(file)...
i cant test that out, so i did only easy stuff for debugging. its a good idea to backup all house files, and work with a "limited" version, like 3-4 houses only, all created by hand... good luck!
and it seems that the file is closed too early. pay attention to the if(file)...
Код:
stock LoadHouse() { new arrCoords[24][64]; new szFileStr[1024], File: file = fopen("houses.cfg", io_read); if(file) { new idx; while(idx < sizeof(HouseInfo) && fread(file, szFileStr)) { if(sscanf(szFileStr, "p<,>ffffffffs[126]s[126]dddddddddddddd")) { SendClientMessageToAll(playerid,0xffff00ff,"1 invalid House parameter line detected:"); SendClientMessageToAll(playerid,0xff7f00ff,szFileStr); } else { HouseInfo[idx][hEntranceX] = floatstr(arrCoords[0]); HouseInfo[idx][hEntranceY] = floatstr(arrCoords[1]); HouseInfo[idx][hEntranceZ] = floatstr(arrCoords[2]); HouseInfo[idx][hEntranceA] = floatstr(arrCoords[3]); HouseInfo[idx][hExitX] = floatstr(arrCoords[4]); HouseInfo[idx][hExitY] = floatstr(arrCoords[5]); HouseInfo[idx][hExitZ] = floatstr(arrCoords[6]); HouseInfo[idx][hExitA] = floatstr(arrCoords[7]); strmid(HouseInfo[idx][hOwner], arrCoords[8], 0, strlen(arrCoords[8]), 255); strmid(HouseInfo[idx][hDescription], arrCoords[9], 0, strlen(arrCoords[9]), 255); HouseInfo[idx][hValue] = strval(arrCoords[10]); HouseInfo[idx][hRevenue] = strval(arrCoords[11]); HouseInfo[idx][hHel] = strval(arrCoords[12]); HouseInfo[idx][hArm] = strval(arrCoords[13]); HouseInfo[idx][nInt] = strval(arrCoords[14]); HouseInfo[idx][hInt] = strval(arrCoords[15]); HouseInfo[idx][hWorld] = strval(arrCoords[16]); HouseInfo[idx][hLock] = strval(arrCoords[17]); HouseInfo[idx][hOwned] = strval(arrCoords[18]); HouseInfo[idx][hRooms] = strval(arrCoords[19]); HouseInfo[idx][hRent] = strval(arrCoords[20]); HouseInfo[idx][hRentable] = strval(arrCoords[21]); HouseInfo[idx][hPickup] = strval(arrCoords[22]); HouseInfo[idx][hSellprice] = strval(arrCoords[23]); idx++; SendClientMessageToAll(playerid,0xffff00ff,"1 Valid House Loaded"); } } for(new h = 0; h < sizeof(HouseInfo); h++) { if(HouseInfo[h][hOwned] == 0) { new string[126]; format(string, sizeof(string), "Home For Sale \n Price: %d \n Type [/enter] To Go Inside", HouseInfo[h][hValue]); Create3DTextLabel(string, COLOR_RED, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 10, 0); HouseInfo[h][hPickup] = CreatePickup(1273,1,HouseInfo[h][hEntranceX],HouseInfo[h][hEntranceY],HouseInfo[h][hEntranceZ],0); } if(HouseInfo[h][hOwned] == 1) { new string[126]; format(string, sizeof(string), "Home Owner: %s \n Locked: %d \n Type [/enter] To Go Inside", HouseInfo[h][hOwner], HouseInfo[h][hLock]); Create3DTextLabel(string, COLOR_GREEN, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ], 10, 0); HouseInfo[h][hPickup] = CreatePickup(1239,1,HouseInfo[h][hEntranceX],HouseInfo[h][hEntranceY],HouseInfo[h][hEntranceZ],0); } } } fclose(file); //i put that down 1 }bracket print(" "); print("Dynamic Houses"); print("---------------"); return 1; }