The below code reports "Found" but doesn't write the extra line to the file.
No error reported, nothing.
but if it doesn't find the map in the file, it does create the lines as defined in after "if(iFound == 0)".
IT doesn't add the extra snippet lines after the server print though.
Any clue?
Thanks
Code:
new file_handle = fopen(g_file_path,"rt+")
new iFound = 0
new temp_string[128]
while(!feof(file_handle))
{
new buffer[128]
fgets(file_handle,buffer,sizeof(buffer))
if(containi(buffer,g_map_name) != -1)
{
iFound = 1
server_print("Found!")
format(temp_string,sizeof(temp_string),"^n[Ent] %s %i %i %i %i^n",gName,origin[0],origin[1],origin[2],angle)
fprintf(file_handle,temp_string)
break;
}
}
if(iFound == 0)
{
format(temp_string,sizeof(temp_string),"^n[%s]^n[Ent] %s %i %i %i %i^n[/%s]^n",g_map_name,gName,origin[0],origin[1],origin[2],angle,g_map_name)
fprintf(file_handle,temp_string)
}
client_print(id,print_console,"[Ent Spawner] Entity %s was saved to file!",gName)
fclose(file_handle)
__________________