Guest User

Untitled

a guest
Jul 30th, 2020
26
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2.  
  3. #include <a_mysql>
  4. new SQL = -1, gQuery[256];
  5.  
  6. #define function%0(%1) forward %0(%1); public %0(%1)
  7. #define SCM SendClientMessage
  8.  
  9. enum pInfo{
  10. pSQLID,
  11. pName[MAX_PLAYER_NAME],
  12. pPassword[32],
  13. pEmail[32],
  14. pGender
  15. }
  16. new PlayerInfo[MAX_PLAYERS][pInfo];
  17.  
  18. enum {
  19. // Register
  20. DIALOG_REGISTER,
  21. DIALOG_EMAIL,
  22. DIALOG_GENDER,
  23.  
  24. // Login
  25. DIALOG_LOGIN
  26. }
  27.  
  28. #define Script "#1"
  29.  
  30. main() {print("Gamemode-ul este in curs de procesare..."); }
  31.  
  32. public OnGameModeInit()
  33. {
  34. SQL = mysql_connect("localhost", "root", "chroma", "");
  35.  
  36. // Don't use these lines if it's a fliterscript
  37. SetGameModeText("Chroma");
  38. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  39. return 1;
  40. }
  41.  
  42. public OnPlayerRequestClass(playerid, classid)
  43. {
  44. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  45. SetPlayerCameraPos(playerid,1958.3783, 1343.1572, 15.3746);
  46. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  47. return 1;
  48. }
  49.  
  50. public OnPlayerConnect(playerid) {
  51. gQuery[0] = EOS;
  52. mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM 'users' WHERE 'Name' '='%s LIMIT 1", GetName(playerid));
  53. mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
  54. return 1;
  55. }
  56.  
  57. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  58. switch(dialogid) {
  59. case DIALOG_REGISTER: {
  60. if(!response)
  61. return Kick(playerid);
  62.  
  63. if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
  64. return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere / maxim 32:", "Select", "Cancel");
  65.  
  66. gQuery[0] = EOS;
  67. mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO 'users' ('Name', 'Password') VALUES ('%s', '%s')", GetName(playerid), inputtext);
  68. mysql_tquery(SQL, gQuery, "insertaccount", "i", playerid);
  69.  
  70. gString[0] = EOS;
  71. format(gString, sizeof(gString), "Parola ta contine %d caractere.", strlen(inputtext));
  72. SCM(playerid, -1, gString);
  73.  
  74. format(PlayerInfo[playerid][pPassword], 32, inputtext);
  75.  
  76. ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");
  77. }
  78. case DIALOG_EMAIL: {
  79. if(!response)
  80. return Kick(playerid);
  81.  
  82. if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
  83. return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere / maxim 32:", "Select", "Cancel");
  84.  
  85. gQuery[0] = EOS;
  86. mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE 'users' SET 'Email'='%s' WHERE 'ID'='%d'", inputtext, PlayerInfo[playerid][pSQLID]);
  87. mysql_tquery(SQL, gQuery, );
  88.  
  89. gString[0] = EOS;
  90. format(gString, sizeof(gString), "Email setat: %s", inputtext);
  91. SCM(playerid, -1, gString);
  92.  
  93. format(PlayerInfo[playerid][pEmail], 32, inputtext);
  94.  
  95. ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza-ti sex-ul:", "Masculin", "Feminin");
  96. }
  97. case DIALOG_GENDER: {
  98. switch(response) {
  99. case 0: {
  100. PlayerInfo[playerid][pGender] = 1;
  101. SCM(playerid, -1, "Sex setat: Feminin");
  102. }
  103. case 1: {
  104. PlayerInfo[playerid][pGender] = 0;
  105. SCM(playerid, -1, "Sex setat: Masculin");
  106. }
  107. }
  108.  
  109. gQuery[0] = EOS;
  110. mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE 'users' SET 'Gender'='%d' WHERE 'ID'='%d'", inputtext, PlayerInfo[playerid][pGender],PlayerInfo[playerid][pSQLID]);
  111. mysql_tquery(SQL, gQuery, "", "");
  112.  
  113. SpawnPlayer(playerid);
  114. }
  115. case DIALOG_LOGIN: {
  116. if(!response)
  117. return Kick(playerid);
  118.  
  119. }
  120.  
  121. return 1;
  122. }
  123.  
  124. function insertaccount(playerid) {
  125. PlayerInfo[playerid][pSQLID] = cache_insert_id();
  126. printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
  127. return 1;
  128. }
  129. function checkAccount(playerid) {
  130. switch(cache_num_rows()) {
  131. case 0:ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere / maxim 32 caractere):", "Select", "Cancel");
  132. case 1:ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea loga:", "Select", "Cancel");
  133. }
  134. return 1;
  135. }
  136.  
  137.  
  138. stock GetName(playerid) {
  139. new playerName[MAX_PLAYER_NAME];
  140. GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
  141. return playerName;
  142. }
RAW Paste Data