23.12.2016, 18:21
Hi, I have my server's settings saved in a file called "Server.ini". It's the only ini file that I need to read from so I decided to create my own function that reads the stuff inside instead of using a ini file reading include. It works, I printed the values and it's all good, but when it comes to setting the password then this is what happens:
https://gyazo.com/632de81739191f94c6d37ded9eb65ea6
in the server's log it's OK though:
this didn't happen when I had an include and now when I try to connect with that password then it tells me it's the wrong password.
Here's the function:
What's up? Please don't tell me to use an include because I don't want to. :P Also when the password is 0 it still says that the server has a password.
https://gyazo.com/632de81739191f94c6d37ded9eb65ea6
in the server's log it's OK though:
Код:
[21:09:55] Setting server password to: "password" [21:09:55] [SERVER]: Server is locked with a password of "password".
Here's the function:
Код:
LoadServer() { if (fexist("Server.ini")) { new File:file = fopen("Server.ini", io_read), buffer[128], row[64], value[64], pos; while (fread(file, buffer)) { pos = strfind(buffer, "="); strmid(row, buffer, 0, pos); strmid(value, buffer, pos + 1, strlen(buffer) - 1); if (!strcmp(row, "Password")) strcpy(g_ServerPassword, value, 24); else if (!strcmp(row, "Taxes")) g_Taxes = floatstr(value); else if (!strcmp(row, "OOCEnabled")) g_OOCEnabled = strval(value); else if (!strcmp(row, "ShellsDisabled")) g_ShellsDisabled = strval(value); else if (!strcmp(row, "CorpsesDisabled")) g_CorpsesDisabled = strval(value); } fclose(file); } if (strcmp(g_ServerPassword, "0")) { new rcon[32]; format(rcon, sizeof(rcon), "password %s", g_ServerPassword); SendRconCommand(rcon); printf("[SERVER]: Server is locked with a password of \"%s\".", g_ServerPassword); } }