06.01.2012, 15:25
solved
Could I do this with this system?
pawn Код:
pawn Код:
|
Does the plugin support subfolders?
I want to create a directory within a directory, but when I perform the code the server shuts down because it can't create a file within the directory because the directory doesn't exists, and hasn't been created. So, would this peace of code work? pawn Код:
|
if(!file_read("Dennis_Smith.txt","Text")) { print("Found file"); }
Why doesn't this work? The file does exist with "Text" in it but doesn't return true.
Код:
if(!file_read("Dennis_Smith.txt","Text")) { print("Found file"); } |
new str[48];
file_read("Dennis_Smith.txt", str);
if(!strcmp(str, "Text")) print("Found file");
file_create("scriptfiles/users/Dennis_Smith.txt");
stock SaveServer(Stat[], format[], {Float,_}) {
if(!dir_exists("Saved/")) dir_create("Saved/");
if(!dir_exists("Saved/Server/")) dir_create("Saved/Server/");
new File[100],
String[100];
format(File, 100, ServerFile, Stat); // #define ServerFile "Saved/Server/%s.ini"
if(file_exists(File)) file_delete(File);
switch(format[0]) {
case 's': {
new Result[100];
for(new ResultPos = 0; getarg(3, ResultPos) != 0; ResultPos++) {
Result[ResultPos] = getarg(3, ResultPos);
}
format(String, 100, "%s", Result);
}
case 'd', 'i': {
new Result = getarg(3);
format(String, 100, "%d", Result);
}
case 'f': {
new Float: Result = Float: getarg(3);
format(String, 100, "%f", Result);
}
}
file_create(File);
file_write(File, String);
printf("%s", String);
return true;
}
new File: f = f_open("server.cfg"); // Open the file.
new string[100];
while(f_read(f, string)) // Returns true when a line is found
print(string); // Will print each line of the server.cfg
f_close(f); // Make sure to close the file.
Nice but, f_write isn't so healthy.Because every f_write opens file, writes it, closes file.
I think that, f_write must be with f_open. |
new File:file = f_open("horse.txt", "w");
fwrite("Welcome");
fwrite(" horses");
fclose(file);