Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.09 KB | None | 0 0
  1. /*
  2. I would appreciate it if you add my name in the credits if you use this FS in your server
  3. ______ ____ ______ ____ ___
  4. | | | /\ | | | | |__|
  5. | | XCZ<XCX<C|---- /--\ | |---| |---- | \
  6. _|____| |____/ \ | | | |____ | \
  7. DARE TO DIE
  8.  
  9. Notes:
  10. 1. You need 'dRegis' folder in the scriptfiles folder.
  11. 2. Donot Remove these credits.
  12. 3. You can edit it for your own purpose but you are not allowed to realease this without my permission.
  13. */
  14. //********************************INCLUDES************************************//
  15. //============================================================================//
  16. #include <a_samp>
  17. #include <dini>
  18. #include <dutils>
  19. //**********************************COLORS************************************//
  20. //============================================================================//
  21. #define COLOR_MESSAGE 0x00C7FFAA
  22. #define COLOR_LIGHTBLUE 0x33CCFFAA
  23. #define COLOR_BLUE 0x0000BBAA
  24. #define COLOR_GREY 0xAFAFAFAA
  25. #define COLOR_GREEN 0x33AA33AA
  26. #define COLOR_RED 0xFF0000FF
  27. #define COLOR_YELLOW 0xFFFF0088
  28. #define COLOR_ORANGE 0xFF9900AA
  29. #define COLOR_WHITE 0xFFFFFFAA
  30. #define COLOR_LIGHTRED 0xFF6347AA
  31. #define COLOR_LIGHTBLUE 0x33CCFFAA
  32. #define COLOUR_LIGHTBLUE 0x33CCFFAA
  33. #define COLOR_LIGHTGREEN 0x9ACD32AA
  34. #define COLOR_GREEN2 0x33FF33AA
  35. #define COLOR_ERROR 0xFF0000AA
  36. #define COLOR_MSG 0x00FFFFFF
  37. #define COLOR_PINK 0xFF66FFAA
  38. #define COLOR_WHITE 0xFFFFFFAA
  39. #define COLOR_GREEN1 0x33AA33AA
  40. #define COLOR_BROWN 0xA52A2AAA
  41. #define COLOR_PURPLE 0x800080AA
  42. #define COLOR_BLACK 0x000000AA
  43. #define COLOR_GREEN1 0x33AA33AA
  44. //**********************************DIALOGS***********************************//
  45. //============================================================================//
  46. #define REGISTERDIALOG 500
  47. #define LOGINDIALOG 501
  48. #define STATS 502DFASD
  49. #define AUTOLOGIN 503
  50. //*******************************DEFINE DCMD**********************************//
  51. //============================================================================//
  52. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  53. //**********************************ENUM*************************************//
  54. //============================================================================//
  55. enum PlayerData
  56. {
  57. Name[MAX_PLAYER_NAME],
  58. IP[16],
  59. Registered,
  60. Password,
  61. LoggedIn,
  62. Autologin,
  63. Kills,
  64. Deaths
  65. };
  66. //***********************************NEW**************************************//
  67. //============================================================================//
  68. new PlayerInfo[MAX_PLAYERS][PlayerData];
  69. //*******************************CALLBACKS************************************//
  70. //============================================================================//
  71. public OnFilterScriptInit()
  72. {
  73. printf("******************************************************************");
  74. printf("---deather's Dialog Registration System by 'Deather' has been loaded---");
  75. printf("******************************************************************");
  76. return 1;
  77. }
  78. //============================================================================//
  79. public OnPlayerConnect(playerid)
  80. {
  81. new playername[MAX_PLAYER_NAME];
  82. new string1[64];
  83. GetPlayerName(playerid, playername, sizeof(playername));
  84. format(string1, sizeof(string1), "--%s (ID: %d) has joined the server--", playername, playerid);
  85. SendClientMessageToAll(COLOR_LIGHTBLUE, string1);
  86.  
  87. new file[128];
  88. format(file, sizeof(file), "dRegis/%s.ini", pName(playerid));
  89.  
  90. PlayerInfo[playerid][Name] = playername;
  91. PlayerInfo[playerid][IP] = 0;
  92. PlayerInfo[playerid][Registered] = 0;
  93. PlayerInfo[playerid][LoggedIn] = 0;
  94. PlayerInfo[playerid][Autologin] = 0;
  95. PlayerInfo[playerid][Password] = 0;
  96. PlayerInfo[playerid][Password] = dini_Int(file,"Password");
  97. PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
  98. PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
  99.  
  100. if(userfile(playerid))
  101. {
  102. new RegIP_hash;
  103. RegIP_hash = num_hash(dini_Get(file,"Ip"));
  104. new playerIp[16];
  105. GetPlayerIp(playerid,playerIp,sizeof(playerIp));
  106. new playerIP_hash;
  107. playerIP_hash = num_hash(playerIp);
  108.  
  109. if(PlayerInfo[playerid][Autologin] == 1)
  110. {
  111. if(playerIP_hash == RegIP_hash)
  112. {
  113. Autolog(playerid);
  114. new autolog[128];
  115. ShowPlayerDialog(playerid, AUTOLOGIN, DIALOG_STYLE_MSGBOX,"Deather's AutoLogin",autolog,"Ok","Cancel");
  116. format(autolog, sizeof(autolog), "Welcome back %s. You have been automatically logged in.", pName(playerid));
  117. }
  118. }
  119. else
  120. {
  121. ShowPlayerDialog(playerid, LOGINDIALOG, DIALOG_STYLE_INPUT, "Deather's Login", "Enter your Password to login to your account", "Login", "Cancel");
  122. new msg2[128];
  123. format(msg2, sizeof(msg2), "Welcome back. Your account is registered. Please Login.");
  124. SendClientMessage(playerid, COLOR_LIGHTGREEN, msg2);
  125. }
  126. }
  127. else
  128. {
  129. ShowPlayerDialog(playerid, REGISTERDIALOG ,DIALOG_STYLE_INPUT, "Deather's Registration", "Please enter a New Password and Register with our server.\n And do remember this password for your future Logins","Register","Cancel");
  130. new msg3[128];
  131. format(msg3, sizeof(msg3), "Welcome to our server %s. You are not registered yet. Please reigster before you continue.", pName(playerid));
  132. SendClientMessage(playerid, COLOR_LIGHTGREEN, msg3);
  133. }
  134. return 1;
  135. }
  136. //============================================================================//
  137. public OnPlayerDisconnect(playerid, reason)
  138. {
  139.  
  140. new playerName[MAX_PLAYER_NAME], string[56];
  141. GetPlayerName(playerid, playerName, sizeof(playerName));
  142. switch(reason)
  143. {
  144. case 0: format(string, sizeof(string), "%s has left the server. (Ping Timeout)", playerName);
  145. case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", playerName);
  146. case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", playerName);
  147. }
  148. SendClientMessageToAll(COLOR_GREY, string);
  149.  
  150. new pfile[256];
  151. format(pfile,sizeof(pfile),"dRegis/%s.ini", pName(playerid));
  152. dini_IntSet(pfile,"Kills",PlayerInfo[playerid][Kills]);
  153. dini_IntSet(pfile,"Deaths",PlayerInfo[playerid][Deaths]);
  154.  
  155. return 1;
  156. }
  157. //============================================================================//
  158. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  159. {
  160. new playername[MAX_PLAYERS];
  161. GetPlayerName(playerid, playername, sizeof(playername));
  162. if(dialogid == REGISTERDIALOG)
  163. {
  164. if(response == 1)
  165. {
  166. if(!inputtext[0])
  167. {
  168. ShowPlayerDialog(playerid, REGISTERDIALOG ,DIALOG_STYLE_INPUT, "Deather's Registration", "Enter the password for your account.","Register","Cancel");
  169. return 1;
  170. }
  171.  
  172. new pfile[128];
  173. format(pfile, sizeof(pfile), "dRegis/%s.ini", pName(playerid));
  174.  
  175. new Ip[16];
  176. GetPlayerIp(playerid,Ip,sizeof(Ip));
  177. new password = num_hash(inputtext);
  178. PlayerInfo[playerid][Password] = password;
  179. PlayerInfo[playerid][Registered] = 1;
  180. PlayerInfo[playerid][LoggedIn] = 1;
  181. dini_Create(pfile);
  182. dini_IntSet(pfile,"Password",PlayerInfo[playerid][Password]);
  183. dini_Set(pfile,"Ip",Ip);
  184. PlayerInfo[playerid][Kills] = 0;
  185. PlayerInfo[playerid][Deaths] = 0;
  186. dini_IntSet(pfile,"Kills",0);
  187. dini_IntSet(pfile,"Deaths",0);
  188. SendClientMessage(playerid, COLOR_GREY, "Registration Done");
  189. SendClientMessage(playerid, COLOR_GREY, "Welcome to the server.");
  190.  
  191. new string[256];
  192. format(string, sizeof(string), "Your New Password is: \'%s\'.", inputtext);
  193. SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
  194. }
  195. if(response == 0)
  196. {
  197. Kick(playerid);
  198. new string[256];
  199. format(string, sizeof(string),"%s hasn't registered and so have been kicked from the server",playername);
  200. SendClientMessageToAll(COLOR_RED, string);
  201. }
  202. }
  203.  
  204. if(dialogid == LOGINDIALOG)
  205. {
  206. if(response == 1)
  207. {
  208. new password = num_hash(inputtext);
  209. if(PlayerInfo[playerid][Password] == password)
  210. Autolog(playerid);
  211. SendClientMessage(playerid, COLOR_LIGHTGREEN, "Welcome back to the server. You have successfully been logged in.");
  212. }
  213. else
  214. {
  215. Kick(playerid);
  216. new string1[256];
  217. format(string1, sizeof(string1),"%s hasn't logged in and so have been kicked from the server",playername);
  218. SendClientMessageToAll(COLOR_RED, string1);
  219. }
  220. }
  221. if(response == 0)
  222. {
  223. Kick(playerid);
  224. new string1[256];
  225. format(string1, sizeof(string1),"%s hasn't logged in and so have been kicked from the server",playername);
  226. SendClientMessageToAll(COLOR_RED, string1);
  227. }
  228. return 1;
  229. }
  230. //============================================================================//
  231. public OnPlayerDeath(playerid, killerid, reason)
  232. {
  233. new pname[24], kfile[50], pfile[50], kname[24];
  234. GetPlayerName(playerid, pname, sizeof(pname));
  235. GetPlayerName(killerid, kname, sizeof(kname));
  236. format(kfile, sizeof(kfile), "dRegis/%s.ini", kname);
  237. format(pfile, sizeof(pfile), "dRegis/%s.ini", pname);
  238.  
  239. if(killerid == INVALID_PLAYER_ID)
  240. {
  241. SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
  242. PlayerInfo[playerid][Deaths]++;
  243. dini_IntSet(pfile, "Deaths", PlayerInfo[playerid][Deaths]);
  244. }
  245. else
  246. {
  247. SendDeathMessage(killerid, playerid, reason);
  248. PlayerInfo[killerid][Kills]++;
  249. PlayerInfo[playerid][Deaths]++;
  250. dini_IntSet(pfile, "Deaths", PlayerInfo[playerid][Deaths]);
  251. dini_IntSet(pfile, "Kills", PlayerInfo[killerid][Kills]);
  252. }
  253. return 1;
  254. }
  255. //============================================================================//
  256. public OnPlayerClickPlayer(playerid,clickedplayerid,source)
  257. {
  258. if(clickedplayerid == playerid)
  259. {
  260. new statstr[500];
  261. format(statstr, sizeof(statstr), "Name: %s\nIP: %d\nKills: %d\nDeaths: %d",PlayerInfo[playerid][Name],PlayerInfo[playerid][IP],PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths]);
  262. ShowPlayerDialog(playerid, STATS, DIALOG_STYLE_MSGBOX,"Player Stats", statstr, "Ok", "Cancel");
  263. }
  264. return 1;
  265. }
  266. //**********************************STOCKS************************************//
  267. //============================================================================//
  268. stock pName(playerid)
  269. {
  270. new name[MAX_PLAYER_NAME];
  271. GetPlayerName(playerid, name, sizeof(name));
  272. return name;
  273. }
  274. //============================================================================//
  275. stock userfile(playerid)
  276. {
  277. new FilePath[128];
  278. format(FilePath, sizeof(FilePath), "dRegis/%s.ini", pName(playerid));
  279.  
  280. if(dini_Exists(FilePath)) return 1;
  281.  
  282. return 0;
  283. }
  284. //============================================================================//
  285. stock Autolog(playerid)
  286. {
  287. new file[128];
  288. format(file, sizeof(file), "dRegis/%s.ini", pName(playerid));
  289.  
  290. PlayerInfo[playerid][LoggedIn] = 1;
  291. PlayerInfo[playerid][Registered] = 1;
  292. PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
  293. PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
  294. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement