11.06.2009, 16:16
So, here is my very first post of this forum. I was just wondering about that server crashes in some file processing scripts when it does not founds a specified file. So I just created a function named as DoesFileExists("filename.txt") - An example is given below :-
Example :
This example will print the message EXISTS / Not EXISTS in your console window of the server. The file is kept in scriptfiles folder in your SAMP Server directory. Like if your SAMP Server is here
C:\Program Files\Server SAMP
Then the file will be here
C:\Program Files\Server SAMP\scriptfiles\ExampleFile.txt
Tell me if stuck with my code.
Use it wherever you want to.
Steal, modify or do w/e you want.
Code:
DoesFileExists(fname[]){
new File:checkfile = fopen(fname[0],io_read);
if(!checkfile){
return 0;
}
else{
fclose(checkfile);
return 1;
}
}
Code:
#include <a_samp>
public OnPlayerConnect(playerid)
{
if(DoesFileExists("ExampleFile.txt")){
printf("exists");
}
else{
printf("Not Exists");
}
return 1;
}
DoesFileExists(fname[]){
new File:checkfile = fopen(fname[0],io_read);
if(!checkfile){
return 0;
}
else{
fclose(checkfile);
return 1;
}
}
This example will print the message EXISTS / Not EXISTS in your console window of the server. The file is kept in scriptfiles folder in your SAMP Server directory. Like if your SAMP Server is hereC:\Program Files\Server SAMP
Then the file will be here
C:\Program Files\Server SAMP\scriptfiles\ExampleFile.txt
Tell me if stuck with my code.
Use it wherever you want to.
Steal, modify or do w/e you want.

