RyoKRZ

DriftGen

Apr 26th, 2014
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.33 KB | None | 0 0
  1. //--------------------------Don't Remove Credits--------------------------------
  2. //--------------------------I know you'll remove me from Credits----------------
  3. //--------------------------You can edit everything you want--------------------
  4. //--------------------------Just keep me in the Credits-------------------------
  5.  
  6.  
  7.  
  8. #include <a_samp>
  9.  
  10. #define Blue 0x02EAFDFF
  11. #define COLOR_CONNECT 0x80FF00FF
  12. #define COLOR_DISCONNECT 0xAFAFAFAA
  13.  
  14. new pname[20], filename[24];
  15. new File:user;
  16.  
  17.  
  18.  
  19. //-------------------Save load System Don't uncomment this line-----------------
  20. static Float:posx[MAX_PLAYERS] = 0.0;
  21. static Float:posy[MAX_PLAYERS] = 0.0;
  22. static Float:posz[MAX_PLAYERS] = 0.0;
  23. static Float:zangle[MAX_PLAYERS] = 0.0;
  24. //------------------Don't comment the upper lines-------------------------------
  25.  
  26. main()
  27. {
  28. print("\n----------------------------------");
  29. print(" Simple Gamemode by Ryo[KRZ]");
  30. print("----------------------------------\n");
  31. }
  32.  
  33. public OnGameModeInit()
  34. {
  35. SetGameModeText("Drift/Freeroam");
  36. UsePlayerPedAnims();
  37. AddPlayerClass(1, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  38. AddPlayerClass(2, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  39. AddPlayerClass(3, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  40. AddPlayerClass(4, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  41. AddPlayerClass(5, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  42. AddPlayerClass(6, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  43. AddPlayerClass(7, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  44. AddPlayerClass(8, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  45. AddPlayerClass(9, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  46. AddPlayerClass(10, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  47. AddPlayerClass(11, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  48. AddPlayerClass(12, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  49. AddPlayerClass(13, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  50. AddPlayerClass(14, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  51. AddPlayerClass(15, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  52. AddPlayerClass(16, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  53. AddPlayerClass(17, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  54. AddPlayerClass(18, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  55. AddPlayerClass(19, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  56. AddPlayerClass(20, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  57. AddPlayerClass(21, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  58. AddPlayerClass(22, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  59. AddPlayerClass(23, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  60. AddPlayerClass(24, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  61. AddPlayerClass(25, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  62. AddPlayerClass(26, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  63. AddPlayerClass(27, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  64. AddPlayerClass(28, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  65. AddPlayerClass(29, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  66. AddPlayerClass(30, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  67. AddPlayerClass(31, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  68. AddPlayerClass(32, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  69. AddPlayerClass(33, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  70. AddPlayerClass(34, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  71. AddPlayerClass(35, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  72. AddPlayerClass(36, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  73. AddPlayerClass(37, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  74. AddPlayerClass(38, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  75. AddPlayerClass(39, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  76. AddPlayerClass(40, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  77. AddPlayerClass(41, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  78. AddPlayerClass(42, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  79. AddPlayerClass(43, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  80. AddPlayerClass(44, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  81. AddPlayerClass(45, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  82. AddPlayerClass(46, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  83. AddPlayerClass(47, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  84. AddPlayerClass(48, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  85. AddPlayerClass(49, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  86. AddPlayerClass(50, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  87. return 1;
  88. }
  89.  
  90. public OnGameModeExit()
  91. {
  92. return 1;
  93. }
  94.  
  95. public OnPlayerConnect(playerid)
  96. {
  97. new jstring[128];
  98. new playername[MAX_PLAYER_NAME];
  99. GetPlayerName(playerid, playername, sizeof(playername));
  100. format(jstring, sizeof(jstring), "<<< %s is joining the server >>>", playername);
  101. SendClientMessageToAll(COLOR_CONNECT, jstring);
  102. GetPlayerName(playerid, pname, 20);
  103. format(filename, 24, "users/%s.txt", pname);
  104. if(!fexist(filename))
  105. {
  106. ShowPlayerDialog(playerid, 1, 1, "[DriftGen]", "Please type in a password:", "Register", "Cancel");
  107. }
  108. return 1;
  109. }
  110.  
  111. public OnPlayerDisconnect(playerid, reason)
  112. {
  113. new dstring[128];
  114. new playername[MAX_PLAYER_NAME];
  115. GetPlayerName(playerid, playername, sizeof(playername));
  116. switch(reason)
  117. {
  118. case 0: format(dstring, sizeof(dstring), "<<< %s has left the game ( Timeout/Crashed ) >>>", playername);
  119. case 1: format(dstring, sizeof(dstring), "<<< %s has left the game ( Leaving ) >>>", playername);
  120. case 2: format(dstring, sizeof(dstring), "<<< %s has left the game ( Kicked/Banned ) >>>", playername);
  121. }
  122. SendClientMessageToAll(COLOR_DISCONNECT, dstring);
  123. return 1;
  124. }
  125.  
  126. public OnPlayerSpawn(playerid)
  127. {
  128. SetPlayerInterior(playerid,0);
  129. SetPlayerVirtualWorld(playerid, 0);
  130. SetPlayerHealth(playerid,100);
  131. SetPlayerArmour(playerid,100);
  132. SetPlayerPos(playerid,-309.9230,1536.2162,75.5625);
  133. SetPlayerFacingAngle(playerid,146.2062);
  134. GivePlayerMoney(playerid, 50000);
  135. return 1;
  136. }
  137.  
  138. public OnPlayerDeath(playerid, killerid, reason)
  139. {
  140. GivePlayerMoney(playerid,-1000);
  141. GivePlayerMoney(killerid,1000);
  142. SendClientMessage(playerid, 0xFF6F6FFF,"You are killed, wait until you get respawned");
  143. SendClientMessage(killerid, 0xAFAFAFAA,"You killed a person, You got $1000");
  144. return 1;
  145. }
  146.  
  147. public OnVehicleSpawn(vehicleid)
  148. {
  149. return 1;
  150. }
  151.  
  152. public OnVehicleDeath(vehicleid, killerid)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerText(playerid, text[])
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerCommandText(playerid, cmdtext[])
  163. {
  164. new tmp[128];
  165. new cmd[256];
  166. new idx;
  167. cmd = strtok(cmdtext, idx);
  168.  
  169. if(strcmp(cmd, "/lvair", true) == 0)
  170. {
  171. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  172. {
  173. SetVehiclePos(GetPlayerVehicleID(playerid), 1433.4521, 1504.1399, 10.8203);
  174. }
  175. else
  176. {
  177. SetPlayerPos(playerid, 1433.4521, 1504.1399, 10.8203);
  178. }
  179. return 1;
  180. }
  181. if(strcmp(cmd, "/sf", true) == 0)
  182. {
  183. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  184. {
  185. SetVehiclePos(GetPlayerVehicleID(playerid), -1898.6420,243.1353,41.0469);
  186. }
  187. else
  188. {
  189. SetPlayerPos(playerid, -1898.6420,243.1353,41.0469);
  190. }
  191. return 1;
  192. }
  193. if(strcmp(cmd, "/ls", true) == 0)
  194. {
  195. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  196. {
  197. SetVehiclePos(GetPlayerVehicleID(playerid), 1535.9197,-1679.2443,13.3828);
  198. }
  199. else
  200. {
  201. SetPlayerPos(playerid, 1535.9197,-1679.2443,13.3828);
  202. }
  203. return 1;
  204. }
  205. if(strcmp(cmd, "/lv", true) == 0)
  206. {
  207. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  208. {
  209. SetVehiclePos(GetPlayerVehicleID(playerid), 2045.2657,1343.9778,10.6719);
  210. }
  211. else
  212. {
  213. SetPlayerPos(playerid, 2045.2657,1343.9778,10.6719);
  214. }
  215. return 1;
  216. }
  217. if (strcmp(cmdtext, "/arch", true) == 0)
  218. {
  219. if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  220. {
  221. SetVehiclePos(GetPlayerVehicleID(playerid), -2704.4775,217.2848,3.8375);
  222. SetVehicleZAngle(GetPlayerVehicleID(playerid), 90);
  223. }
  224. else
  225. {
  226. SetPlayerPos(playerid, -2714.2739,204.8123,4.3281);
  227. SetPlayerFacingAngle(playerid, 0);
  228. }
  229. SetCameraBehindPlayer(playerid);
  230. return 1;
  231. }
  232. if (strcmp(cmdtext, "/trans", true) == 0)
  233. {
  234. if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  235. {
  236. SetVehiclePos(GetPlayerVehicleID(playerid), -1936.360839, 225.120300, 33.814777);
  237. SetVehicleZAngle(GetPlayerVehicleID(playerid), 357.421691);
  238. }
  239. else
  240. {
  241. SetPlayerPos(playerid, -1936.360839, 225.120300, 33.814777);
  242. SetPlayerFacingAngle(playerid, 357.421691);
  243. }
  244. SetCameraBehindPlayer(playerid);
  245. return 1;
  246. }
  247. if(strcmp(cmdtext, "/cmds", true) == 0)
  248. {
  249. SendClientMessage(playerid,Blue,"[DriftGen]: /Lvair, /Ls, /Sf, /Lv, /Arch, /Trans, /Afk, /Back, /Credits");
  250. SendClientMessage(playerid,Blue,"[DriftGen]: /Pc, /Me, /Carcolour, /S(saveplace), /L(LoadPlace), /Kill");
  251. return 1;
  252. }
  253. if(strcmp(cmdtext, "/afk", true) == 0)
  254. {
  255. SendClientMessage(playerid, 0xAFAFAFAA,"<<< You are now afk ( Away from Keyboard ), type /back to move again >>>");
  256. TogglePlayerControllable(playerid,0);
  257. new string1[128];
  258. new name[MAX_PLAYER_NAME];
  259. GetPlayerName(playerid, name, sizeof(name));
  260. format(string1,sizeof(string1), "<<< %s is now afk ( Away from Keyboard ) >>>", name);
  261. SendClientMessageToAll(Blue, string1);
  262. return 1;
  263. }
  264. if(strcmp(cmdtext, "/back", true) == 0)
  265. {
  266. SendClientMessage(playerid, 0xAFAFAFAA,"<<< You are no longer afk ( Away from Keyboard ) >>>");
  267. TogglePlayerControllable(playerid, 1);
  268. new string1[128];
  269. new name[MAX_PLAYER_NAME];
  270. GetPlayerName(playerid, name, sizeof(name));
  271. format(string1,sizeof(string1), "<<< %s is no longer afk ( Away from Keyboard ) >>>", name);
  272. SendClientMessageToAll(Blue, string1);
  273. return 1;
  274. }
  275. if(strcmp(cmdtext, "/pc", true) == 0)
  276. {
  277. GivePlayerWeapon(playerid, 46, 1);
  278. return 1;
  279. }
  280. if(!strcmp(cmdtext, "/me", true, 3))
  281. {
  282. if(!cmdtext[3])return SendClientMessage(playerid, 0xAFAFAFAA, "[DriftGen]: /me [action]");
  283. new str[128];
  284. GetPlayerName(playerid, str, sizeof(str));
  285. format(str, sizeof(str), "* %s %s *", str, cmdtext[4]);
  286. SendClientMessageToAll(0xA8A8FFAA, str);
  287. return 1;
  288. }
  289. if(strcmp(cmd, "/carcolour", true) == 0)
  290. {
  291. new color1, color2;
  292. tmp = strtok(cmdtext, idx);
  293. if(!strlen(tmp)) return SendClientMessage(playerid, 0xAFAFAFAA, "[DriftGen]: /carcolour [color1] [color2]");
  294. color1 = strval(tmp);
  295. tmp = strtok(cmdtext, idx);
  296. if(!strlen(tmp)) return SendClientMessage(playerid, 0xAFAFAFAA, "[DriftGen]: /carcolour [color1] [color2]");
  297. color2 = strval(tmp);
  298. ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
  299. return 1;
  300. }
  301. if(strcmp(cmd, "/credits", true) == 0)
  302. {
  303. SendClientMessage(playerid,Blue,"<<< Scripted and tested fully working >>>");
  304. SendClientMessage(playerid,Blue,"<<< Gamemode by Ryo[KRZ] >>>");
  305. return 1;
  306. }
  307. if(strcmp(cmdtext, "/s", true) == 0)
  308. {
  309. SendClientMessage(playerid, Blue,"[DriftGen]: <<< Your current position has been saved, /l to get back here >>>");
  310. if(IsPlayerInAnyVehicle(playerid))
  311. {
  312. new VehicleID;
  313. VehicleID = GetPlayerVehicleID(playerid);
  314. GetVehiclePos(VehicleID, posx[playerid], posy[playerid], posz[playerid]);
  315. GetVehicleZAngle(VehicleID, zangle[playerid]);
  316. } else {
  317. GetPlayerPos(playerid, posx[playerid], posy[playerid], posz[playerid]);
  318. GetPlayerFacingAngle(playerid, zangle[playerid]);
  319. }
  320. return 1;
  321. }
  322. if(strcmp(cmdtext, "/l", true) == 0)
  323. {
  324. SendClientMessage(playerid, COLOR_CONNECT, "[DriftGen]: <<< Your Saved position was loaded >>>");
  325. if(IsPlayerInAnyVehicle(playerid))
  326. {
  327. new VehicleID = GetPlayerVehicleID(playerid);
  328. SetVehiclePos(VehicleID, posx[playerid], posy[playerid], posz[playerid]);
  329. SetVehicleZAngle(VehicleID, zangle[playerid]);
  330. }
  331. else
  332. {
  333. SetPlayerPos(playerid, posx[playerid], posy[playerid], posz[playerid]);
  334. SetPlayerFacingAngle(playerid, zangle[playerid]);
  335. }
  336. return 1;
  337. }
  338. if(strcmp(cmd, "/kill", true) == 0)
  339. {
  340. SetPlayerHealth(playerid, 0);
  341. SpawnPlayer(playerid);
  342. return 1;
  343. }
  344. return 0;
  345. }
  346.  
  347. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  348. {
  349. return 1;
  350. }
  351.  
  352.  
  353. public OnPlayerStateChange(playerid, newstate, oldstate)
  354. {
  355. return 1;
  356. }
  357.  
  358.  
  359. public OnPlayerRequestSpawn(playerid)
  360. {
  361. return 1;
  362. }
  363.  
  364. public OnPlayerPickUpPickup(playerid, pickupid)
  365. {
  366. return 1;
  367. }
  368.  
  369. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  370. {
  371.  
  372. if(dialogid == 1)
  373. {
  374. if(response == 0)
  375. {
  376. SendClientMessage(playerid, Blue, "<<< You have been disconnected due to not logging in >>>");
  377. Kick(playerid);
  378. return 1;
  379. }
  380. user = fopen(filename, io_write);
  381. fwrite(user, inputtext);
  382. fclose(user);
  383. new jstring[128];
  384. new playername[MAX_PLAYER_NAME];
  385. GetPlayerName(playerid, playername, sizeof(playername));
  386. format(jstring, sizeof(jstring), "<<< %s has logged in to the server >>>", playername);
  387. SendClientMessageToAll(COLOR_CONNECT, jstring);
  388.  
  389. }
  390. return 1;
  391. }
  392.  
  393. forward SetupPlayerForClassSelection(playerid);
  394. public SetupPlayerForClassSelection(playerid)
  395. {
  396. SetPlayerInterior(playerid,14);
  397. SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
  398. SetPlayerFacingAngle(playerid, 270.0);
  399. SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
  400. SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
  401. }
  402.  
  403. public OnPlayerRequestClass(playerid, classid)
  404. {
  405. SetPlayerPos(playerid, 2520.1550,-1671.1104,19.4203);
  406. SetPlayerFacingAngle(playerid,270);
  407. SetPlayerCameraPos(playerid, 2524.1550,-1671.1104,19.9203);
  408. SetPlayerCameraLookAt(playerid, 2520.1550,-1671.1104,19.4203);
  409. return 1;
  410. }
  411.  
  412.  
  413. strtok(const string[], &index)
  414. {
  415. new length = strlen(string);
  416. while ((index < length) && (string[index] <= ' '))
  417. {
  418. index++;
  419. }
  420.  
  421. new offset = index;
  422. new result[30];
  423. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  424. {
  425. result[index - offset] = string[index];
  426. index++;
  427. }
  428. result[index - offset] = EOS;
  429. return result;
  430. }
Advertisement
Add Comment
Please, Sign In to add comment