0x32789
Expert
Hi guys I am trying to make a reading and writing function for my hack so it can read values which were set old time and there is no need to set it again and again
But I have a problem when I try to write something in a file it freezes my game.
and also when my script tries to read, it dosent read
Help me I am not good in File I/O functions. (or probably cpp)
this is one of the commands and all of them crash:
and my fexists(its my own)
read function
But I have a problem when I try to write something in a file it freezes my game.
and also when my script tries to read, it dosent read
Help me I am not good in File I/O functions. (or probably cpp)
this is one of the commands and all of them crash:
Code:
if(fexists(WIDTH_FILE))
{
DeleteFile((LPCSTR)*WIDTH_FILE);
}
CreateFile((LPCSTR)*WIDTH_FILE,GENERIC_READ,FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL,NULL);
FILE *file;
file = fopen(WIDTH_FILE, "w");
if (!file) return;
fprintf(file,"%d", felix);
fclose(file);
Code:
bool fexists(const char *_filename)
{
FILE *temp_chck_99482;
temp_chck_99482 = fopen(_filename, "w");
if (!temp_chck_99482) return false;
else if (temp_chck_99482) return true;
return false;
}
read function
Code:
FILE *file;
char read[1000];
if(fexists(SPEED_FILE))
{
file = fopen(SPEED_FILE,"r");
if (!file)
{
AddMessageToSAWindow( D3DCOLOR_XRGB( 0, 0xFF, 0 ), "Failed to read Speed Value from Configuration file.");
}
else
{
while (fgets(read,1000, file) != NULL)
{
std::string fs(read);
MOD_SPEED = std::stof(fs);
}
}
fclose(file);
}
if(fexists(HEIGHT_FILE))
{
file = fopen(HEIGHT_FILE,"r");
if (!file)
{
AddMessageToSAWindow( D3DCOLOR_XRGB( 0, 0xFF, 0 ), "Failed to read Screen Height Value from Configuration file.");
}
else
{
while (fgets(read,1000, file) != NULL)
{
x = (int)read;
}
}
fclose(file);
}
if(fexists(WIDTH_FILE))
{
file = fopen(WIDTH_FILE,"r");
if (!file)
{
AddMessageToSAWindow( D3DCOLOR_XRGB( 0, 0xFF, 0 ), "Failed to read Screen Width Value from Configuration file.");
}
else
{
while (fgets(read,1000, file) != NULL)
{
y = (int)read;
}
}
fclose(file);
}