Guest User

Untitled

a guest
Jan 22nd, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.64 KB | None | 0 0
  1. /*******************************************************************************
  2. * SERVER NAME: Los Santos Life Cops n Robbers
  3. * SERVER VERSION: v1.0
  4. * SERVER DEVELOPER: Goldkiller & JerryBean
  5. *
  6. * INFORMATION: Los Santos Life Cops n Robbers is a gamemode which was created
  7. * on the 19.1.2013. This script contains lots of functions, commands, and
  8. * admin commands.
  9. *
  10. * Copyright 2013. Do not steal this Gamemode, if your using it, leave the
  11. * credits on.
  12. *
  13. * To do list:
  14. *
  15. * *Add Admin + Register system
  16. *
  17. *******************************************************************************/
  18. //--[INCLUDES]--
  19. #include <a_samp>
  20. #include <YSI\y_ini>
  21.  
  22. //-----[FORWARDS]-----
  23. forward loadaccount_user(playerid, name[], value[]);
  24.  
  25. //-----[NATIVES]-----
  26. native WP_Hash(buffer[],len,const str[]);
  27.  
  28. //-----[ADMIN DEFINES]-----
  29. #define dregister 2011
  30. #define dlogin 2012
  31. #define UserPath "Adm/Users/%s.ini"
  32.  
  33. //-----[COLOR DEFINES FOR ADMIN/REG SYSTEM]-----
  34. #define COL_WHITE "{FFFFFF}"
  35. #define COL_RED "{F81414}"
  36. #define COL_GREEN "{00FF22}"
  37. #define COL_LIGHTBLUE "{00CED1}"
  38.  
  39. //-----[ENUMS]-----
  40. enum PlayerInfo
  41. {
  42. Pass[129], //User's password
  43. Adminlevel, //User's admin level
  44. VIPlevel, //User's vip level
  45. Money, //User's money
  46. Scores, //User's scores
  47. Kills, //User's kills
  48. Deaths //User's deaths
  49. }
  50. new pInfo[MAX_PLAYERS][PlayerInfo];
  51.  
  52. //-----[OTHER DEFINES]-----
  53.  
  54. //-----[FORWARDS]-----
  55. forward RandomMessages();
  56.  
  57. //--[TEXTDRAWS]--
  58. new Text:Startup0;
  59. new Text:Startup1;
  60. new Text:Startup2;
  61. new Text:Startup3;
  62. new Text:Startup4;
  63. new Text:Startup5;
  64.  
  65. new randomMessages[][] = //Random server messages
  66. {
  67. "[INFO]Always remember to follow the servers rules otherwise it may result in a punishment", //First Random Message
  68. "[INFO]If you liked our server tell your friends about it", //Second Random Message
  69. "[INFO]Remember to add our server to your favourites. Our IP is ~Comming soon~", //Third Random Message
  70. "[INFO]Remember to visit our TeamSpeak 3 server. Our TS3 IP is ~Comming soon~", //Fourth Random Message
  71. "[INFO]Unsure of anything? Need help? Use /ask to ask a question to our online staff", //Fifth Random Message
  72. "[INFO]Spotted a hacker? /report in game them or report them on our forums", //Sixth Random Message
  73. "[INFO]Use /admins to see a list of our online staff", //Sevent Random Message
  74. "[INFO]Found a bug? Report it on our forums."
  75. };
  76.  
  77. //------[TEAM DEFINES]------
  78. #define TEAM_COPS 0
  79. #define TEAM_COLOR_COPS COLOR_BLUE
  80. #define TEAM_C.I.A 1
  81. #define TEAM_COLOR_C.I.A COLOR_BLUE
  82. #define TEAM_SWAT 2
  83. #define TEAM_COLOR_SWAT COLOR_AQUA
  84. #define TEAM_ARMY 3
  85. #define TEAM_COLOR_ARMY COLOR_PURPLE
  86. #define TEAM_MEDICS 4
  87. #define TEAM_COLOR_MEDICS COLOR_PINK
  88. #define TEAM_TAXI 5
  89. #define TEAM_COLOR_TAXI COLOR_GREEN
  90. #define TEAM_MECH 6
  91. #define TEAM_COLOR_MECH COLOR_WHITE
  92. #define TEAM_ CIV 7
  93. #define TEAM_COLOR_CIV COLOR_WHITE
  94.  
  95. //------[COLOR DEFINES]------
  96. /////////TEAM_COLORS/////////
  97. #define COLOR_BLUE 0x00FFFFFF ///Cops & C.I.A
  98. #define COLOR_AQUA 0x00FFFFFF ///SWAT
  99. #define COLOR_PURPLE 0xA200FFFF ///Army
  100. #define COLOR_PINK 0xECC8ECFF ///Medics
  101. #define COLOR_GREEN 0xECC8ECFF ///Taxi
  102. #define COLOR_WHITE 0xFFFFFFFF ///CIV & Mech
  103.  
  104. //---------[COLORS]---------
  105. //////////OTHER_COLORS//////
  106. #define COLOR_GREY 0xAFAFAFAA
  107. #define COLOR_RED 0xAA3333AA
  108. #define COLOR_YELLOW 0xFFFF00AA
  109. #define COLOR_WHITE 0xFFFFFFFF
  110. #define COLOR_LIGHTBLUE 0x33CCFFAA
  111. #define COLOR_ORANGE 0xFF9900AA
  112. #define COLOR_RED 0xAA3333AA
  113. #define COLOR_LIME 0x10F441AA
  114. #define COLOR_MAGENTA 0xFF00FFFF
  115. #define COLOR_NAVY 0x000080AA
  116. #define COLOR_CRIMSON 0xDC143CAA
  117. #define COLOR_FLBLUE 0x6495EDAA
  118. #define COLOR_BISQUE 0xFFE4C4AA
  119. #define COLOR_BLACK 0x000000AA
  120. #define COLOR_CHARTREUSE 0x7FFF00AA
  121. #define COLOR_BROWN 0XA52A2AAA
  122. #define COLOR_CORAL 0xFF7F50AA
  123. #define COLOR_GOLD 0xB8860BAA
  124. #define COLOR_GREENYELLOW 0xADFF2FAA
  125. #define COLOR_INDIGO 0x4B00B0AA
  126. #define COLOR_IVORY 0xFFFF82AA
  127. #define COLOR_LAWNGREEN 0x7CFC00AA
  128. #define COLOR_SEAGREEN 0x20B2AAAA
  129. #define COLOR_LIMEGREEN 0x32CD32AA
  130. #define COLOR_MIDNIGHTBLUE 0X191970AA
  131. #define COLOR_MAROON 0x800000AA
  132. #define COLOR_OLIVE 0x808000AA
  133. #define COLOR_ORANGERED 0xFF4500AA
  134. #define COLOR_SPRINGGREEN 0x00FF7FAA
  135. #define COLOR_TOMATO 0xFF6347AA
  136. #define COLOR_YELLOWGREEN 0x9ACD32AA
  137. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  138. #define COLOR_MEDIUMMAGENTA 0x8B008BAA
  139.  
  140. #if defined FILTERSCRIPT
  141.  
  142. public OnFilterScriptInit()
  143. {
  144. print("\n--------------------------------------");
  145. print(" Blank Filterscript by your name here");
  146. print("--------------------------------------\n");
  147. return 1;
  148. }
  149.  
  150. public OnFilterScriptExit()
  151. {
  152. return 1;
  153. }
  154.  
  155. #else
  156.  
  157. main()
  158. {
  159. print("-------------------------------------------");
  160. print("SERVER: Los Santos Life Cops n Robbers");
  161. print("VERSION: Mode v1.0");
  162. print("DEVELOPER: Goldkiller & JerryBean");
  163. print("BETA TESTERS: SilverKiller & JerryBean");
  164. print("-------------------------------------------");
  165. }
  166.  
  167. #endif
  168.  
  169. public OnGameModeInit()
  170. {
  171. Startup0 = TextDrawCreate(645.000000, 2.000000, "_");
  172. TextDrawBackgroundColor(Startup0, 255);
  173. TextDrawFont(Startup0, 1);
  174. TextDrawLetterSize(Startup0, 0.500000, 10.100002);
  175. TextDrawColor(Startup0, -1);
  176. TextDrawSetOutline(Startup0, 0);
  177. TextDrawSetProportional(Startup0, 1);
  178. TextDrawSetShadow(Startup0, 1);
  179. TextDrawUseBox(Startup0, 1);
  180. TextDrawBoxColor(Startup0, 255);
  181. TextDrawTextSize(Startup0, -5.000000, 0.000000);
  182.  
  183. Startup1 = TextDrawCreate(645.000000, 354.000000, "_");
  184. TextDrawBackgroundColor(Startup1, 255);
  185. TextDrawFont(Startup1, 1);
  186. TextDrawLetterSize(Startup1, 0.500000, 10.100002);
  187. TextDrawColor(Startup1, -1);
  188. TextDrawSetOutline(Startup1, 0);
  189. TextDrawSetProportional(Startup1, 1);
  190. TextDrawSetShadow(Startup1, 1);
  191. TextDrawUseBox(Startup1, 1);
  192. TextDrawBoxColor(Startup1, 255);
  193. TextDrawTextSize(Startup1, -5.000000, 0.000000);
  194.  
  195. Startup2 = TextDrawCreate(645.000000, 354.000000, "_");
  196. TextDrawBackgroundColor(Startup2, 255);
  197. TextDrawFont(Startup2, 1);
  198. TextDrawLetterSize(Startup2, 0.500000, 0.000000);
  199. TextDrawColor(Startup2, -1);
  200. TextDrawSetOutline(Startup2, 0);
  201. TextDrawSetProportional(Startup2, 1);
  202. TextDrawSetShadow(Startup2, 1);
  203. TextDrawUseBox(Startup2, 1);
  204. TextDrawBoxColor(Startup2, COLOR_LIGHTBLUE);
  205. TextDrawTextSize(Startup2, -5.000000, 0.000000);
  206.  
  207. Startup3 = TextDrawCreate(645.000000, 93.000000, "_");
  208. TextDrawBackgroundColor(Startup3, 255);
  209. TextDrawFont(Startup3, 1);
  210. TextDrawLetterSize(Startup3, 0.500000, 0.000000);
  211. TextDrawColor(Startup3, -1);
  212. TextDrawSetOutline(Startup3, 0);
  213. TextDrawSetProportional(Startup3, 1);
  214. TextDrawSetShadow(Startup3, 1);
  215. TextDrawUseBox(Startup3, 1);
  216. TextDrawBoxColor(Startup3, COLOR_LIGHTBLUE);
  217. TextDrawTextSize(Startup3, -5.000000, 0.000000);
  218.  
  219. Startup4 = TextDrawCreate(138.000000, 19.000000, "Los Santos Life");
  220. TextDrawBackgroundColor(Startup4, COLOR_LIGHTBLUE);
  221. TextDrawFont(Startup4, 2);
  222. TextDrawLetterSize(Startup4, 0.699999, 4.599997);
  223. TextDrawColor(Startup4, 255);
  224. TextDrawSetOutline(Startup4, 1);
  225. TextDrawSetProportional(Startup4, 1);
  226.  
  227. Startup5 = TextDrawCreate(92.000000, 73.000000, "This server may contain explicit content and may be considered only for adults");
  228. TextDrawBackgroundColor(Startup5, COLOR_LIGHTBLUE);
  229. TextDrawFont(Startup5, 2);
  230. TextDrawLetterSize(Startup5, 0.240000, 0.900000);
  231. TextDrawColor(Startup5, 255);
  232. TextDrawSetOutline(Startup5, 1);
  233. TextDrawSetProportional(Startup5, 1);
  234.  
  235. SetGameModeText("Cops and Robbers");
  236. //------------------------[PLAYER CLASS SELECTION]--------------------------
  237. /////////////////////////////////TEAM_COPS//////////////////////////////////
  238. AddPlayerClass(266, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  239. AddPlayerClass(265, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  240. AddPlayerClass(267, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  241. AddPlayerClass(283, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  242. AddPlayerClass(288, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  243. AddPlayerClass(286, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  244. AddPlayerClass(284, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  245. //////////////////////////////////TEAM_C.I.A////////////////////////////////
  246. AddPlayerClass(165, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  247. AddPlayerClass(166, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
  248. //////////////////////////////////TEAM_SWAT///////////////////////////////////
  249. AddPlayerClass(285, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  250. /////////////////////////////////TEAM_ARMY///////////////////////////////////
  251. AddPlayerClass(287, 2778.7278,-2410.4207,13.6359,180.4225, 0, 0, 0, 0, 0, 0);
  252. ////////////////////////////////TEAM_MEDICS//////////////////////////////////
  253. AddPlayerClass(276, 2027.7826,-1404.2111,17.2339,179.8795, 0, 0, 0, 0, 0, 0);
  254. AddPlayerClass(275, 2027.7826,-1404.2111,17.2339,179.8795, 0, 0, 0, 0, 0, 0);
  255. ///////////////////////////////TEAM_TAXI/////////////////////////////////////
  256. AddPlayerClass(261, 1770.8652,-1861.5470,13.5774,358.8449, 0, 0, 0, 0, 0, 0);
  257. AddPlayerClass(7, 1770.8652,-1861.5470,13.5774,358.8449, 0, 0, 0, 0, 0, 0);
  258. //////////////////////////////TEAM_MECH//////////////////////////////////////
  259. AddPlayerClass(50, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  260. //////////////////////////////TEAM_CIV///////////////////////////////////////
  261. AddPlayerClass(2, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  262. AddPlayerClass(3, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  263. AddPlayerClass(21, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  264. AddPlayerClass(22, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  265. AddPlayerClass(23, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  266. AddPlayerClass(29, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  267. AddPlayerClass(47, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  268. AddPlayerClass(48, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  269. AddPlayerClass(12, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  270. AddPlayerClass(24, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  271. AddPlayerClass(25, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  272. AddPlayerClass(26, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  273. AddPlayerClass(28, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  274. AddPlayerClass(86, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  275. AddPlayerClass(100, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  276. AddPlayerClass(103, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  277. AddPlayerClass(104, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  278. AddPlayerClass(106, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  279. AddPlayerClass(107, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  280. AddPlayerClass(108, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  281. AddPlayerClass(147, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  282. AddPlayerClass(149, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  283. AddPlayerClass(180, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  284. AddPlayerClass(188, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  285. AddPlayerClass(217, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  286. AddPlayerClass(223, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  287. AddPlayerClass(247, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  288. AddPlayerClass(248, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  289. AddPlayerClass(250, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  290. AddPlayerClass(254, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  291. AddPlayerClass(264, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  292. AddPlayerClass(46, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  293. AddPlayerClass(294, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  294. //Changing the way it runs
  295. UsePlayerPedAnims();
  296. ///Timer
  297. SetTimer("RandomMessages", 100000, true); //Time for Random Messages - Appears every 100 seceonds
  298. SetTimer("RandomMessage",10000,1); // 8000 is for 8 seconds, if you want 50 seconds use 50000
  299. return 1;
  300. }
  301.  
  302. public OnGameModeExit()
  303. {
  304. return 1;
  305. }
  306.  
  307. public OnPlayerRequestClass(playerid, classid)
  308. {
  309. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  310. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  311. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  312. return 1;
  313. }
  314.  
  315. public OnPlayerConnect(playerid)
  316. {
  317. TextDrawShowForPlayer(playerid,Startup0);
  318. TextDrawShowForPlayer(playerid,Startup1);
  319. TextDrawShowForPlayer(playerid,Startup2);
  320. TextDrawShowForPlayer(playerid,Startup3);
  321. TextDrawShowForPlayer(playerid,Startup4);
  322. TextDrawShowForPlayer(playerid,Startup5);
  323. PlayAudioStreamForPlayer(playerid, "http://mixconnect.com/disk2/mp3/1e1a51b28bdc93803dcbf.mp3");
  324. new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
  325. GetPlayerName(playerid,name,sizeof(name)); //Get player's name
  326. if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
  327. {// then
  328. INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
  329. ShowPlayerDialog(playerid,dlogin, DIALOG_STYLE_PASSWORD,""COL_GREEN"Login",""COL_WHITE"This account is {00FF22}already registered.\n{FFFFFF}Please login by entering your password in below","Login","Quit");
  330. }
  331. else //If the connected user is not registered,
  332. {//then we will 'force' him to register :)
  333. ShowPlayerDialog(playerid,dregister, DIALOG_STYLE_PASSWORD,""COL_RED"Register",""COL_WHITE"This account is{F81414} not yet registered \n{FFFFFF}Please create an account by writing a password below","Register","Quit");
  334. return 1;
  335. }
  336. return 1;
  337. }
  338.  
  339. public RandomMessages()
  340. {
  341. new randomMsg = random(sizeof(randomMessages)); //create a variable "randomMsg" and give it the value of our array we've created ("randomMessages")
  342. SendClientMessageToAll(0xFF8400FF, randomMessages[randomMsg]); //Will send a Random Message to everybody on the server
  343. }
  344.  
  345.  
  346. public OnPlayerDisconnect(playerid, reason)
  347. {
  348. //Same as OnDialogResponse, we will save their stats inside of their user's account
  349. if(fexist(Path(playerid)))//Will check if the file is exit or not inside of User's folder that we have created.
  350. {
  351. new INI:file = INI_Open(Path(playerid)); //will open their file
  352. INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  353. INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
  354. INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
  355. INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
  356. INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
  357. INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
  358. INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
  359. INI_Close(file);//Now after we've done saving their data, we now need to close the file
  360. return 1;
  361. }
  362. return 1;
  363. }
  364.  
  365. public OnPlayerSpawn(playerid)
  366. {
  367. TextDrawHideForPlayer(playerid, Startup0);
  368. TextDrawHideForPlayer(playerid, Startup1);
  369. TextDrawHideForPlayer(playerid, Startup2);
  370. TextDrawHideForPlayer(playerid, Startup3);
  371. TextDrawHideForPlayer(playerid, Startup4);
  372. TextDrawHideForPlayer(playerid, Startup5);
  373. StopAudioStreamForPlayer(playerid);
  374. return 1;
  375. }
  376.  
  377. public OnPlayerDeath(playerid, killerid, reason)
  378. {
  379. pInfo[killerid][Kills]++;
  380. pInfo[killerid][Kills]++;
  381. return 1;
  382. }
  383.  
  384. public OnVehicleSpawn(vehicleid)
  385. {
  386. return 1;
  387. }
  388.  
  389. public OnVehicleDeath(vehicleid, killerid)
  390. {
  391. return 1;
  392. }
  393.  
  394. public OnPlayerText(playerid, text[])
  395. {
  396. return 1;
  397. }
  398.  
  399. public OnPlayerCommandText(playerid, cmdtext[])
  400. {
  401. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  402. {
  403. // Do something here
  404. return 1;
  405. }
  406. return 0;
  407. }
  408.  
  409. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  410. {
  411. return 1;
  412. }
  413.  
  414. public OnPlayerExitVehicle(playerid, vehicleid)
  415. {
  416. return 1;
  417. }
  418.  
  419. public OnPlayerStateChange(playerid, newstate, oldstate)
  420. {
  421. return 1;
  422. }
  423.  
  424. public OnPlayerEnterCheckpoint(playerid)
  425. {
  426. return 1;
  427. }
  428.  
  429. public OnPlayerLeaveCheckpoint(playerid)
  430. {
  431. return 1;
  432. }
  433.  
  434. public OnPlayerEnterRaceCheckpoint(playerid)
  435. {
  436. return 1;
  437. }
  438.  
  439. public OnPlayerLeaveRaceCheckpoint(playerid)
  440. {
  441. return 1;
  442. }
  443.  
  444. public OnRconCommand(cmd[])
  445. {
  446. return 1;
  447. }
  448.  
  449. public OnPlayerRequestSpawn(playerid)
  450. {
  451. return 1;
  452. }
  453.  
  454. public OnObjectMoved(objectid)
  455. {
  456. return 1;
  457. }
  458.  
  459. public OnPlayerObjectMoved(playerid, objectid)
  460. {
  461. return 1;
  462. }
  463.  
  464. public OnPlayerPickUpPickup(playerid, pickupid)
  465. {
  466. return 1;
  467. }
  468.  
  469. public OnVehicleMod(playerid, vehicleid, componentid)
  470. {
  471. return 1;
  472. }
  473.  
  474. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  475. {
  476. return 1;
  477. }
  478.  
  479. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  480. {
  481. return 1;
  482. }
  483.  
  484. public OnPlayerSelectedMenuRow(playerid, row)
  485. {
  486. return 1;
  487. }
  488.  
  489. public OnPlayerExitedMenu(playerid)
  490. {
  491. return 1;
  492. }
  493.  
  494. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  495. {
  496. return 1;
  497. }
  498.  
  499. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  500. {
  501. return 1;
  502. }
  503.  
  504. public OnRconLoginAttempt(ip[], password[], success)
  505. {
  506. return 1;
  507. }
  508.  
  509. public OnPlayerUpdate(playerid)
  510. {
  511. return 1;
  512. }
  513.  
  514. public OnPlayerStreamIn(playerid, forplayerid)
  515. {
  516. return 1;
  517. }
  518.  
  519. public OnPlayerStreamOut(playerid, forplayerid)
  520. {
  521. return 1;
  522. }
  523.  
  524. public OnVehicleStreamIn(vehicleid, forplayerid)
  525. {
  526. return 1;
  527. }
  528.  
  529. public OnVehicleStreamOut(vehicleid, forplayerid)
  530. {
  531. return 1;
  532. }
  533.  
  534. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  535. {
  536. if(dialogid == dregister) //If dialog id is a register dialog
  537. {//then
  538. if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  539. if(response) //if they clicked the first button "Register"
  540. {//then
  541. if(!strlen(inputtext)) //If they didn't enter any password
  542. {// then we will tell to them to enter the password to register
  543. ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
  544. return 1;
  545. }
  546. //If they have entered a correct password for his/her account...
  547. new hashpass[129]; //Now we will create a new variable to hash his/her password
  548. WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
  549. new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
  550. INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  551. INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
  552. INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
  553. INI_WriteInt(file,"VIPLevel",0);//As explained above
  554. INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
  555. INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
  556. INI_WriteInt(file,"Kills",0);//As explained above
  557. INI_WriteInt(file,"Deaths",0);//As explained above
  558. INI_Close(file);//Now after we've done saving their data, we now need to close the file
  559. SendClientMessage(playerid,-1,"You successfuly created an account!");//Tell to them that they have successfully registered a new account
  560. return 1;
  561. }
  562. }
  563. if(dialogid == dlogin) //If dialog id is a login dialog
  564. {//then
  565. if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  566. if(response) //if they clicked the first button "Register"
  567. {//then
  568. new hashpass[129]; //Will create a new variable to hash his/her password
  569. WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
  570. if(!strcmp(hashpass,pInfo[playerid][Pass])) //If they have insert their correct password
  571. {//then
  572. INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
  573. SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
  574. GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
  575. SendClientMessage(playerid,-1,"You have successfully logged in");//Tell them that they've successfully logged in
  576. }
  577. else //If they've entered an incorrect password
  578. {//then
  579. ShowPlayerDialog(playerid,dlogin, DIALOG_STYLE_PASSWORD,""COL_GREEN"Login",""COL_RED"You have entered an{F81414} incorrect password.\n"COL_WHITE"Please try again","Login","Quit");
  580. return 1;
  581. }
  582. }
  583. }
  584. return 1;
  585. }
  586.  
  587. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  588. {
  589. return 1;
  590. }
  591.  
  592.  
  593. stock Path(playerid)
  594. {
  595. new str[128],name[MAX_PLAYER_NAME];
  596. GetPlayerName(playerid,name,sizeof(name));
  597. format(str,sizeof(str),UserPath,name);
  598. return str;
  599. }
  600.  
  601. public loadaccount_user(playerid, name[], value[])
  602. {
  603. INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
  604. ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
  605. INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
  606. INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
  607. INI_Int("Money",pInfo[playerid][Money]); //As explained above
  608. INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
  609. INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
  610. INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
  611. return 1;
  612. }
Advertisement
Add Comment
Please, Sign In to add comment