Advertisement
Guest User

Untitled

a guest
Jan 31st, 2011
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.01 KB | None | 0 0
  1. ////////////////////////////////////////////////
  2. // /* Register And Login System by $teVe. */
  3. // /* Please do not change anything in here. */
  4. // /* Leave my Credits Too Please. */
  5. ////////////////////////////////////////////////
  6.  
  7. #include <a_samp>
  8. #include <dini>
  9.  
  10. ////////////////
  11. // /* Defines */
  12. ////////////////
  13. // Colors (For the Colors wich the player's recieve).
  14. #define red 0xAA3333AA
  15. #define RED 0xAA3333AA
  16. #define COLOUR_RED 0xAA3333AA
  17. #define COLOR_VIOLETRED 0xDB7093FF
  18. #define COLOR_LIGHTGREEN 0x00FF00FF
  19. #define COLOR_LIGHTBLUE 0x33CCFFAA
  20. #define COLOR_GREY 0xAFAFAFAA
  21. #define COLOR_GRELLOW 0xFFFF00AA
  22. #define COLOR_WHITE 0x0000BBAA
  23. #define COLOR_LIGHTBLUE 0x33CCFFAA
  24. #define COLOR_ORANGE 0xFF9900AA
  25. #define COLOR_RED 0xAA3333AA
  26. #define COLOR_LIME 0x10F441AA
  27. #define COLOR_MAGENTA 0xFF00FFFF
  28. #define COLOR_NAVY 0x000080AA
  29. #define COLOR_AQUA 0xF0F8FFAA
  30. #define COLOR_CRIMSON 0xDC143CAA
  31. #define COLOR_FLBLUE 0x6495EDAA
  32. #define COLOR_BISQUE 0xFFE4C4AA
  33. #define COLOR_BLACK 0x000000AA
  34. #define COLOR_CHARTREUSE 0x7FFF00AA
  35. #define COLOR_BROWN 0xA52A2AAA
  36. #define COLOR_CORAL 0xFF7F50AA
  37. #define COLOR_GOLD 0xB8860BAA
  38. #define COLOR_GREENYELLOW 0xADFF2FAA
  39. #define COLOR_INDIGO 0x4B00B0AA
  40. #define COLOR_IVORY 0xFFFF82AA
  41. #define COLOR_LAWNGREEN 0x7CFC00AA
  42. #define COLOR_SEAGREEN 0x20B2AAAA
  43. #define COLOR_LIMEGREEN 0x32CD32AA
  44. #define COLOR_MIDNIGHTBLUE 0x191970AA
  45. #define COLOR_MAROON 0x800000AA
  46. #define COLOR_OLIVE 0x808000AA
  47. #define COLOR_ORANGERED 0xFF4500AA
  48. #define COLOR_PINK 0xFFC0CBAA
  49. #define COLOR_SPRINGGREEN 0x00FF7FAA
  50. #define COLOR_TOMATO 0xFF6347AA
  51. #define COLOR_YELLOWGREEN 0x9ACD32AA
  52. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  53. #define COLOR_MEDIUMMAGENTA 0x8B008BAA
  54. #define COLOR_MAROON 0x800000AA
  55. #define COLOR_OLIVE 0x808000AA
  56. #define COLOR_ORANGERED 0xFF4500AA
  57. #define COLOR_PINK 0xFFC0CBAA
  58. #define COLOR_SPRINGGREEN 0x00FF7FAA
  59. #define COLOR_TOMATO 0xFF6347AA
  60. #define COLOR_YELLOWGREEN 0x9ACD32AA
  61. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  62. #define ADMIN_RED 0xFB0000FF
  63. #define ADMINRED 0xFB0000FF
  64. #define YELLOW 0xFFFF00FF
  65. #define COLOUR_YELLOW 0xFFFF00FF
  66. #define ORANGE 0xF97804FF
  67. #define LIGHTRED 0xFF8080FF
  68. #define LIGHTBLUE 0x00C2ECFF
  69. #define LIGHTBLUE2 0x00C2ECFF
  70. #define PURPLE 0xB360FDFF
  71. #define PLAYER_COLOR 0xFFFFFFFF
  72. #define BLUE 0x1229FAFF
  73. #define blue 0x1229FAFF
  74. #define BLAU 0x1229FAFF
  75. #define LIGHTGREEN 0x38FF06FF
  76. #define DARKPINK 0xE100E1FF
  77. #define DARKGREEN 0x008040FF
  78. #define ANNOUNCEMENT 0x6AF7E1FF
  79. #define COLOR_SYSTEM 0xEFEFF7AA
  80. #define GREY 0x99FFFFAA
  81. #define PINK 0xD52DFFFF
  82. #define DARKGREY 0x626262FF
  83. #define AQUAGREEN 0x03D687FF
  84. #define NICESKY 0x99FFFFAA
  85. #define WHITE 0xFFFFFFFF
  86. #define l_red 0xFF0000AA
  87. #define l_green 0x33FF33AA
  88. #define ADMINRED 0xFB0000FF
  89. #define AQUA 0xF0F8FFAA
  90. #define COLOR_GREEN 0x33AA33AA
  91. #define GREEN 0x33AA33AA
  92. #define grey 0xC0C0C0AA
  93. #define orange 0xFF9900AA
  94. #define AFK 0x6AF7E1FF
  95. #define DEDMColor 0xFE9100FF
  96. #define lightred 0xFB0000AA
  97. // Hex Colors (For all Colors on the Messages or Dialogs).
  98. #define HEX_ORANGE "{FF9900}"
  99. #define HEX_ADMINRED "{FB0000}"
  100. #define HEX_WHITE "{FFFFFF}"
  101. #define HEX_PURPLE "{FF00FF}"
  102. #define HEX_GREY "{C0C0C0}"
  103. #define HEX_AQUA "{F0F8FF}"
  104. #define HEX_BLUE "{1229FA}"
  105. #define HEX_LIGHTGREEN "{38FF06}"
  106. #define HEX_LIGHTBLUE "{00C2EC}"
  107. #define HEX_YELLOW "{FFFF00}"
  108. #define HEX_PINK "{FFC0CB}"
  109. #define HEX_GREEN "{33AA33}"
  110. #define HEX_LIGHTRED "{FB0000}"
  111. #define HEX_GREY "{C0C0C0}"
  112. #define HEX_BLACK "{000000}"
  113. // DCMD Define (For all Commands).
  114. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  115. // Dialog Define (The define for the Dialog IDS).
  116. #define DIALOG_REGISTER 1
  117. #define DIALOG_LOGIN 2
  118. // Filterscript Define (REMOVE IT IF YOU ADD THIS TO YOUR GAMEMODE)!!!!!
  119. #define FILTERSCRIPT
  120.  
  121. // Sets (Comment this lines if you want to Disable the fallowing Functions).
  122. #define SAVEPLAYERSCORE
  123. #define SAVEPLAYERMONEY
  124. #define SAVEPLAYERDEATHS
  125. #define SHOWINFORMATIONS
  126.  
  127. // SendClientMessagef Define (By RyDeR´).
  128. #if !defined SendClientMessagef || !defined SendClientMessageToAllf || !defined MSGf || !defined MSGToAllf
  129. new __string[256];
  130. #define SendClientMessagef(%0,%1,%2) \
  131. format(__string, sizeof(__string), %2); \
  132. SendClientMessage((%0), (%1), __string)
  133. #define SendClientMessageToAllf(%0,%1) \
  134. format(__string, sizeof(__string), %1); \
  135. SendClientMessageToAll((%0), __string)
  136. #define MSGf(%0,%1,%2) \
  137. format(__string, sizeof(__string), %2); \
  138. SendClientMessage((%0), (%1), __string)
  139. #define MSGToAllf(%0,%1) \
  140. format(__string, sizeof(__string), %1); \
  141. SendClientMessageToAll((%0), __string)
  142. #endif
  143. // Dialog Defines (For the Dialog to show).
  144. #if !defined ShowRegisterDialog || !defined ShowLoginDialog
  145. new dString[150];
  146. #define ShowRegisterDialog(%0) \
  147. format(dString, sizeof(dString), "Welcome "HEX_LIGHTGREEN"%s"HEX_WHITE", Your account was not found. Type the password you want to register.", PlayerName(%0)); \
  148. ShowPlayerDialog(%0, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", dString, "Register", "Cancel")
  149. #define ShowLoginDialog(%0) \
  150. format(dString, sizeof(dString), "Welcome "HEX_LIGHTGREEN"%s"HEX_WHITE", Your account was found. Type the password you've registered.", PlayerName(%0)); \
  151. ShowPlayerDialog(%0, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", dString, "Login", "Cancel")
  152. #endif
  153. // Max Login Attempts (Use 0 or 1 to kick him if he failed 1x).
  154. #define MAX_LOGIN_ATTEMPTS 3
  155.  
  156. //////////////////
  157. // /* Veriables */
  158. //////////////////
  159. new FirstTimeSpawned[MAX_PLAYERS];
  160. new AccountFile[100];
  161. new LoginAttempts[MAX_PLAYERS];
  162. new Deaths[MAX_PLAYERS];
  163.  
  164. #if defined FILTERSCRIPT
  165.  
  166. public OnFilterScriptInit()
  167. {
  168. print("\n--------------------------------------");
  169. print(" S_RegLogin (Register and login system) by Steve successfully loaded! ");
  170. print(" Successfully Loaded!");
  171. print("--------------------------------------\n");
  172. return 1;
  173. }
  174.  
  175. public OnFilterScriptExit()
  176. {
  177. return 1;
  178. }
  179.  
  180. #else
  181.  
  182. main()
  183. {
  184. print("\n----------------------------------");
  185. print(" Blank Gamemode by your name here");
  186. print("----------------------------------\n");
  187. }
  188.  
  189. #endif
  190.  
  191. public OnGameModeInit()
  192. {
  193. SetGameModeText("Blank Script");
  194. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  195. return 1;
  196. }
  197.  
  198. stock PlayerName(playerid)
  199. {
  200. new name[MAX_PLAYER_NAME];
  201. GetPlayerName(playerid, name, sizeof(name));
  202. return name;
  203. }
  204.  
  205. public OnGameModeExit()
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnPlayerRequestClass(playerid, classid)
  211. {
  212. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  213. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  214. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  215. return 1;
  216. }
  217.  
  218. public OnPlayerConnect(playerid)
  219. {
  220. #if defined SAVEPLAYERDEATHS
  221. format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
  222. if(dini_Exists(AccountFile))
  223. {
  224. if(!dini_Isset(AccountFile, "Deaths")) dini_IntSet(AccountFile, "Deaths", 0);
  225. Deaths[playerid] = dini_Int(AccountFile, "Deaths");
  226. }
  227. else if(!dini_Exists(AccountFile))
  228. {
  229. Deaths[playerid] = 0;
  230. }
  231. #endif
  232. LoginAttempts[playerid] = 0;
  233. FirstTimeSpawned[playerid] = 0;
  234. return 1;
  235. }
  236.  
  237. stock SavePlayer(playerid)
  238. {
  239. format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
  240. #if defined SAVEPLAYERMONEY
  241. if(!dini_Isset(AccountFile, "Money")) dini_IntSet(AccountFile, "Money", 0);
  242. dini_IntSet(AccountFile, "Money", GetPlayerMoney(playerid));
  243. #endif
  244. #if defined SAVEPLAYERSCORE
  245. if(!dini_Isset(AccountFile, "Score")) dini_IntSet(AccountFile, "Score", 0);
  246. dini_IntSet(AccountFile, "Score", GetPlayerScore(playerid));
  247. #endif
  248. #if defined SAVEPLAYERDEATHS
  249. if(!dini_Isset(AccountFile, "Deaths")) dini_IntSet(AccountFile, "Deaths", 0);
  250. dini_IntSet(AccountFile, "Deaths", Deaths[playerid]);
  251. #endif
  252. return 1;
  253. }
  254.  
  255. public OnPlayerDisconnect(playerid, reason)
  256. {
  257. LoginAttempts[playerid] = 0;
  258. FirstTimeSpawned[playerid] = 0;
  259. SavePlayer(playerid);
  260. return 1;
  261. }
  262.  
  263. stock CheckRegLogin(playerid)
  264. {
  265. if(FirstTimeSpawned[playerid] == 0)
  266. {
  267. format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
  268. if(dini_Exists(AccountFile)) { ShowLoginDialog(playerid); }
  269. else if(!dini_Exists(AccountFile)) { ShowRegisterDialog(playerid); }
  270. FirstTimeSpawned[playerid] = 1;
  271. }
  272. else if(FirstTimeSpawned[playerid] != 0) { }
  273. return 1;
  274. }
  275.  
  276. public OnPlayerSpawn(playerid)
  277. {
  278. CheckRegLogin(playerid);
  279. return 1;
  280. }
  281.  
  282. public OnPlayerDeath(playerid, killerid, reason)
  283. {
  284. Deaths[playerid]++;
  285. return 1;
  286. }
  287.  
  288. public OnVehicleSpawn(vehicleid)
  289. {
  290. return 1;
  291. }
  292.  
  293. public OnVehicleDeath(vehicleid, killerid)
  294. {
  295. return 1;
  296. }
  297.  
  298. public OnPlayerText(playerid, text[])
  299. {
  300. return 1;
  301. }
  302.  
  303. public OnPlayerCommandText(playerid, cmdtext[])
  304. {
  305. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  306. {
  307.  
  308. return 1;
  309. }
  310. return 0;
  311. }
  312.  
  313. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  314. {
  315. return 1;
  316. }
  317.  
  318. public OnPlayerExitVehicle(playerid, vehicleid)
  319. {
  320. return 1;
  321. }
  322.  
  323. public OnPlayerStateChange(playerid, newstate, oldstate)
  324. {
  325. return 1;
  326. }
  327.  
  328. public OnPlayerEnterCheckpoint(playerid)
  329. {
  330. return 1;
  331. }
  332.  
  333. public OnPlayerLeaveCheckpoint(playerid)
  334. {
  335. return 1;
  336. }
  337.  
  338. public OnPlayerEnterRaceCheckpoint(playerid)
  339. {
  340. return 1;
  341. }
  342.  
  343. public OnPlayerLeaveRaceCheckpoint(playerid)
  344. {
  345. return 1;
  346. }
  347.  
  348. public OnRconCommand(cmd[])
  349. {
  350. return 1;
  351. }
  352.  
  353. public OnPlayerRequestSpawn(playerid)
  354. {
  355. return 1;
  356. }
  357.  
  358. public OnObjectMoved(objectid)
  359. {
  360. return 1;
  361. }
  362.  
  363. public OnPlayerObjectMoved(playerid, objectid)
  364. {
  365. return 1;
  366. }
  367.  
  368. public OnPlayerPickUpPickup(playerid, pickupid)
  369. {
  370. return 1;
  371. }
  372.  
  373. public OnVehicleMod(playerid, vehicleid, componentid)
  374. {
  375. return 1;
  376. }
  377.  
  378. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  379. {
  380. return 1;
  381. }
  382.  
  383. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  384. {
  385. return 1;
  386. }
  387.  
  388. public OnPlayerSelectedMenuRow(playerid, row)
  389. {
  390. return 1;
  391. }
  392.  
  393. public OnPlayerExitedMenu(playerid)
  394. {
  395. return 1;
  396. }
  397.  
  398. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  399. {
  400. return 1;
  401. }
  402.  
  403. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  404. {
  405. return 1;
  406. }
  407.  
  408. public OnRconLoginAttempt(ip[], password[], success)
  409. {
  410. return 1;
  411. }
  412.  
  413. public OnPlayerUpdate(playerid)
  414. {
  415. return 1;
  416. }
  417.  
  418. public OnPlayerStreamIn(playerid, forplayerid)
  419. {
  420. return 1;
  421. }
  422.  
  423. public OnPlayerStreamOut(playerid, forplayerid)
  424. {
  425. return 1;
  426. }
  427.  
  428. public OnVehicleStreamIn(vehicleid, forplayerid)
  429. {
  430. return 1;
  431. }
  432.  
  433. public OnVehicleStreamOut(vehicleid, forplayerid)
  434. {
  435. return 1;
  436. }
  437.  
  438. stock KickX(playerid, reason[])
  439. {
  440. new string[200]; format(string, sizeof(string), ""HEX_ADMINRED"%s"HEX_WHITE" has been kicked by the system (reason: %s)", PlayerName(playerid), reason);
  441. SendClientMessage(playerid, WHITE, string);
  442. Kick(playerid);
  443. return 1;
  444. }
  445.  
  446. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  447. {
  448. if(dialogid == DIALOG_REGISTER)
  449. {
  450. if(!strlen(inputtext)) { SendClientMessage(playerid, WHITE, ""HEX_ADMINRED"ERROR:"HEX_WHITE" You must type a password!"); ShowRegisterDialog(playerid); return 1; }
  451. if(response)
  452. {
  453. format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
  454. dini_Create(AccountFile);
  455. #if defined SAVEPLAYERSCORE
  456. dini_IntSet(AccountFile, "Score", 0);
  457. #endif
  458. #if defined SAVEPLAYERDEATHS
  459. dini_IntSet(AccountFile, "Deaths", 0);
  460. #endif
  461. #if defined SAVEPLAYERMONEY
  462. dini_IntSet(AccountFile, "Money", 0);
  463. #endif
  464. dini_Set(AccountFile, "Password", inputtext);
  465. SendClientMessage(playerid, WHITE, "You have "HEX_LIGHTGREEN"successfully"HEX_WHITE" Registered and Logged in!");
  466. #if defined SHOWINFORMATIONS
  467. SendClientMessage (playerid, ORANGE, " Information:");
  468. #if defined SAVEPLAYERSCORE
  469. SendClientMessagef(playerid, WHITE, "- Score: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerScore(playerid));
  470. #endif
  471. #if defined SAVEPLAYERMONEY
  472. SendClientMessagef(playerid, WHITE, "- Money: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerMoney(playerid));
  473. #endif
  474. #if defined SAVEPLAYERDEATHS
  475. SendClientMessagef(playerid, WHITE, "- Deaths: "HEX_LIGHTBLUE"%d"HEX_WHITE".", Deaths[playerid]);
  476. #endif
  477. #endif
  478. }
  479. else if(!response)
  480. {
  481. KickX(playerid, "You Must Register!");
  482. }
  483. }
  484. if(dialogid == DIALOG_LOGIN)
  485. {
  486. if(!strlen(inputtext)) { SendClientMessage(playerid, WHITE, ""HEX_ADMINRED"ERROR:"HEX_WHITE" You must type a password!"); ShowLoginDialog(playerid); return 1; }
  487. if(response)
  488. {
  489. format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
  490. if(strcmp(inputtext, dini_Get(AccountFile, "Password"), true) == 0)
  491. {
  492. #if defined SAVEPLAYERMONEY
  493. if(!dini_Isset(AccountFile, "Money")) dini_IntSet(AccountFile, "Money", 0);
  494. GivePlayerMoney(playerid, dini_Int(AccountFile, "Money"));
  495. #endif
  496. #if defined SAVEPLAYERSCORE
  497. if(!dini_Isset(AccountFile, "Score")) dini_IntSet(AccountFile, "Score", 0);
  498. SetPlayerScore(playerid, dini_Int(AccountFile, "Score"));
  499. #endif
  500. SendClientMessage(playerid, WHITE, "You have "HEX_LIGHTGREEN"successfully"HEX_WHITE" Logged in!");
  501. #if defined SHOWINFORMATIONS
  502. SendClientMessage (playerid, ORANGE, " Information:");
  503. #if defined SAVEPLAYERSCORE
  504. SendClientMessagef(playerid, WHITE, "- Score: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerScore(playerid));
  505. #endif
  506. #if defined SAVEPLAYERMONEY
  507. SendClientMessagef(playerid, WHITE, "- Money: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerMoney(playerid));
  508. #endif
  509. #if defined SAVEPLAYERDEATHS
  510. SendClientMessagef(playerid, WHITE, "- Deaths: "HEX_LIGHTBLUE"%d"HEX_WHITE".", Deaths[playerid]);
  511. #endif
  512. #endif
  513. LoginAttempts[playerid] = 0;
  514. }
  515. else
  516. {
  517. LoginAttempts[playerid]++;
  518. if(LoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
  519. {
  520. KickX(playerid, "Failed Login");
  521. return 1;
  522. }
  523. SendClientMessagef(playerid, WHITE, ""HEX_ADMINRED"ERROR:"HEX_WHITE" Invalid password [Failed Logins: %d/Max Allowed: %d]!", LoginAttempts[playerid], MAX_LOGIN_ATTEMPTS);
  524. ShowLoginDialog(playerid);
  525. }
  526. }
  527. else if(!response)
  528. {
  529. KickX(playerid, "You Must Login!");
  530. }
  531. }
  532. return 1;
  533. }
  534.  
  535. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  536. {
  537. return 1;
  538. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement