! - . . , , . , , , (, ) . !




 
VK: vk.com/sergey68

76890 - 1000,46860 - 500, 300
** V.I.P --> **

: RolePlay MySql #1

1 1 1

  1. #1

      Zzzerl

    :
    :29.09.2017
    :8
    :7 [+/-] 

    RolePlay MySql #1

    P-I RolePlay Rage MP.

    ! . , -. =)

    ... =)

    1.

    MySql , ( ) OpenServer , , .


    1. . mybase.
    2. users.
    3. users: id int AUTO_INCREMENT, name VARCHAR, email VARCHAR, password VARCHAR, money int

    !
    []


    2. .




    nodejs

    1. , : cd dir ( dir , ) cd C:\RAGEMP\server-files
    2. npm package.json : npm init -y
    3. : npm install mysql

    js

    1. client_packages: index.js,login.js login. login js, main.js
    2. packages: roleplay : index.js - , mysql.js - , events.js -
    []


    3. .

    , client_packages\login ,



    js main.js
    PHP :
    $('.validate-form').on('submit',function(){
            var 
    check true;

            for(var 
    i=0i<input.lengthi++) {
                if(
    validate(input[i]) == false){
                    
    showValidate(input[i]);
                    
    check=false;
                }
            }
            return 
    check;
        }); 
    PHP :
    if(check){
                
    let email document.getElementById("email").value
                let pass 
    document.getElementById("pass").value
                mp
    .trigger("loginDataToServer"emailpass0); //    
            

            else {
                
    console.log("");
            } 
    PHP :
    $('.validate-form').on('submit',function(){
            var 
    check true;

            for(var 
    i=0i<input.lengthi++) {
                if(
    validate(input[i]) == false){
                    
    showValidate(input[i]);
                    
    check=false;
                }
            }
            if(
    check){
                
    let email document.getElementById("email").value
                let pass 
    document.getElementById("pass").value
                mp
    .trigger("loginDataToServer"emailpass0); //    
            

            else {
                
    console.log("");
            }
            return 
    check;
        }); 
    client_packages index.js
    PHP :
    require("login.js"); //  
    mp.gui.chat.show(true); // 
    mp.gui.chat.activate(false);//  
    login.js
    PHP :
    var loginBrowser mp.browsers.new("package://login/index.html"); //         .     ,    index.js   login.js     
    mp.gui.cursor.show(truetrue); // 
    mp.events.add("loginDataToServer", (emailpassstate) => { //    
         
    mp.events.callRemote("sendDataToServer"emailpassstate); //   
    });
    mp.events.add("loginHandler", (handle) => { //   
       
    switch(handle){
            case 
    "success"//  
        
    {
                  
    loginBrowser.destroy(); //   
                  
    mp.gui.chat.push("  "); //   
                  
    mp.gui.chat.activate(true); // 
              
    mp.gui.cursor.show(falsefalse); // 
                  
    break;
            }
       }
    }); 
    packages\roleplay mysql.js
    PHP :
    "use strict";
    let mysql module.exports//  
    console.log('  ...'); //

    var mysql2 = require('mysql'); // 

    mysql.connection mysql2.createConnection({ 
        
    host     '',
        
    user     '',
        
    password '',
        
    database ''
    });
    mysql.connection.connect(function(err) { // 
         
    if(err) { //   
          
    console.log("    ...");
          throw 
    err;
          } else {
              
    console.log('  , !'); 
          }
    });
    console.log(' ...');

    setInterval(function() { //      10 ,  ,         ,    
        
    mysql.connection.query('select 1', function(errresults) {
        });
    }, 
    10000); 
    events.js
    PHP :
    var mysql = require('./mysql.js'); //   
    //
    mp.events.add("playerJoin"checkJoinPlayer); //    
    mp.events.add("sendDataToServer"sendDataToServer); //   

    //
    function checkJoinPlayer(player//    
    {
        
    console.log(`${player.name}   .`);
        
    player.loggedInAs "";//  
        
    }
    function 
    sendDataToServer(playeremailpassstate//   
    {
        
    let loggedAccount mp.players.toArray().find(=> p.loggedInAs == email); // 
        
    switch(state)
        {
            case 
    0:
            {
                if(
    loggedAccount)// 
                
    {
                    
    console.log("  .");
                }
                else
                {
                    
    mysql.connection.query('SELECT `password`,`name` FROM `users` WHERE `email` = ?', [email], function(errres)
                    {
                        if(
    res.length 0)//  
                        
    {
                            
    let sqlPass res[0]["password"];
                            
    let sqlName res[0]["name"];
                            if(
    sqlPass == pass//      
                            
    {
                                
    player.name sqlName//  
                                
    player.call("loginHandler", ["success"]); //   
                                
    loadAccount(player);// 
                            
    }
                        }
                    });
                }
            }
        }
    }
    function 
    loadAccount(p)
    {
        
    mysql.connection.query('SELECT * FROM `users` WHERE name = ?', [p.name], function(errresrow){
             if(
    errconsole.log(err);
             if(
    res.length)
             {
                
    p.loggedInAs res[0]["email"]; //  
             
    }
        });

    index.js
    PHP :
    require('./events.js'); // 
    []

    4.


    conf.json
    PHP :
    {
        
    "maxplayers" 100//  
        
    "name" "Pawno-info"// 
        
    "gamemode" "roleplay"//
        
    "stream-distance" 500.0//  
        
    "announce" false//    
        
    "csharp" "disabled"//....
        
    "port"22005//
        
    "language""ru"//
        
    "url":"http://pawno-info.ru/"//
        
    "voice-chat"true// 
        
    "voice-chat-sample-rate"48000 // 

    =)

    []

    , . - , . , Rage MP. ,
  2. 1 c Zzzerl :

    me0w (02.09.2019)

, : 24

/su, 1000, 500, , css, , , html, , info, , , mysql, , , , , , , , pawno, pawno-info, php, roleplay, server

(, , , , , ), , .
!
samp-rp advanvce pawn s0beit cs 1.6 0.3x World of Tanks samp-rp, samp-rp, - PAWNO SA-MP IV-MP MTA cleo s0beit sobeit sa-mp sa-mp pawno pawno pawno iv-mp iv-mp iv-mp godfather SAMP gta 4 4 GTA 4 GTA 4 GTA 4 SAMP SAMP Pen1 LS Pen1 Fugitive The Godfather rp roleplay samp-rp sa-mp sa-mp pawno gta-iv gta-v gta-sa gta-3 gta-III gta-4 gta-5 gta-vc mta mta-dm mta-race mta-sa pawno info ru pawno pawno gta-iv gta-iv gta-v gta-v gta-iv keygen gta sa gta 4 multiplayer gta san adnreas multiplayer sa-mp forum sa-mp pawno sa-mp pawno sa-mp gta-sa pawno pawno errors sa-mp 0.3c SA-MP 0.3d 4 GTA 4 GTA 4 GTA 4 SAMP SAMP Pen1 LS Pen1 Fugitive The Godfather SAMP hack rat android instagram twitter ddos root linux ubuntu mac android advance arizona 4g