Advertisement
Guest User

Untitled

a guest
May 30th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.73 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dudb>
  3. #include <dini>
  4.  
  5. #define FILTERSCRIPT
  6. #if defined FILTERSCRIPT
  7.  
  8. #define Register 1
  9. #define Login 2
  10. #define WELCOME3 3
  11. #define WELCOME2 4
  12. #define WELCOME1 5
  13. #define Register1 6
  14. #define Register2 7
  15. #define SkinSave 8
  16. #define AutoLog 9
  17.  
  18. #define COLOR_GREEN 0x00FF00FF
  19. #define COLOR_RED 0xFF0000FF
  20. #define COLOR_RED2 0xA50047FF
  21. #define COLOR_GREEN2 0x18FF18FF
  22. #define COLOR_BLUE 0x0000FFFF
  23.  
  24. enum pInfo
  25. {
  26. Deaths,
  27. Kills,
  28. ServerTime
  29. }
  30. new PlayerInfo[MAX_PLAYERS][pInfo];
  31. new IsLogged[MAX_PLAYERS];
  32. new TimeTimer;
  33. new rip[MAX_PLAYERS][16];
  34. new Avisos[MAX_PLAYERS];
  35.  
  36. public OnFilterScriptInit()
  37. {
  38. print("\n--------------------------------------");
  39. print("------------------RankS-----------------");
  40. print("--------------------------------------\n");
  41. return 1;
  42. }
  43. #endif
  44.  
  45. public OnPlayerConnect(playerid)
  46. {
  47. TogglePlayerSpectating(playerid, 1);
  48. IsLogged[playerid] = 0;
  49. new file[128], string[128];
  50. new name[MAX_PLAYER_NAME];
  51. GetPlayerName(playerid, name, sizeof(name));
  52. format(file,sizeof(file),"/RankS/%s.ini",name);
  53. if(!fexist(file))
  54. {
  55. ShowPlayerDialog(playerid, WELCOME1, DIALOG_STYLE_MSGBOX, "Welcome", string, "Login", "Register");
  56. }
  57. if(fexist(file))
  58. {
  59. format(file,sizeof(file),"/RankS/%s IP.ini",name);
  60. GetPlayerIp(playerid,rip[playerid],16);
  61. if(!strcmp(rip[playerid], dini_Get(file,"IP")))
  62. {
  63. SpawnPlayer(playerid);
  64. IsLogged[playerid] = 1;
  65. TogglePlayerSpectating(playerid, 0);
  66. }else{
  67. format(string, sizeof string, "Your IP doesn match with Username: %s", name);
  68. ShowPlayerDialog(playerid, 14, DIALOG_STYLE_MSGBOX, "Login Failed", string, "OK", "Cancel");
  69. }
  70. if(!dini_Exists(file))
  71. {
  72. ShowPlayerDialog(playerid, WELCOME2, DIALOG_STYLE_MSGBOX, "Welcome", string, "Register", "Login");
  73. }
  74. return 1;
  75. }
  76. return 0;
  77. }
  78.  
  79. public OnPlayerSpawn(playerid)
  80. {
  81. new file[128], string[128];
  82. new name[MAX_PLAYER_NAME];
  83. GetPlayerName(playerid, name, sizeof(name));
  84. format(file,sizeof(file),"/RankS/%s SKINS.ini",name);
  85. if(dini_Exists(file))
  86. {
  87. SetPlayerSkin(playerid, dini_Int(file,"Skins"));
  88. }
  89. format(file,sizeof(file),"/RankS/%s IP.ini",name);
  90. if(!strcmp(rip[playerid], dini_Get(file,"IP")))
  91. {
  92. SendClientMessage(playerid, COLOR_GREEN, "You have been automatically logged in");
  93. }else{
  94. IsLogged[playerid] = 0;
  95. TogglePlayerSpectating(playerid, 1);
  96. format(string, sizeof string, "Your IP doesn match with Username:%s", name);
  97. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Login Failed", string, "OK", "Cancel");
  98. }
  99. return 1;
  100. }
  101.  
  102. public OnPlayerDisconnect(playerid, reason)
  103. {
  104. new file[128];
  105. new name[MAX_PLAYER_NAME];
  106. GetPlayerName(playerid, name, sizeof(name));
  107. format(file,sizeof(file),"/RankS/%s.ini",name);
  108. if(!dini_Exists(file))
  109. {
  110. dini_Create(file);
  111. dini_IntSet(file,"Score", GetPlayerScore(playerid));
  112. dini_IntSet(file,"Money", GetPlayerMoney(playerid));
  113. dini_IntSet(file,"Deaths", PlayerInfo[playerid][Deaths]);
  114. dini_IntSet(file,"Kills", PlayerInfo[playerid][Kills]);
  115. dini_IntSet(file,"ServerTime", PlayerInfo[playerid][ServerTime]);
  116. dini_IntSet(file, "WantedLevel", GetPlayerWantedLevel(playerid));
  117. dini_FloatSet(file, "FightStyle", GetPlayerFightingStyle(playerid));
  118. }
  119. IsLogged[playerid] = 0;
  120. KillTimer(TimeTimer);
  121. return 1;
  122. }
  123.  
  124. public OnPlayerDeath(playerid, killerid)
  125. {
  126. PlayerInfo[playerid][Deaths] ++;
  127. PlayerInfo[killerid][Kills] ++;
  128. return 1;
  129. }
  130.  
  131. forward TimeOnServer(playerid);
  132. public TimeOnServer(playerid)
  133. {
  134. PlayerInfo[playerid][ServerTime] ++;
  135. }
  136.  
  137. public OnPlayerCommandText(playerid, cmdtext[])
  138. {
  139. if(!strcmp(cmdtext, "/changepass", true))
  140. {
  141. new string[128], name[MAX_PLAYER_NAME] ,PlayerName[24];
  142. {
  143. format(string, sizeof string, "Your About to change your password \n\nA password authorization will be needed to continue!!!", name);
  144. ShowPlayerDialog(playerid, Register1, DIALOG_STYLE_MSGBOX, "change password ", string, "OK", "Cancel");
  145. }
  146. if(IsLogged[playerid] == 0)
  147. {
  148. format(string, sizeof string, "You Need To login First", PlayerName);
  149. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "WARRNING", string, "login", "Cancel");
  150. }
  151. return 1;
  152. }
  153. if(!strcmp(cmdtext, "/logout", true))
  154. {
  155. new string[128], name[MAX_PLAYER_NAME] ,PlayerName[24];
  156. if(IsLogged[playerid] == 0)
  157. {
  158. format(string, sizeof string, "You are already logged out", PlayerName);
  159. ShowPlayerDialog(playerid, 12, DIALOG_STYLE_MSGBOX, "ERROR", string, "OK", "Cancel");
  160. }
  161. IsLogged[playerid] = 0;
  162. TogglePlayerSpectating(playerid, 7);
  163. printf("%s has Logged Out", name);
  164. format(string, sizeof string, "Enter a password to log back in", PlayerName);
  165. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  166. return 1;
  167. }
  168. if(!strcmp(cmdtext, "/register", true))
  169. {
  170. new file[128], string[128] ,PlayerName[24] ,name[MAX_PLAYER_NAME];
  171. GetPlayerName(playerid, name, sizeof(name));
  172. format(file,sizeof(file),"/RankS/%s.ini",name);
  173. if(IsLogged[playerid] == 0)
  174. {
  175. if(fexist(file))
  176. GetPlayerName(playerid, PlayerName, sizeof PlayerName);
  177. format(string, sizeof string, "You need to login first", PlayerName);
  178. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  179. }
  180. if(!fexist(file))
  181. {
  182. GetPlayerName(playerid, PlayerName, sizeof PlayerName);
  183. format(string, sizeof string, "Enter Your Password for your account", PlayerName);
  184. ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
  185. }
  186. if(IsLogged[playerid] == 1)
  187. {
  188. format(string, sizeof string, "You are already Registered", PlayerName);
  189. ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "ERROR", string, "OK", "Cancel");
  190. }
  191. return 1;
  192. }
  193. if(!strcmp(cmdtext, "/login", true))
  194. {
  195. new file[128], string[128] ,PlayerName[24] ,name[MAX_PLAYER_NAME];
  196. GetPlayerName(playerid, name, sizeof(name));
  197. format(file,sizeof(file),"/RankS/%s.ini",name);
  198. if(IsLogged[playerid] == 0)
  199. {
  200. if(fexist(file))
  201. GetPlayerName(playerid, PlayerName, sizeof PlayerName);
  202. format(string, sizeof string, "Enter a password to log back in", PlayerName);
  203. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  204. }
  205. if(!fexist(file))
  206. {
  207. GetPlayerName(playerid, PlayerName, sizeof PlayerName);
  208. format(string, sizeof string, "You need to Register First", PlayerName);
  209. ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
  210. }
  211. if(IsLogged[playerid] == 1)
  212. {
  213. format(string, sizeof string, "You are already logged in", PlayerName);
  214. ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "ERROR", string, "OK", "Cancel");
  215. }
  216. return 1;
  217. }
  218. if(!strcmp(cmdtext, "/AutoLog", true))
  219. {
  220. new string[128] ,PlayerName[24];
  221. ShowPlayerDialog(playerid, AutoLog, DIALOG_STYLE_LIST, "Auto Login", "On \nOff", "Select", "Cancel");
  222. if(IsLogged[playerid] == 0)
  223. {
  224. format(string, sizeof string, "You Need To login First", PlayerName);
  225. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "login", "Cancel");
  226. }
  227. return 1;
  228. }
  229. if(!strcmp(cmdtext, "/Saveskin", true))
  230. {
  231. new string[128] ,PlayerName[24];
  232. ShowPlayerDialog(playerid, SkinSave, DIALOG_STYLE_LIST, "Skin Saving", "On \nOff", "Select", "Cancel");
  233. if(IsLogged[playerid] == 0)
  234. {
  235. format(string, sizeof string, "You Need To login First", PlayerName);
  236. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "login", "Cancel");
  237. }
  238. return 1;
  239. }
  240. return 0;
  241. }
  242.  
  243. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  244. {
  245. if(dialogid == AutoLog && response)
  246. {
  247. switch(listitem)
  248. {
  249. case 0:
  250. {
  251. new file[128] ,name[MAX_PLAYER_NAME];
  252. GetPlayerName(playerid, name, sizeof(name));
  253. format(file,sizeof(file),"/RankS/%s IP.ini",name);
  254. {
  255. dini_Create(file);
  256. GetPlayerIp(playerid,rip[playerid],16);
  257. dini_Set(file,"IP",rip[playerid]);
  258. SendClientMessage(playerid, COLOR_GREEN, "Auto Login Enabled");
  259. }
  260. return 1;
  261. }
  262. case 1:
  263. {
  264. new file[128] ,name[MAX_PLAYER_NAME];
  265. GetPlayerName(playerid, name, sizeof(name));
  266. format(file,sizeof(file),"/RankS/%s IP.ini",name);
  267. {
  268. dini_Remove(file);
  269. GetPlayerIp(playerid,rip[playerid],16);
  270. dini_Set(file,"IP",rip[playerid]);
  271. SendClientMessage(playerid, COLOR_RED, "Auto Login Disable");
  272. }
  273. return 1;
  274. }
  275. }
  276. }
  277. if(dialogid == SkinSave && response)
  278. {
  279. switch(listitem)
  280. {
  281. case 0:
  282. {
  283. new file[128] ,name[MAX_PLAYER_NAME];
  284. GetPlayerName(playerid, name, sizeof(name));
  285. format(file,sizeof(file),"/RankS/%s SKINS.ini",name);
  286. {
  287. dini_Create(file);
  288. dini_IntSet(file,"Skins",GetPlayerSkin(playerid));
  289. SendClientMessage(playerid, COLOR_GREEN, "Skin Saved");
  290. }
  291. return 1;
  292. }
  293. case 1:
  294. {
  295. new file[128] ,name[MAX_PLAYER_NAME];
  296. GetPlayerName(playerid, name, sizeof(name));
  297. format(file,sizeof(file),"/RankS/%s SKINS.ini",name);
  298. {
  299. dini_Remove(file);
  300. dini_IntSet(file,"Skins",GetPlayerSkin(playerid));
  301. SendClientMessage(playerid, COLOR_RED, "Skin UnSaved");
  302. }
  303. return 1;
  304. }
  305. }
  306. }
  307. if(dialogid == WELCOME2)
  308. {
  309. if(response)
  310. {
  311. ShowPlayerDialog(playerid,WELCOME2,DIALOG_STYLE_MSGBOX,"ERROR","You are already Registered \n \n If you dont know your password use another USERNAME","Cancel","Login");
  312. }
  313. else
  314. {
  315. TogglePlayerSpectating(playerid, 1);
  316. IsLogged[playerid] = 0;
  317.  
  318. new file[128], string[128] ,name[MAX_PLAYER_NAME];
  319. GetPlayerName(playerid, name, sizeof(name));
  320. format(file,sizeof(file),"/RankS/%s.ini",name);
  321. if(fexist(file))
  322. {
  323. format(string, sizeof string, "Welcome %s! \nYour account is Registered \n\nPlease Login to your account!", name);
  324. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  325. }
  326. }
  327. }
  328. if(dialogid == WELCOME1)
  329. {
  330. if(response)
  331. {
  332. ShowPlayerDialog(playerid,WELCOME1,DIALOG_STYLE_MSGBOX,"ERROR","Your account is not Registered","Cancel","Register");
  333. }
  334. else
  335. {
  336. TogglePlayerSpectating(playerid, 1);
  337. IsLogged[playerid] = 0;
  338. new file[128], string[128] ,name[MAX_PLAYER_NAME];
  339. GetPlayerName(playerid, name, sizeof(name));
  340. format(file,sizeof(file),"/RankS/%s.ini",name);
  341. if(!fexist(file))
  342. {
  343. format(string, sizeof string, "Welcome %s! \nPlease Register you account!", name);
  344. ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
  345. }
  346. }
  347. }
  348. if(dialogid == Register1)
  349. {
  350. if(response)
  351. {
  352. new file[128] ,string[128] ,PlayerName[24];
  353. if(strlen(inputtext) == 0)
  354. {
  355. GetPlayerName(playerid, PlayerName, sizeof PlayerName);
  356. format(string, sizeof string, "Enter your old password to proceed", PlayerName);
  357. ShowPlayerDialog(playerid, Register1, DIALOG_STYLE_INPUT, "Account", string, "Confirm", "Cancel");
  358. return 0;
  359. }
  360. new name[MAX_PLAYER_NAME];
  361. GetPlayerName(playerid, name, sizeof(name));
  362. format(file,sizeof(file),"/RankS/%s.ini",name);
  363. if(fexist(file))
  364. {
  365. new password = dini_Int(file, "Password");
  366. if(udb_hash(inputtext) != password)
  367. {
  368. SendClientMessage(playerid, COLOR_RED, "Error ~ Incorrect password");
  369. }
  370. else
  371. {
  372. format(string, sizeof string, "Password confirmed", name);
  373. ShowPlayerDialog(playerid, Register2, DIALOG_STYLE_MSGBOX, "change password", string, "NEXT", "Cancel");
  374. }
  375. }
  376. }
  377. }
  378. if(dialogid == Register2)
  379. {
  380. if(response)
  381. {
  382. new file[128] ,string[128] ,name[MAX_PLAYER_NAME];
  383. GetPlayerName(playerid, name, sizeof(name));
  384. format(file,sizeof(file),"/RankS/%s.ini",name);
  385. if(strlen(inputtext) == 0)
  386. {
  387. format(string, sizeof string, "Please enter a new password!", name);
  388. ShowPlayerDialog(playerid, Register2, DIALOG_STYLE_INPUT, "Account", string, "Change", "Cancel");
  389. return 1;
  390. }
  391. format(file,sizeof(file),"/RankS/%s.ini",name);
  392. {
  393. dini_Create(file);
  394. dini_IntSet(file,"Password", udb_hash(inputtext));
  395. TogglePlayerSpectating(playerid, 0);
  396. SendClientMessage(playerid, COLOR_BLUE, "You have successfully changed your password");
  397. }
  398. }
  399. }
  400. if(dialogid == Register)
  401. {
  402. if(response)
  403. {
  404. new file[128] ,string[128] ,name[MAX_PLAYER_NAME];
  405. GetPlayerName(playerid, name, sizeof(name));
  406. format(string,128,"%s.ini",inputtext);
  407. if(dini_Exists(string))
  408. {
  409. ShowPlayerDialog(playerid,WELCOME1 ,DIALOG_STYLE_MSGBOX,"Register [ERROR]","THIS USERNAME IS IN USE!\n\nPlease enter another username:","Cancel","Go back");
  410. }
  411. if(strlen(inputtext) == 0)
  412. {
  413. format(string, sizeof string, "Please enter a password \n\nWelcome %s! \nYour account is NOT Registered \n\nPlease Register you account!", name);
  414. ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
  415. return 0;
  416. }
  417. format(file,sizeof(file),"/RankS/%s.ini",name);
  418. if(!fexist(file))
  419. {
  420. dini_Create(file);
  421. dini_IntSet(file,"Password", udb_hash(inputtext));
  422. dini_IntSet(file,"Score", GetPlayerScore(playerid));
  423. dini_IntSet(file,"Money", GetPlayerMoney(playerid));
  424. dini_IntSet(file,"Deaths", PlayerInfo[playerid][Deaths]);
  425. dini_IntSet(file,"Kills", PlayerInfo[playerid][Kills]);
  426. dini_IntSet(file,"ServerTime", PlayerInfo[playerid][ServerTime]);
  427. dini_FloatSet(file, "FightStyle", GetPlayerFightingStyle(playerid));
  428. format(string, sizeof string, "Account Registered \n\nWelcome %s! \nWe have detected that your account is Registered \n\nPlease Login to your account!", name);
  429. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  430. PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
  431. GetPlayerName(playerid, name, sizeof(name));
  432. printf("%s has Registered a account", name);
  433. }
  434. }
  435. }
  436. if(dialogid == Login)
  437. {
  438. if(response)
  439. {
  440. new file[128] ,string[128] ,PlayerName[24];
  441. if(strlen(inputtext) == 0)
  442. {
  443. GetPlayerName(playerid, PlayerName, sizeof PlayerName);
  444. format(string, sizeof string, "Please enter a password \n\nWelcome %s! \nYour account is Registered \n\nPlease Login to your account!", PlayerName);
  445. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  446. return 0;
  447. }
  448. new name[MAX_PLAYER_NAME];
  449. GetPlayerName(playerid, name, sizeof(name));
  450. format(file,sizeof(file),"/RankS/%s.ini",name);
  451. if(fexist(file))
  452. {
  453. new password = dini_Int(file, "Password");
  454. new player[25];
  455. if(udb_hash(inputtext) != password)
  456. {
  457. if(Avisos[playerid]==2)
  458. {
  459. new str[128];
  460. Avisos[playerid]=0;
  461. format(str, sizeof (str), "%s kicked || Reason: incorrect password [3/3 Tries]",player);
  462. format(string, sizeof string, "incorrect password \n\n[3/3 Tries]", PlayerName);
  463. ShowPlayerDialog(playerid, -1, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  464. Kick(playerid);
  465. }
  466. if(Avisos[playerid]==1)
  467. {
  468. new str[128];
  469. Avisos[playerid]++;
  470. format(str, sizeof (str), "%s kicked || Reason: incorrect password [2/3 Tries]",player);
  471. format(string, sizeof string, "incorrect password \n\n[2/3 Tries]", PlayerName);
  472. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  473. }
  474. if(Avisos[playerid]==0)
  475. {
  476. new str[128];
  477. Avisos[playerid]++;
  478. format(str, sizeof (str), "%s kicked || Reason: incorrect password [1/3 Tries]",player);
  479. format(string, sizeof string, "incorrect password \n\n[1/3 Tries]", PlayerName);
  480. ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
  481. }
  482. }
  483. else
  484. {
  485. IsLogged[playerid] = 1;
  486. ResetPlayerMoney(playerid);
  487. SetPlayerScore(playerid, dini_Int(file,"Score"));
  488. GivePlayerMoney(playerid, dini_Int(file,"Money"));
  489. PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
  490. PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
  491. PlayerInfo[playerid][ServerTime] = dini_Int(file,"ServerTime");
  492. TimeTimer = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
  493. SendClientMessage(playerid, COLOR_GREEN, "Success ~ You have successfully logged into your account");
  494. TogglePlayerSpectating(playerid, 0);
  495. new pName[MAX_PLAYER_NAME];
  496. GetPlayerName(playerid, pName, sizeof(pName));
  497. format(string, sizeof(string), "[SERVER] %s has successfully loged In", name );
  498. SendClientMessageToAll(COLOR_GREEN2, string);
  499. printf("%s has logged into his account", name);
  500. }
  501. }
  502. }
  503. }
  504. return 0;
  505. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement