Advertisement
Guest User

Sanady Reg

a guest
May 29th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. //
  2. // Sanady Registration System 1.0(2012)(c)
  3. //
  4.  
  5. #include <a_samp>
  6. #include <dini>
  7. #include <dudb>
  8.  
  9. #pragma unused ret_memcpy
  10.  
  11. #define COLOR_GREY 0xAFAFAFAA
  12. #define COLOR_GREEN 0x33AA33AA
  13. #define COLOR_ORANGE 0xFF9900AA
  14. #define COLOR_RED 0xAA3333AA
  15. #define COLOR_YELLOW 0xFFFF00AA
  16.  
  17. #define ERROR 0xFF0000AA
  18. #define SYSTEM 0x375FFFFF
  19. #define blue 0x375FFFFF
  20. #define red 0xFF0000FF
  21. #define white 0xFFFFFFFF
  22. #define green 0x33FF33FF
  23. #define yellow 0xFFFF00FF
  24. #define grey 0xC0C0C0FF
  25. #define orange 0xFF9900FF
  26. #define pink 0xFF66FFFF
  27.  
  28. #define embed_blue "{00C0FF}"
  29. #define embed_red "{FF0000}"
  30. #define embed_white "{FFFFFF}"
  31. #define embed_green "{33FF33}"
  32. #define embed_yellow "{E8D04C}"
  33. #define embed_grey "{C0C0C0}"
  34. #define embed_orange "{FF9900}"
  35. #define embed_pink "{FF66FF}"
  36. #define embed_lblue "{00AFFF}"
  37. #define embed_sw "{ED136A}"
  38.  
  39. #define color_ok 0xFFFF00FF
  40. #define color_wa 0xFF9900AA
  41.  
  42.  
  43. #define COL_GREEN "{6EF83C}" // GREEN color in HEX ( USED )
  44. #define COL_RED "{F81414}" // RED color in HEX ( USED )
  45. #define COL_BLUE "{00C0FF}" // BLUE color in HEX ( USED )
  46.  
  47. #define MAX_FAIL_LOGINS 3
  48.  
  49. enum PlayerInfo
  50. {
  51. pLevel,
  52. pMoney,
  53. pScore,
  54. pKills,
  55. pFailLogins,
  56. pDeaths,
  57. }
  58. new pInfo[MAX_PLAYERS][PlayerInfo];
  59. new gPlayerLogged[MAX_PLAYERS];
  60.  
  61. #define SERVER_USER_FILE "SanadyReg/Accounts/%s.ini"
  62.  
  63. public OnFilterScriptInit()
  64. {
  65. print("\n--------------------------------------");
  66. print(" Sanady Registration System 1.0");
  67. print("--------------------------------------\n");
  68. return 1;
  69. }
  70.  
  71. public OnFilterScriptExit()
  72. {
  73. return 1;
  74. }
  75.  
  76.  
  77. main()
  78. {
  79. print("\n----------------------------------");
  80. print(" Sanady Registration System 1.0");
  81. print("----------------------------------\n");
  82. }
  83.  
  84.  
  85. public OnGameModeInit()
  86. {
  87. return 1;
  88. }
  89.  
  90. public OnGameModeExit()
  91. {
  92. return 1;
  93. }
  94.  
  95. public OnPlayerRequestClass(playerid, classid)
  96. {
  97. return 1;
  98. }
  99.  
  100. public OnPlayerConnect(playerid)
  101. {
  102. gPlayerLogged[playerid] = 0;
  103. new file[256],string[226],name[MAX_PLAYER_NAME];
  104. GetPlayerName(playerid, name, sizeof(name));
  105. format(file, sizeof(file), SERVER_USER_FILE, name);
  106.  
  107. if (!dini_Exists(file))
  108. {
  109. format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password.", name, playerid);
  110. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{FFFFFF}Registration", string, "Register", "Leave");
  111. }
  112. if(fexist(file))
  113. {
  114. format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.You're registered\n\nPlease log in by inputting your password.",name, playerid);
  115. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", string, "Login", "Leave");
  116. }
  117. TogglePlayerSpectating(playerid,0);
  118. return 1;
  119. }
  120.  
  121. public OnPlayerDisconnect(playerid, reason)
  122. {
  123. new file[256],name[MAX_PLAYER_NAME];
  124. GetPlayerName(playerid, name, sizeof(name));
  125. format(file, sizeof(file), SERVER_USER_FILE, name);
  126.  
  127. if(gPlayerLogged[playerid] == 1)
  128. {
  129. dini_IntSet(file, "Score", pInfo[playerid][pScore]);
  130. dini_IntSet(file, "Money", pInfo[playerid][pMoney]);
  131. dini_IntSet(file, "AdminLevel",pInfo[playerid][pLevel]);
  132. dini_IntSet(file, "Kills",pInfo[playerid][pKills]);
  133. dini_IntSet(file, "Deaths",pInfo[playerid][pDeaths]);
  134. }
  135. gPlayerLogged[playerid] = 0;
  136. return 1;
  137. }
  138.  
  139. public OnPlayerSpawn(playerid)
  140. {
  141. return 1;
  142. }
  143.  
  144. public OnPlayerDeath(playerid, killerid, reason)
  145. {
  146. pInfo[killerid][pKills] ++;
  147. pInfo[playerid][pDeaths] ++;
  148. return 1;
  149. }
  150.  
  151. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  152. {
  153. if (dialogid == 1)
  154. {
  155. new file[256],name[MAX_PLAYER_NAME],string[158];
  156. GetPlayerName(playerid, name, sizeof(name));
  157. format(file, sizeof(file), SERVER_USER_FILE, name);
  158. if(!response) return Kick(playerid);
  159. if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{FFFFFF}Registration", ""COL_RED"[ERROR]{FFFFFF}Please input password!", "Register", "Leave");
  160. dini_Create(file);
  161. dini_IntSet(file, "Password", udb_hash(inputtext));
  162. dini_IntSet(file, "AdminLevel",pInfo[playerid][pLevel] = 0);
  163. dini_IntSet(file, "Money",pInfo[playerid][pMoney] = 500);
  164. dini_IntSet(file, "Score",pInfo[playerid][pScore] = 0);
  165. dini_IntSet(file, "Kills",pInfo[playerid][pKills] = 0);
  166. dini_IntSet(file, "Deaths",pInfo[playerid][pDeaths] = 0);
  167.  
  168. format(string,sizeof(string),"{FFFFFF}You have been {8CF051}succesfully {FFFFFF}registred\n\n\nAlso you need to log in.Press button "COL_BLUE"continue {FFFFFF}to log in!");
  169. ShowPlayerDialog(playerid, 3,DIALOG_STYLE_MSGBOX,"{FFFFFF}Welcome",string,"Continue","");
  170.  
  171. }
  172. if (dialogid == 2)
  173. {
  174. new name[MAX_PLAYER_NAME], file[256],string[227];
  175. GetPlayerName(playerid, name, sizeof(name));
  176. format(file, sizeof(file), SERVER_USER_FILE, name);
  177. if(!response) return Kick(playerid);
  178. if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFFFF}", ""COL_RED"[ERROR]{FFFFFF}Please input right password!", "Login", "Leave");
  179. new tmp;
  180. tmp = dini_Int(file, "Password");
  181. if(udb_hash(inputtext) != tmp)
  182. {
  183. format(string, sizeof (string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.You're registered\n\nPlease log in by inputting your password.\n"embed_red"Wrong password!", name,playerid);
  184. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD,"{FFFFFF}Login", string,"Login","Kick");
  185. pInfo[playerid][pFailLogins]++;
  186. if(pInfo[playerid][pFailLogins] >= MAX_FAIL_LOGINS)
  187. {
  188. SendClientMessage(playerid, red, "[ERROR]"embed_grey"Failed to login!");
  189. Kick(playerid);
  190. return 1;
  191. }
  192. }
  193. else
  194. {
  195. gPlayerLogged[playerid] = 1;
  196. pInfo[playerid][pLevel] = dini_Int(file, "AdminLevel");
  197. SetPlayerScore(playerid, pInfo[playerid][pScore]);
  198. GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
  199. pInfo[playerid][pKills] = dini_Int(file, "Kills");
  200. pInfo[playerid][pDeaths] = dini_Int(file, "Deaths");
  201. SendClientMessage(playerid,0xFFFFFFF,""embed_blue"[INFO]{FFFFFF}You have been {8CF051}succesfully {FFFFFF}logged in.");
  202. }
  203. }
  204. if (dialogid == 3)
  205. {
  206. new string[134],name[MAX_PLAYER_NAME];
  207. GetPlayerName(playerid,name,sizeof(name));
  208. format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.You're registered\n\nPlease log in by inputting your password.", name, playerid);
  209. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", string, "Login", "Leave");
  210. }
  211. return 1;
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement