Guest User

Untitled

a guest
Sep 1st, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. /*******************************************************************************
  2. * SERVER NAME: saCvT
  3. * SERVER VERSION: r1.0a (01/09/2012)
  4. * SERVER DEVELOPER: Livar
  5. *
  6. * INFORMATION: This gamemode was created simply for education purposes!
  7. *
  8. *******************************************************************************/
  9.  
  10. /* @script includes */
  11. #include <a_samp>
  12. #include <dini>
  13. #include <dutils>
  14. #include <dudb>
  15.  
  16. /* @script settings */
  17. #pragma tabsize 0
  18. #pragma unused ret_memcpy
  19.  
  20. /* @script defines */
  21. #define COLOR_GREY 0xAFAFAFAA
  22. #define COLOR_GREEN 0x33AA33AA
  23. #define COLOR_RED 0xAA3333AA
  24. #define COLOR_YELLOW 0xFFFF00AA
  25. #define COLOR_WHITE 0xFFFFFFAA
  26. #define COLOR_BLUE 0x0000BBAA
  27. #define COLOR_LIGHTBLUE 0x33CCFFAA
  28. #define COLOR_ORANGE 0xFF9900AA
  29. #define COLOR_RED 0xAA3333AA
  30. #define COLOR_LIME 0x10F441AA
  31. #define COLOR_MAGENTA 0xFF00FFFF
  32. #define COLOR_NAVY 0x000080AA
  33. #define COLOR_AQUA 0xF0F8FFAA
  34. #define COLOR_CRIMSON 0xDC143CAA
  35. #define COLOR_FLBLUE 0x6495EDAA
  36. #define COLOR_BISQUE 0xFFE4C4AA
  37. #define COLOR_BLACK 0x000000AA
  38. #define COLOR_CHARTREUSE 0x7FFF00AA
  39. #define COLOR_BROWN 0XA52A2AAA
  40. #define COLOR_CORAL 0xFF7F50AA
  41. #define COLOR_GOLD 0xB8860BAA
  42. #define COLOR_GREENYELLOW 0xADFF2FAA
  43. #define COLOR_INDIGO 0x4B00B0AA
  44. #define COLOR_IVORY 0xFFFF82AA
  45. #define COLOR_LAWNGREEN 0x7CFC00AA
  46. #define COLOR_SEAGREEN 0x20B2AAAA
  47. #define COLOR_LIMEGREEN 0x32CD32AA
  48. #define COLOR_MIDNIGHTBLUE 0X191970AA
  49. #define COLOR_MAROON 0x800000AA
  50. #define COLOR_OLIVE 0x808000AA
  51. #define COLOR_ORANGERED 0xFF4500AA
  52. #define COLOR_PINK 0xFFC0CBAA
  53. #define COLOR_SPRINGGREEN 0x00FF7FAA
  54. #define COLOR_TOMATO 0xFF6347AA
  55. #define COLOR_YELLOWGREEN 0x9ACD32AA
  56. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  57. #define COLOR_MEDIUMMAGENTA 0x8B008BAA
  58.  
  59. /* @script enumerators */
  60. enum pInfo
  61. {
  62. Password,
  63. Score,
  64. Money,
  65. Rank,
  66. Team
  67. }
  68.  
  69. /* @script news' */
  70. new PlayerInfo[MAX_PLAYERS][pInfo];
  71.  
  72. main()
  73. {
  74. print("SERVER NAME: saCvT ");
  75. print("SERVER VERSION: r1.0a (01/09/20120)");
  76. print("DEVELOPER: Livar");
  77. }
  78.  
  79.  
  80. public OnGameModeInit()
  81. {
  82. return 1;
  83. }
  84.  
  85. public OnGameModeExit()
  86. {
  87. return 1;
  88. }
  89.  
  90. public OnPlayerRequestClass(playerid, classid)
  91. {
  92. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  93. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  94. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  95. return 1;
  96. }
  97.  
  98. public OnPlayerConnect(playerid)
  99. {
  100. new username[MAX_PLAYER_NAME], file[128];
  101. GetPlayerName(playerid, username, MAX_PLAYER_NAME);
  102. format(file, sizeof(file), "Users/%s.ini", username);
  103.  
  104. if(!fexist(file))
  105. {
  106. SendClientMessage(playerid, COLOR_RED, "Welcome to saCvT, it seems you're not registered, enter your desired password below!");
  107. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please register", "Enter your desired password below", "Register", "Cancel");
  108. }
  109.  
  110. else
  111. {
  112. new str[128];
  113. GetPlayerName(playerid, username, MAX_PLAYER_NAME);
  114. format(str, sizeof(str), "Welcome back to San Andreas Cops vs Terrorists, ~r~%s. Enjoy!", username);
  115. SendClientMessage(playerid, COLOR_YELLOW, str);
  116. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please enter your password", "Enter your password below", "Login", "Cancel");
  117. }
  118.  
  119. return 1;
  120. }
  121.  
  122. public OnPlayerDisconnect(playerid, reason)
  123. {
  124. new file[128], username[MAX_PLAYER_NAME];
  125. GetPlayerName(playerid, username, MAX_PLAYER_NAME);
  126. format(file, sizeof(file), "Users/%s.ini", username);
  127.  
  128. if(dini_Exists(file))
  129. {
  130. dini_IntSet(file, "Password", PlayerInfo[playerid][Password]);
  131. dini_IntSet(file, "Score", PlayerInfo[playerid][Score]);
  132. dini_IntSet(file, "Money", PlayerInfo[playerid][Money]);
  133. dini_IntSet(file, "Rank", PlayerInfo[playerid][Rank]);
  134. dini_IntSet(file, "Team", PlayerInfo[playerid][Team]);
  135. }
  136.  
  137. return 1;
  138. }
  139.  
  140. public OnPlayerSpawn(playerid)
  141. {
  142. return 1;
  143. }
  144.  
  145. public OnPlayerDeath(playerid, killerid, reason)
  146. {
  147. return 1;
  148. }
  149.  
  150. public OnVehicleSpawn(vehicleid)
  151. {
  152. return 1;
  153. }
  154.  
  155. public OnVehicleDeath(vehicleid, killerid)
  156. {
  157. return 1;
  158. }
  159.  
  160. public OnPlayerText(playerid, text[])
  161. {
  162. return 1;
  163. }
  164.  
  165. public OnPlayerCommandText(playerid, cmdtext[])
  166. {
  167. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  168. {
  169. // Do something here
  170. return 1;
  171. }
  172. return 0;
  173. }
  174.  
  175. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  176. {
  177. return 1;
  178. }
  179.  
  180. public OnPlayerExitVehicle(playerid, vehicleid)
  181. {
  182. return 1;
  183. }
  184.  
  185. public OnPlayerStateChange(playerid, newstate, oldstate)
  186. {
  187. return 1;
  188. }
  189.  
  190. public OnPlayerEnterCheckpoint(playerid)
  191. {
  192. return 1;
  193. }
  194.  
  195. public OnPlayerLeaveCheckpoint(playerid)
  196. {
  197. return 1;
  198. }
  199.  
  200. public OnPlayerEnterRaceCheckpoint(playerid)
  201. {
  202. return 1;
  203. }
  204.  
  205. public OnPlayerLeaveRaceCheckpoint(playerid)
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnRconCommand(cmd[])
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnPlayerRequestSpawn(playerid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnObjectMoved(objectid)
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnPlayerObjectMoved(playerid, objectid)
  226. {
  227. return 1;
  228. }
  229.  
  230. public OnPlayerPickUpPickup(playerid, pickupid)
  231. {
  232. return 1;
  233. }
  234.  
  235. public OnVehicleMod(playerid, vehicleid, componentid)
  236. {
  237. return 1;
  238. }
  239.  
  240. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  241. {
  242. return 1;
  243. }
  244.  
  245. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  246. {
  247. return 1;
  248. }
  249.  
  250. public OnPlayerSelectedMenuRow(playerid, row)
  251. {
  252. return 1;
  253. }
  254.  
  255. public OnPlayerExitedMenu(playerid)
  256. {
  257. return 1;
  258. }
  259.  
  260. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  261. {
  262. return 1;
  263. }
  264.  
  265. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  266. {
  267. return 1;
  268. }
  269.  
  270. public OnRconLoginAttempt(ip[], password[], success)
  271. {
  272. return 1;
  273. }
  274.  
  275. public OnPlayerUpdate(playerid)
  276. {
  277. return 1;
  278. }
  279.  
  280. public OnPlayerStreamIn(playerid, forplayerid)
  281. {
  282. return 1;
  283. }
  284.  
  285. public OnPlayerStreamOut(playerid, forplayerid)
  286. {
  287. return 1;
  288. }
  289.  
  290. public OnVehicleStreamIn(vehicleid, forplayerid)
  291. {
  292. return 1;
  293. }
  294.  
  295. public OnVehicleStreamOut(vehicleid, forplayerid)
  296. {
  297. return 1;
  298. }
  299.  
  300. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  301. {
  302. if(dialogid == 1)
  303. {
  304. new file[128], username[MAX_PLAYER_NAME], str[128];
  305. GetPlayerName(playerid, username, MAX_PLAYER_NAME);
  306. format(file, sizeof(file), "Users/%s.ini", username);
  307.  
  308. if(response)
  309. {
  310. if(strlen(inputtext))
  311. {
  312. dini_Create(file);
  313. dini_IntSet(file, "Password", num_hash(inputtext));
  314. dini_IntSet(file, "Score", PlayerInfo[playerid][Score]);
  315. dini_IntSet(file, "Money", PlayerInfo[playerid][Money]);
  316. dini_IntSet(file, "Rank", PlayerInfo[playerid][Rank]);
  317. dini_IntSet(file, "Team", PlayerInfo[playerid][Team]);
  318.  
  319. /* User has registered, set their values */
  320. format(str, sizeof(str), "You are registered as ~r~%s. Your password is ~r~%s. Enjoy!", username, inputtext);
  321. SendClientMessage(playerid, COLOR_GREEN, str);
  322. PlayerInfo[playerid][Password] = num_hash(inputtext);
  323. PlayerInfo[playerid][Score] = dini_Int(file, "0");
  324. PlayerInfo[playerid][Money] = dini_Int(file, "10000");
  325. PlayerInfo[playerid][Rank] = dini_Int(file, "Private");
  326. }
  327. }
  328.  
  329. else
  330. {
  331. SendClientMessage(playerid, COLOR_RED, "You have been kicked for a failure at registration, please re-connect to retry");
  332. Kick(playerid);
  333. }
  334. }
  335.  
  336. if(dialogid == 2)
  337. {
  338. new file[128], username[MAX_PLAYER_NAME], str[128];
  339. GetPlayerName(playerid, username, MAX_PLAYER_NAME);
  340. format(str, sizeof(str), "Users/%s.ini", username);
  341.  
  342. if(response)
  343. {
  344. if(strlen(inputtext))
  345. {
  346. if(num_hash(inputtext) != dini_Int(file, "Password"))
  347. SendClientMessage(playerid, COLOR_RED, "Wrong password, try again!");
  348. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please enter your password", "Enter your password below", "Login", "Cancel");
  349. }
  350.  
  351. else
  352. {
  353. new text[128], money[128], score[128];
  354. format(money, sizeof(money), PlayerInfo[playerid][Money]);
  355. format(score, sizeof(score), PlayerInfo[playerid][Score]);
  356. format(text, sizeof(text), "You are logged as ~r~%s. Your score is ~r~%s. Enjoy!", username, money, score);
  357. SendClientMessage(playerid, COLOR_GREEN, text);
  358.  
  359. SetPlayerScore(playerid, dini_Int(file, "Score"));
  360. GivePlayerMoney(playerid, dini_Int(file, "Money"));
  361. }
  362. }
  363.  
  364. else
  365. {
  366. SendClientMessage(playerid, COLOR_RED, "You have been kicked because a failure attempt on logging in");
  367. Kick(playerid);
  368. }
  369. }
  370.  
  371. return 1;
  372. }
  373.  
  374. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  375. {
  376. return 1;
  377. }
Advertisement
Add Comment
Please, Sign In to add comment