"SERVER: Unknown Command" problem..
#1

Whenever i try using the command, i get "SERVER: Unknown Command".
It's in a filterscript, but everything else in the filterscript works just fine.

dont steal my scripts
Reply
#2

Load crashdetect plugin for that. Until then, I found 2 things.

pawn Код:
printf("* zBlock: LOGIN! %s has logged in the zBlock 'CP'!", GetName(playerid), SecondParam);
1 placeholder and 2 arguments.

The last one and most important, you should check if the file handle is valid before using any file function because it can crash the server. For example, this (from your code) is incorrect:
pawn Код:
new
    File: zBlockstuff = fopen("/zblock/password.txt", io_read)
;
fread(zBlockstuff, string);
fclose(zBlockstuff);
It should be:
pawn Код:
new
    File: zBlockstuff = fopen("/zblock/password.txt", io_read)
;
if (zBlockstuff)
{
    fread(zBlockstuff, string);
    fclose(zBlockstuff);
}
Then in changepassword, you have:
pawn Код:
if(zBlockstuff)
{
    fopen("/zblock/password.txt", io_write);
    fwrite(zBlockstuff, SecondParam);
    fclose(zBlockstuff);
   
    format(messagestring, sizeof(messagestring), "zBlock: %s(%d) has changed the password to %s", GetName(playerid), playerid, SecondParam);
    SendMessageToAdmins(COLOR_NOTES2, messagestring);
   
    printf("* zBlock: PASS CHANGE! %s has changed the password to %s!", GetName(playerid), SecondParam);
}
opening a file without storing the file handle to a variable and closing another file handle.
Reply
#3

dont steal my scripts
Reply
#4

If it doesn't exist, it creates the file and it's empty inside. Compare with strcmp, it could return 0 (that they're equal) though you've done a mistake:
pawn Код:
if(strcmp(string, "defaultpassword5791", true))
that checks if the text "string" holds is not "defaultpassword5791". It should be:
pawn Код:
if(!strcmp(string, "defaultpassword5791", true))

About the empty line in the file, you can do something like this:
pawn Код:
if (!fread(zBlockstuff, string))
{
    // it's empty, do whatever you want..
}
else
{
    if(!strcmp(string, "defaultpassword5791", true))
    {
        DefaultPass = 1;
        print("** zBlock: Server is using the default password\n** zBlock: Please change it for your own safety.");
    }
    else
    {
        DefaultPass = 0;
        print("** zBlock: Server is NOT using the default password\n** zBlock: The 'CP' is ready for use.");
    }
}
Reply
#5

Haha, thank you!
So.. em, about that command.
Should i change the "if(strcmp(SecondParam, string, true) == 0)" to "if(!strcmp(SecondParam, string, true) == 0)"? ( Password checking )
Reply
#6

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Should i change the "if(strcmp(SecondParam, string, true) == 0)" to "if(!strcmp(SecondParam, string, true) == 0)"? ( Password checking )
No, you don't! It checks already if what strcmp returns is equal to 0.
pawn Код:
// an example:
if (a == 0)
// is same as:
if (!a)
both statements check if a is equal 0.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
No, you don't! It checks already if what strcmp returns is equal to 0.
pawn Код:
// an example:
if (a == 0)
// is same as:
if (!a)
both statements check if a is equal 0.
Konstantinos saves the day once again

"You must spread some Reputation around before giving it to Konstantinos again." :c
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)