[Include] od_server_password.inc - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (
https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (
https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] od_server_password.inc (
/showthread.php?tid=624230)
od_server_password.inc - Make your mode not work without a password. -
OneDay - 13.12.2016
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
}
It can make your server not be stolen. When it starts you must type the password in the console, or the mode will not start. If you have no password, the server will make the code for your password.
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;
}
Correct:
Wrong disables everything (even ctrl-c doesn't work):
Put:
PHP код:
Password_Check(true);
For no wrong message and no CPU use on wrong password (just makes the mode not work).
To make work on Linux type:
PHP код:
ln -s /dev/tty ./scriptfiles/CON
Uses od_stdio.inc:
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
Re: od_server_password.inc -
Marines - 13.12.2016
Wow. Very nice include, i love it.
+Rep
Re: od_server_password.inc -
Eoussama - 13.12.2016
Dope
Re: od_server_password.inc -
tysanio - 14.12.2016
nice one!
Re: od_server_password.inc -
OneDay - 22.12.2016
Quote:
Originally Posted by Marines
Wow. Very nice include, i love it.
+Rep
|
Quote:
Originally Posted by Eoussama
Dope
|
Quote:
Originally Posted by tysanio
nice one!
|
Thanks
Re: od_server_password.inc -
OneDay - 04.04.2017
updated with fixed hooks
nice functions names
works on Linux with:
PHP код:
ln -s /dev/tty ./scriptfiles/CON