roscatu

Untitled

Jun 6th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. #pragma tabsize 0
  2.  
  3. // ============================ INCLUDES ====================================================
  4.  
  5. #include <a_samp>
  6. #include <a_players>
  7. #include <a_mysql>
  8. #include <zcmd>
  9. #include <sscanf2>
  10. #include <YSI>
  11.  
  12. // ===============================DEFINE=====================================================
  13.  
  14. #define COLOR_WHITE 0xFFFFFFAA
  15. #define SCM SendClientMessage
  16. #define SCMALL SendClientMessageToAll
  17.  
  18. // ======================= MYSQL CONNECT DETAILS ============================================
  19.  
  20. #define MYSQL_HOST "localhost"
  21. #define MYSQL_USER "root"
  22. #define MYSQL_DB "zp_hid3099"
  23. #define MYSQL_PASS "thisba"
  24.  
  25. new username_query[100],
  26. check_password[90];
  27.  
  28. new login_scm[120],
  29. login_dialog[120],
  30. register_dialog[120];
  31.  
  32. //========================= ENUMS ============================================================
  33.  
  34. enum
  35. {
  36. DIALOG_REGISTER,
  37. DIALOG_LOGIN,
  38. };
  39.  
  40.  
  41. // ===================================== STOCKS =========================================
  42. stock GetName(playerid)
  43. {
  44. new name[24];
  45. GetPlayerName(playerid, name, sizeof(name));
  46. return name;
  47. }
  48. // ============================ FUNCTIONS ===========================================================
  49.  
  50. // ========================= Public Factions Location Functions ==============================================
  51.  
  52. forward spwCivil(playerid);
  53. public spwCivil(playerid)
  54. {
  55. SetSpawnInfo( playerid, 0, 0, 1744.4681, -1862.5240, 13.5762, 354.0875, 0, 0, 0, 0, 0, 0 );
  56. SpawnPlayer(playerid);
  57. }
  58.  
  59. forward @Kick(playerid);
  60. @Kick(playerid) Kick(playerid);
  61.  
  62. forward @ban(playerid);
  63. @ban(playerid) Ban(playerid);
  64.  
  65. forward OnAccountCheck(playerid);
  66. public OnAccountCheck(playerid)
  67. {
  68. if(playerid != INVALID_PLAYER_ID)
  69. {
  70. new rows, fields;
  71. cache_get_data(rows, fields, 1);
  72. if(rows == 1)
  73. {
  74. format(login_dialog, sizeof(login_dialog), "{FFFFFF} Bine ai venit {221BE0}%s, {FFFFFF} Introdu {E01B6A} parola {FFFFFF} pentru a te loga:", GetName(playerid));
  75. ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_dialog, "Login", "Exit");
  76. spwCivil(playerid);
  77. }
  78. else
  79. {
  80. SendClientMessage(playerid,0xFF0000C8 , "{2641FE}[INDUNGI]{ffffff}Bine ai venit,raspunde la intrebari pentru a te inregistra.");
  81. format(register_dialog, sizeof(register_dialog), "{FFFFFF}Salut {221BE0} %s, {FFFFFF} Introdu {E01B6A} o parola {FFFFFF} pentru a te inregistra:", GetName(playerid));
  82. ShowPlayerDialog(playerid,DIALOG_REGISTER, DIALOG_STYLE_INPUT , "REGISTER", register_dialog, "Register", "Exit");
  83. }
  84. }
  85. }
  86.  
  87. forward CheckUserPassword(playerid);
  88. public CheckUserPassword(playerid)
  89. {
  90. new rows,fields;
  91. cache_get_data(rows, fields, 1);
  92.  
  93. if(rows == 1)
  94. {
  95. spwCivil(playerid);
  96. }
  97. else
  98. {
  99. format(login_scm, sizeof(login_scm), "[ACCOUNT] Parola gresita. Incearca din nou!");
  100. ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_scm, "Login", "Exit");
  101. }
  102. }
  103.  
  104. // ===================================================================================================
  105.  
  106. main()
  107. {
  108. print("\n----------------------------------");
  109. print(" IDG Romania V0.1");
  110. print("----------------------------------\n");
  111.  
  112. }
  113.  
  114. public OnGameModeInit()
  115. {
  116. print("\n------------------------");
  117. print(" IDG Register V0.1");
  118. print("------------------------\n");
  119.  
  120. SetGameModeText("IDG Romania V.1");
  121.  
  122. // ====================== MYSQL CONNECTED ================================================
  123.  
  124. if(mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS))
  125. {
  126. print("\n-------------------------------------------------");
  127. print(" Conexiunea la baza de date sa facut cu succes! ");
  128. print("---------------------------------------------------\n");
  129. }
  130. else
  131. {
  132. print("\n------------------------------------------");
  133. print(" Conectarea la baza de date nu a reusit! ");
  134. print("------------------------------------------\n");
  135. }
  136.  
  137. if(mysql_ping())
  138. {
  139. print("\n----------------------------------");
  140. print(" MySQL connection is still alive! ");
  141. print("----------------------------------\n");
  142. }
  143. if(!mysql_ping())
  144. {
  145. print("\n------------------------------");
  146. print(" MySQL connection is dead! ");
  147. print("------------------------------\n");
  148. }
  149.  
  150. mysql_debug(1);
  151. }
  152.  
  153. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  154. {
  155. if(dialogid == DIALOG_LOGIN)
  156. {
  157. if(!response)
  158. {
  159. Kick(playerid);
  160. }
  161. else
  162. {
  163. if (strlen(inputtext) < 5 )
  164. {
  165. format(login_scm, sizeof(login_scm), "{FFFFFF}Salut {221BE0}%s, {FFFFFF} Introdu {E01B6A} o parola {FFFFFF} pentru a te intra:", GetName(playerid));
  166. ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_scm, "Login", "Exit");
  167. }
  168. else if(strlen(inputtext) > 5)
  169. {
  170. mysql_format(1, check_password, "SELECT * FROM users WHERE username = '%s' AND password = '%s'", GetName(playerid),inputtext);
  171. mysql_function_query(1 , check_password, true, "CheckUserPassword", "", "");
  172. }
  173. else
  174. {
  175. format(login_scm, sizeof(login_scm), "{FFFFFF}Salut {221BE0}%s, {FFFFFF} Introdu {E01B6A} o parola {FFFFFF} pentru a te intra:", GetName(playerid));
  176. ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "LOGIN", login_scm, "Login", "Exit");
  177. }
  178. }
  179. }
  180. }
  181. // ========================= BASIC CALLBACKS =======================================================================
  182.  
  183. public OnPlayerRequestClass(playerid, classid)
  184. {
  185. SetPlayerPos(playerid, 1133.0504, -2038.4034, 69.0395);
  186. SetPlayerCameraPos(playerid, 1133.0504, -2038.4034, 69.0395);
  187. SetPlayerCameraLookAt(playerid, 1133.0504, -2038.4034, 69.0395);
  188.  
  189. mysql_format(1 ,username_query,"SELECT * FROM users WHERE username = '%s'", GetName(playerid));
  190. mysql_function_query(1 , username_query, true, "OnAccountCheck", "", "");
  191.  
  192. }
Add Comment
Please, Sign In to add comment