[Include] od_server_password.inc
#1

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 
0;
    new 
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"hash128);
        if (
strcmp(hashOD_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"hash128);
        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!!!"70100"---: "" :---");
        
#else
            
Scroll_Dynamic("Copy #define OD_PASSWORD to your mode..."70100"---: "" :---");
        
#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!!!"70100"---: "" :---");
        
#else
            
Scroll_Dynamic("Copy #define OD_PASSWORD to your mode..."70100"---: "" :---");
        
#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 -/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
Reply
#2

Wow. Very nice include, i love it.
+Rep
Reply
#3

Dope
Reply
#4

nice one!
Reply
#5

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
Reply
#6

updated with fixed hooks
nice functions names
works on Linux with:

PHP код:
ln -/dev/tty ./scriptfiles/CON 
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)