Quote:
Originally Posted by The overrated maniac
Thanks all of it worked. When I put szFileData[50000] server crashed, I did it with 9000 and works, what is the max lenght?
|
The theoretical max is not really relevant here since it's much larger than you actually need. You should only use a value that make sense for the use case. For example, an IP address can only be 15 characters, at most. So, it depends on what you're storing in this file and how it's formatted. If you are storing IP addresses, you could get away with a size of 18 (to account for the newline and carriage return and the null character) but I would recommend doubling this value.
Quote:
Originally Posted by The overrated maniac
Edit: testing more I became with a bigger problem.. now I dont have a output, it dosnt put anything in say.
PHP Code:
new Path[256];
get_configsdir(Path, charsmax(Path));
formatex(Path, charsmax(Path),"%s/%s", Path, gFileName);
if(!file_exists(Path)){
return PLUGIN_HANDLED;
}
new f = fopen(Path, "rt");
new szFileData[2000];
while(fgets(f, szFileData, charsmax(szFileData))){
trim(szFileData);
if(contain(szFileData, g_szUserIP) != 1){
client_print(0, print_chat, "CONTAIN IP");
return PLUGIN_HANDLED;
}
else{
client_print(0, print_chat, "NO CONTAIN");
return PLUGIN_HANDLED;
}
}
fclose(f);
Even another message that isnt in the function dont work but I have a client_cmd in this function and it works.. its like the output stop working
|
Don't return in the middle of reading a file because you are creating a memory leak by not properly closing the file every time this code is called.
Also, you are using a value of 1 with contain() which is wrong, you need to use -1.
If you still can't fix it, it will make it much easier to help you if you attach your .sma file.
__________________