Advertisement
iSmirnoff

[PAWN] Registro Online

Sep 19th, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.38 KB | None | 0 0
  1. // ============================================ //
  2. //                  # INCLUDES #                //
  3. // ============================================ //
  4. #include A_SaMP «
  5. #include A_MySQL «
  6. // ============================================ //
  7. //                   # DIALOGS #                //
  8. // ============================================ //
  9. #define xLogin (0)
  10. // ============================================ //
  11. //                  # CONEXÃO #                 //
  12. // ============================================ //
  13. #define xHostName "localhost"
  14. #define xUserName "root"
  15. #define xDataName "SAMP"
  16. #define xPassName ""
  17. // ============================================ //
  18. //                  # VARIAVEIS #               //
  19. // ============================================ //
  20. new xConexao ;
  21. // ============================================ //
  22. //                  # FORWARDS #                //
  23. // ============================================ //
  24. forward xPlayerLogin ( playerid ) ;
  25. forward VerificouLogin ( playerid ) ;
  26. // ============================================ //
  27. //                  # STOCKS #                  //
  28. // ============================================ //
  29. stock Nome ( playerid ) {
  30.  
  31.     new xName [ 21 ] ;
  32.     GetPlayerName ( playerid, xName, 21 ) ;
  33.     return xName ;
  34. }
  35. // ============================================ //
  36. //                  # CALLBACKS #               //
  37. // ============================================ //
  38. public OnFilterScriptInit() {
  39.  
  40.     xConexao = mysql_connect ( xHostName, xUserName, xDataName, xPassName ) ;
  41.  
  42.     if( mysql_ping( ) >= 1 ) print( "[ MySQL ]: Banco de dados carregado" );
  43.         else print( "[ AVISO ]: Erro ao carregar o banco de dados" ) , SendRconCommand( "exit" );
  44.  
  45.     return true ;
  46. }
  47.  
  48. public OnPlayerConnect ( playerid ) {
  49.  
  50.     new Row, Field, xCelulas [ 70 ] ;
  51.  
  52.     cache_get_data ( Row, Field, xConexao ) ;
  53.  
  54.     format( xCelulas, 70 , "SELECT * FROM `contas` WHERE `Nome` = '%s'" , Nome ( playerid ) );
  55.     mysql_function_query ( xConexao, xCelulas, true, "xPlayerLogin", "i", playerid ) ;
  56.     return 1;
  57. }
  58.  
  59. public xPlayerLogin ( playerid ) {
  60.  
  61.     new Row, Field, xCelulas [ 332 ] ;
  62.  
  63.     cache_get_data ( Row, Field, xConexao ) ;
  64.  
  65.     if ( Row ) {
  66.    
  67.         format ( xCelulas, 332, "{7CFC00}» {DCDCDC}Bem vindo(a), Digite sua senha abaixo para logar{7CFC00}«\n\n                         {7CFC00}» {DCDCDC}Usuário: {1E90FF}%s {7CFC00}«\n\n                         {7CFC00}» {DCDCDC}Status: {48D1CC}Registrada {7CFC00}«\n\n{7CFC00}» %s {DCDCDC}Digite uma senha para logar em nosso servidor {7CFC00}«", Nome ( playerid ) ) ;
  68.         ShowPlayerDialog ( playerid, xLogin, DIALOG_STYLE_INPUT, "» Login «", xCelulas, "Logar", "Sair");
  69.     }
  70.     else {
  71.    
  72.         SendClientMessage ( playerid, -1, "   *   Você não está registrado em nosso servidor, vá até o site e se registre" ) ;
  73.         SendClientMessage ( playerid, -1, "Acesse: www.forum.sa-mp.com" ) ;
  74.         Kick ( playerid ) ;
  75.     }
  76.     return true ;
  77. }
  78. public VerificouLogin ( playerid ) {
  79.  
  80.     new Row, Field, xCelulas [ 332 ] ;
  81.  
  82.     cache_get_data ( Row, Field, xConexao ) ;
  83.  
  84.     if ( Row ) {
  85.    
  86.         SendClientMessage ( playerid, -1, "Logado com Sucesso" ) ;
  87.         SetSpawnInfo( playerid, 0, 230, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0 );
  88.         SpawnPlayer ( playerid ) ;
  89.     }
  90.     else {
  91.    
  92.         format ( xCelulas, 332, "{7CFC00}» {DCDCDC}Bem vindo(a), Digite sua senha abaixo para logar{7CFC00}«\n\n                         {7CFC00}» {DCDCDC}Usuário: {1E90FF}%s {7CFC00}«\n\n                         {7CFC00}» {DCDCDC}Status: {48D1CC}Registrada {7CFC00}«\n\n{7CFC00}» %s {DCDCDC}Digite uma senha para logar em nosso servidor {7CFC00}«", Nome ( playerid ) ) ;
  93.         ShowPlayerDialog ( playerid, xLogin, DIALOG_STYLE_INPUT, "» Login «", xCelulas, "Logar", "Sair");
  94.         SendClientMessage ( playerid, -1, "[ ERRO ]: Senha Incorreta" ) ;
  95.     }
  96.     return true ;
  97. }
  98.  
  99. public OnDialogResponse ( playerid, dialogid, response, listitem, inputtext [ ] ) {
  100.  
  101.     switch ( dialogid ) {
  102.    
  103.         case xLogin: {
  104.        
  105.             new Str [ 128 ]  ;
  106.             format ( Str, 128, "SELECT * FROM contas WHERE Nome = '%s' AND Senha ='%s' LIMIT 1", Nome ( playerid ), inputtext ) ;
  107.             mysql_function_query ( xConexao, Str, true, "VerificouLogin", "i", playerid ) ;
  108.         }
  109.     }
  110.     return true ;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement