JuanStone

FS By JuanStone

Apr 30th, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <Dini>
  8.  
  9. #define Dialogo_Registro 2
  10. #define Dialogo_Ingreso 1
  11.  
  12. enum Datos
  13. {
  14. Registrado, Logueado, ContraFail, Muertes, Matados
  15. };
  16.  
  17. new PlayerInfo[ MAX_PLAYERS ][ Datos ];
  18.  
  19. new Nombre [ MAX_PLAYER_NAME ];
  20.  
  21. new datos [ 356 ];
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25. SendDeathMessage(INVALID_PLAYER_ID,playerid, 200);
  26.  
  27. GetPlayerName ( playerid, Nombre , sizeof( Nombre ) );
  28.  
  29. format( datos, sizeof ( datos ), "files/users/%s.ini", Nombre);
  30.  
  31. if ( !dini_Exists ( datos ) )
  32. {
  33. ShowPlayerDialog(playerid, Dialogo_Registro, DIALOG_STYLE_INPUT, "Register", "Welcome choose a password\nRegister to save your data" , "accept", "exit");
  34. }
  35. else
  36. {
  37. ShowPlayerDialog(playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Welcome back","Enter your password\nto load your data." , "accept", "exit" );
  38. }
  39. return 1;
  40. }
  41.  
  42. public OnPlayerDisconnect(playerid, reason)
  43. {
  44. GuardarDatos ( playerid );
  45. return 1;
  46. }
  47.  
  48. public OnPlayerDeath(playerid, killerid, reason)
  49. {
  50. SendDeathMessage(killerid, playerid, reason);
  51.  
  52. if(killerid != INVALID_PLAYER_ID)
  53. {
  54. PlayerInfo[ killerid ][ Matados ] ++;
  55. }
  56. PlayerInfo[ playerid ][ Muertes ] ++;
  57. return 1;
  58. }
  59.  
  60. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  61. {
  62. if ( dialogid == Dialogo_Registro )
  63. {
  64. if (!response) return SendClientMessage(playerid, -1, "Register Cancelled." );
  65.  
  66. GetPlayerName ( playerid, Nombre, sizeof ( Nombre ) );
  67.  
  68. new string [ 256 ];
  69.  
  70. format ( string , sizeof ( string ), "files/users/%s.ini", Nombre);
  71.  
  72. dini_Create ( string );
  73.  
  74. dini_Set ( string, "Name", Nombre );
  75. dini_Set ( string, "Password", inputtext );
  76. dini_Set ( string, "Registrado", PlayerInfo[ playerid ][ Registrado ] );
  77. dini_Set ( string, "Matados", PlayerInfo[ playerid ][ Matados ] );
  78. dini_Set ( string, "Muertes", PlayerInfo[ playerid ][ Muertes ] );
  79. dini_Set ( string, "Money", PlayerInfo[ playerid ][ Registrado ] );
  80.  
  81. dini_IntSet ( string, "Matados", 0);
  82. dini_IntSet ( string, "Muertes", 0);
  83. ResetPlayerMoney( playerid );
  84.  
  85. SendClientMessage(playerid, -1, "[Info]: Your account has been successfully created." );
  86.  
  87. PlayerInfo[ playerid ][ Registrado ] = 1;
  88. PlayerInfo[ playerid ][ Logueado ] = 1;
  89. dini_IntSet ( string, "Registrado", PlayerInfo[ playerid ][ Registrado ] );
  90. }
  91.  
  92. if ( dialogid == Dialogo_Ingreso )
  93. {
  94. new string[ 168 ], ipod[ 168 ], istring[ 128 ];
  95.  
  96. if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Welcome back","Enter your password\nto load your data." , "accept", "exit" );
  97.  
  98. if (!response) return ShowPlayerDialog(playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Welcome back","Enter your password\nto load your data." , "accept", "exit" );
  99.  
  100. GetPlayerName( playerid , Nombre , sizeof ( Nombre ) );
  101.  
  102. format ( string, sizeof ( string ), "files/users/%s.ini", Nombre);
  103.  
  104. format ( ipod , sizeof ( ipod ), "%s", dini_Get( string, "Password"));
  105.  
  106. if ( !strcmp ( inputtext, ipod ) )
  107. {
  108. PlayerInfo[ playerid ][ Logueado ] = 1;
  109. CargarDatos ( playerid );
  110. }
  111. else
  112. {
  113. PlayerInfo[ playerid ][ ContraFail]++;
  114.  
  115. if ( PlayerInfo[ playerid ][ ContraFail ] == 5)
  116. {
  117. format( istring, sizeof ( istring ), "%s It has been kickeado (Incorrect logins)", Nombre );
  118. SendClientMessageToAll( -1, istring );
  119. Kick ( playerid );
  120. }
  121. return ShowPlayerDialog ( playerid, Dialogo_Ingreso, DIALOG_STYLE_INPUT, "Incorrect password", "Welcome back\n enter your password.", "accept", "exit" );
  122. }
  123. }
  124. return 1;
  125. }
  126.  
  127. forward GuardarDatos ( playerid );
  128.  
  129. public GuardarDatos ( playerid )
  130. {
  131. GetPlayerName ( playerid, Nombre, sizeof ( Nombre ) );
  132.  
  133. format ( datos, sizeof ( datos), "files/users/%s.ini", Nombre );
  134.  
  135. if ( !dini_Exists ( datos ) )
  136. {
  137. }
  138. else
  139. {
  140. dini_IntSet ( datos, "Matados", PlayerInfo[ playerid ][ Matados ] );
  141. dini_IntSet ( datos, "Muertes", PlayerInfo[ playerid ][ Muertes ] );
  142. dini_IntSet ( datos, "Money", GetPlayerMoney( playerid ) );
  143.  
  144. SendClientMessage(playerid, -1, "registered correctly!.");
  145.  
  146. PlayerPlaySound( playerid, 1057, 0.0, 0.0, 0.0 );
  147. }
  148. return 1;
  149. }
  150.  
  151. forward CargarDatos ( playerid );
  152.  
  153. public CargarDatos ( playerid )
  154. {
  155. format ( datos, sizeof ( datos ), "files/users/%s.ini", Nombre );
  156.  
  157. if ( !dini_Exists ( datos ) )
  158. {
  159. }
  160. else
  161. {
  162. SetPlayerScore(playerid, dini_Int(datos, "Matados" ) );
  163. PlayerInfo[ playerid ][ Muertes ] = dini_Int ( datos, "Muertes" );
  164. GivePlayerMoney( playerid, dini_Int( datos, "Money" ) );
  165.  
  166. SendClientMessage(playerid, -1, "Logged correctly!. Welcome back.");
  167. }
  168. PlayerPlaySound( playerid, 1057, 0.0, 0.0, 0.0 );
  169. return 1;
  170. }
  171.  
  172. CMD:registro(playerid, params[])
  173. {
  174. if ( PlayerInfo[ playerid ][ Registrado ] == 0 )
  175. {
  176. ShowPlayerDialog(playerid, Dialogo_Registro, DIALOG_STYLE_INPUT, "Register", "Welcome choose a password\nRegister to save your data" , "accept", "exit");
  177. }
  178. else
  179. {
  180. SendClientMessage ( playerid, -1, "[ERROR]: You are already registered." );
  181. }
  182. return 1;
  183. }
Advertisement
Add Comment
Please, Sign In to add comment