13.12.2016, 00:19
(
Последний раз редактировалось OneDay; 04.04.2017 в 13:21.
)
PHP код:
#if defined _INC_od_server_password
#endinput
#endif
#define _INC_od_server_password
#include <od_stdio>
#define OD_PASSWORD_OnGameModeInit Password_Check
static OD_PASSWORD_Strip(str[]) {
new i = 0;
new j = 0;
while (str[i] != 0) {
if (str[i] > 32) {
str[j] = str[i];
++j;
}
++i;
}
str[j] = 0;
}
bool:Password_Check(bool:hang = false) {
#if defined OD_PASSWORD
IO_Write("Write the password to run the mode (on Windows press enter first).");
IO_NewLine();
IO_Flush();
new pass[32];
IO_Read(pass);
OD_PASSWORD_Strip(pass);
new hash[128];
SHA256_PassHash(pass, "od_server_password.inc", hash, 128);
if (strcmp(hash, OD_PASSWORD) != 0) {
while (hang) {
IO_Read(pass);
}
return false;
}
return true;
#else
IO_Write("You do not have a password. Write to get the code (on Windows press enter first).");
IO_NewLine();
IO_Flush();
new pass[32];
IO_Read(pass);
OD_PASSWORD_Strip(pass);
new hash[128];
SHA256_PassHash(pass, "od_server_password.inc", hash, 128);
if (strlen(pass) == 0) {
IO_Write("Password was empty");
IO_NewLine();
}
IO_Write("#define OD_PASSWORD \"");
IO_Write(hash);
IO_Write("\" // \"");
IO_Write(pass);
IO_Write("\"");
IO_NewLine();
IO_Flush();
return false;
#endif
}
Make a password example:
PHP код:
#include <a_samp>
#include <od_server_password>
#include <od_scroll_text>
#include <od_progress_bar>
main()
{
}
public OnGameModeInit()
{
if (Password_Check(false)) {
IO_NewLine();
IO_Write("SERVER LOADING...");
IO_NewLine();
ProgressBar_Up(50);
ProgressBar_Done();
IO_NewLine();
IO_Flush();
} else {
IO_NewLine();
#if defined OD_PASSWORD
Scroll_Dynamic("YOU CAN NOT USE THIS SCRIPT!!!", 70, 100, "---: ", " :---");
#else
Scroll_Dynamic("Copy #define OD_PASSWORD to your mode...", 70, 100, "---: ", " :---");
#endif
}
return 1;
}
Use a password example:
PHP код:
#define OD_PASSWORD "AAF0630BDBB3DFE04DED48AEBF688838C6797F6AF02C656B75F10DF5F08AA1BC" // "changeme"
#include <a_samp>
#include <od_server_password>
#include <od_scroll_text>
#include <od_progress_bar>
main()
{
}
public OnGameModeInit()
{
if (Password_Check(false)) {
IO_NewLine();
IO_Write("SERVER LOADING...");
IO_NewLine();
ProgressBar_Up(50);
ProgressBar_Done();
IO_NewLine();
IO_Flush();
} else {
IO_NewLine();
#if defined OD_PASSWORD
Scroll_Dynamic("YOU CAN NOT USE THIS SCRIPT!!!", 70, 100, "---: ", " :---");
#else
Scroll_Dynamic("Copy #define OD_PASSWORD to your mode...", 70, 100, "---: ", " :---");
#endif
}
return 1;
}
Wrong disables everything (even ctrl-c doesn't work):
Put:
PHP код:
Password_Check(true);
To make work on Linux type:
PHP код:
ln -s /dev/tty ./scriptfiles/CON
http://forum.sa-mp.com/showthread.ph...22#post3812622
Example uses od_scroll_text.inc and od_progress_bar.inc:
http://forum.sa-mp.com/showthread.ph...87#post3812687
http://forum.sa-mp.com/showthread.ph...29#post3812629