Advertisement
Guest User

Untitled

a guest
Oct 29th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.03 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <ZCMD>
  7. #include <foreach>
  8. #include <sscanf2>
  9. #include <YSI\y_ini>
  10.  
  11. #define COLOR_GREY 0xAFAFAFAA
  12. #define COLOR_GREEN 0x33AA33AA
  13. #define COLOR_RED 0xAA3333AA
  14. #define COLOR_YELLOW 0xFFFF00AA
  15. #define COLOR_WHITE 0xFFFFFFAA
  16. #define COLOR_BLUE 0x0000BBAA
  17. #define COLOR_LIGHTBLUE 0x33CCFFAA
  18. #define COLOR_ORANGE 0xFF9900AA
  19. #define COLOR_RED 0xAA3333AA
  20. #define COLOR_LIME 0x10F441AA
  21. #define COLOR_MAGENTA 0xFF00FFFF
  22. #define COLOR_NAVY 0x000080AA
  23. #define COLOR_AQUA 0xF0F8FFAA
  24. #define COLOR_CRIMSON 0xDC143CAA
  25. #define COLOR_FLBLUE 0x6495EDAA
  26. #define COLOR_BISQUE 0xFFE4C4AA
  27. #define COLOR_BLACK 0x000000AA
  28. #define COLOR_CHARTREUSE 0x7FFF00AA
  29. #define COLOR_BROWN 0XA52A2AAA
  30. #define COLOR_CORAL 0xFF7F50AA
  31. #define COLOR_GOLD 0xB8860BAA
  32. #define COLOR_GREENYELLOW 0xADFF2FAA
  33. #define COLOR_INDIGO 0x4B00B0AA
  34. #define COLOR_IVORY 0xFFFF82AA
  35. #define COLOR_LAWNGREEN 0x7CFC00AA
  36. #define COLOR_SEAGREEN 0x20B2AAAA
  37. #define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
  38. #define COLOR_MIDNIGHTBLUE 0X191970AA
  39. #define COLOR_MAROON 0x800000AA
  40. #define COLOR_OLIVE 0x808000AA
  41. #define COLOR_ORANGERED 0xFF4500AA
  42. #define COLOR_PINK 0xFFC0CBAA // - Light light pink
  43. #define COLOR_SPRINGGREEN 0x00FF7FAA
  44. #define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
  45. #define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
  46. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  47. #define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
  48.  
  49. #define PRESSED(%0) \
  50. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) //Detecting keys
  51.  
  52. #define TEAM_POLICE 0
  53. #define TEAM_TRUCKER 1
  54.  
  55. #define dregister 2011 //Defining register dialog so it won't mixed up with the other dialogs
  56. #define dlogin 2012 //Defining login dialog so it won't mixed up with the other dialogs
  57. #define UserPath "Users/%s.ini" /*Will define user's account path. In this case, we will save it in Scriptfiles/Users. So create a file inside of your Scriptfiles folder called Users*/
  58.  
  59. native WP_Hash(buffer[],len,const str[]); // Whirlpool native, add it at the top of your script under includes
  60.  
  61. //We will create an enum to store player's data.
  62. enum PlayerInfo
  63. {
  64. Pass[129], //User's password
  65. Adminlevel, //User's admin level
  66. VIPlevel, //User's vip level
  67. Money, //User's money
  68. Scores, //User's scores
  69. Kills, //User's kills
  70. Deaths //User's deaths
  71. }
  72. new pInfo[MAX_PLAYERS][PlayerInfo]; /*This will create a new variable so we can later use it to saving/loading user's info.*/
  73.  
  74. stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
  75. {
  76. new str[128],name[MAX_PLAYER_NAME];
  77. GetPlayerName(playerid,name,sizeof(name));
  78. format(str,sizeof(str),UserPath,name);
  79. return str;
  80. }
  81.  
  82. forward loadaccount_user(playerid, name[], value[]); //forwarding a new function to load user's data
  83. //Now we will use our own function that we have created above
  84. public loadaccount_user(playerid, name[], value[])
  85. {
  86. INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
  87. ("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*/
  88. 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. */
  89. INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
  90. INI_Int("Money",pInfo[playerid][Money]); //As explained above
  91. INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
  92. INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
  93. INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
  94. return 1;
  95. }
  96.  
  97. new Engine[MAX_VEHICLES], Lights[MAX_VEHICLES];
  98.  
  99. new Text:td_fuel[MAX_PLAYERS];
  100. new Text:td_vhealth[MAX_PLAYERS];
  101. new Text:td_box[MAX_PLAYERS];
  102.  
  103. forward timer_refuel(playerid);
  104. forward timer_fuel_lower();
  105. new isrefuelling[MAX_PLAYERS] = 0;
  106. new fuel[MAX_VEHICLES];
  107. new Float:max_vhealth[MAX_VEHICLES];
  108.  
  109. new iMissionText[512][MAX_PLAYERS], Float:unx[MAX_PLAYERS], Float:uny[MAX_PLAYERS], Float:unz[MAX_PLAYERS], iPay[MAX_PLAYERS], MissionStatus[MAX_PLAYERS];
  110.  
  111. new gTeam[MAX_PLAYERS];
  112.  
  113. new Float:svx[MAX_PLAYERS]; // Holds Velocity X
  114. new Float:svy[MAX_PLAYERS]; // Holds Velocity Y
  115. new Float:svz[MAX_PLAYERS]; // Holds Velocity Z
  116. new Float:sp1[MAX_PLAYERS]; // This Is What Our Forumula Outputs
  117. new sp2[MAX_PLAYERS]; // This Is The Output When The Forumula's Ouput Is Round
  118. new sp3[MAX_PLAYERS][256]; // This Is The Text That Is Displayed To The User
  119. new Text:sdisplay[MAX_PLAYERS]; // This Holds The Textdraw's ID
  120. new stimer[MAX_PLAYERS]; // This Holds The Timer's ID (Used To Refresh Speed)
  121.  
  122. forward speedometer(playerid); // This Forwards The Timer To Our Function
  123.  
  124. stock ProxDetector(Float:radi, playerid, string[],color)
  125. {
  126. new Float:x,Float:y,Float:z;
  127. GetPlayerPos(playerid,x,y,z);
  128. foreach(Player,i)
  129. {
  130. if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
  131. {
  132. SendClientMessage(i,color,string);
  133. }
  134. }
  135. }
  136.  
  137. stock GetName(playerid)
  138. {
  139. new getthename[MAX_PLAYER_NAME];
  140. GetPlayerName(playerid,getthename,sizeof(getthename));
  141. return getthename;
  142. }
  143.  
  144. forward MSG();
  145.  
  146. new Text:ServerMSG;
  147.  
  148. new RMessages[][] =
  149. {
  150. "~y~Random News: ~w~Hei på deg",
  151. "~y~Random News: ~w~Gulost",
  152. "~y~Random News: ~w~dont worry, be happy",
  153. "~y~Random News: ~w~Karl :)",
  154. "~y~Random News: ~w~Hade"
  155. };
  156.  
  157. new
  158. afk[ MAX_PLAYERS char ]
  159. ;
  160.  
  161. enum MisLocationsEnum
  162. {
  163. ID,
  164. LoadName[128],
  165. Float:LoadX,
  166. Float:LoadY,
  167. Float:LoadZ,
  168. Float:UnloadX,
  169. Float:UnloadY,
  170. Float:UnloadZ,
  171. Pay
  172. }
  173.  
  174. new MisLocations[][MisLocationsEnum] =
  175. {
  176. {0, "Beer from Red County Brewery to Bone County Diner",-24.4073,-281.8898,5.9985,-305.4319,1315.6797,54.6189, 5980},
  177. {1, "Fuel from LV Oil Refinery to LV Dirtring",266.8981,1416.5417,10.2001,1097.5164,1741.7422,10.5474, 5700},
  178. {2, "Vehicle Parts from SF Airport ATC to Wang Cars",-1268.8223,13.6925,14.8682,-1986.3477,253.9728,35.8985, 3000},
  179. {3, "Fuel from SF Oil Refinery to RS Haul",-1016.3634,-688.2434,32.7284,-55.3397,-1138.2479,0.8052, 18770}//The last one in the array doesn't have a comma at the end.
  180. };
  181.  
  182. main()
  183. {
  184. print("\n----------------------------------");
  185. print(" Min super gamemode");
  186. print("----------------------------------\n");
  187. }
  188.  
  189. public OnGameModeInit()
  190. {
  191. SetGameModeText("Min Super Gamemode");
  192. UsePlayerPedAnims();
  193. ManualVehicleEngineAndLights();//Instead of vehicle engines and lights automatic, they are now manual.
  194. AddPlayerClass(72, 2134.8254,-2147.6038,13.7015,212.6795, 0,0,0,0,0,0);
  195. AddPlayerClass(282, 2502.7112,2772.9893,10.8203,272.5301, 0,0,0,0,0,0);
  196. for(new i=0;i<MAX_VEHICLES;i++) {
  197. GetVehicleHealth(i,max_vhealth[i]); //getting max health
  198. fuel[i] = 250 + random(150); //setting fuel for vehicles
  199. }
  200.  
  201. for(new i=0;i<MAX_PLAYERS;i++) { //setting up all textdraws
  202. ServerMSG = TextDrawCreate(7.000000, 427.000000, "You don't need to add any text here");
  203. TextDrawBackgroundColor(ServerMSG, 255);
  204. TextDrawFont(ServerMSG, 1);
  205. TextDrawLetterSize(ServerMSG, 0.379999, 1.499999);
  206. TextDrawColor(ServerMSG, -1);
  207. TextDrawSetOutline(ServerMSG, 1);
  208. TextDrawSetProportional(ServerMSG, 1);
  209. td_fuel[i] = TextDrawCreate(476,355,"Fuel:");
  210. td_vhealth[i] = TextDrawCreate(478,376,"Health:");
  211. sdisplay[i] = TextDrawCreate(478,397,"Speed:"); // This Creates Our Textdraw And Stores The Id In The Varible In Front
  212. td_box[i] = TextDrawCreate(478.000000,328.000000,"Vehicle Stats: ~n~~n~~n~~n~");
  213. TextDrawUseBox(td_box[i],1);
  214. TextDrawBoxColor(td_box[i],0x00000066);
  215. TextDrawTextSize(td_box[i],626.000000,21.000000);
  216. TextDrawAlignment(td_fuel[i],0);
  217. TextDrawAlignment(td_vhealth[i],0);
  218. TextDrawAlignment(sdisplay[i],0);
  219. TextDrawAlignment(td_box[i],0);
  220. TextDrawBackgroundColor(td_fuel[i],0x000000ff);
  221. TextDrawBackgroundColor(td_vhealth[i],0x000000ff);
  222. TextDrawBackgroundColor(sdisplay[i],0x000000ff);
  223. TextDrawBackgroundColor(td_box[i],0x000000cc);
  224. TextDrawFont(td_fuel[i],1);
  225. TextDrawLetterSize(td_fuel[i],0.699999,2.699999);
  226. TextDrawFont(td_vhealth[i],1);
  227. TextDrawLetterSize(td_vhealth[i],0.699999,2.699999);
  228. TextDrawFont(sdisplay[i],1);
  229. TextDrawLetterSize(sdisplay[i],0.699999,2.699999);
  230. TextDrawFont(td_box[i],0);
  231. TextDrawLetterSize(td_box[i],0.699999,2.899999);
  232. TextDrawColor(td_fuel[i],0xffffffff);
  233. TextDrawColor(td_vhealth[i],0xffffffff);
  234. TextDrawColor(sdisplay[i],0xffffffff);
  235. TextDrawColor(td_box[i],0xffffffff);
  236. TextDrawSetOutline(td_fuel[i],1);
  237. TextDrawSetOutline(td_vhealth[i],1);
  238. TextDrawSetOutline(sdisplay[i],1);
  239. TextDrawSetOutline(td_box[i],1);
  240. TextDrawSetProportional(td_fuel[i],1);
  241. TextDrawSetProportional(td_vhealth[i],1);
  242. TextDrawSetProportional(sdisplay[i],1);
  243. TextDrawSetProportional(td_box[i],1);
  244. TextDrawSetShadow(td_fuel[i],1);
  245. TextDrawSetShadow(td_vhealth[i],1);
  246. TextDrawSetShadow(sdisplay[i],1);
  247. TextDrawSetShadow(td_box[i],10);
  248. }
  249. SetTimer("timer_update",100,true);
  250. SetTimer("timer_fuel_lower",8200,true);
  251. SetTimer("RandomMessage",8000,1); // 8000 is for 8 seconds, if you want 50 seconds use 50000
  252.  
  253. CreateVehicle(515,2503.0000000,2760.1999500,12.0000000,270.0000000,208,13,15); //Roadtrain
  254.  
  255. return 1;
  256. }
  257.  
  258. public MSG()
  259. {
  260. TextDrawSetString(ServerMSG, RMessages[random(sizeof(RMessages))]);
  261. return 1;
  262. }
  263.  
  264. public OnGameModeExit()
  265. {
  266. return 1;
  267. }
  268.  
  269. SetPlayerTeamFromClass(playerid, classid);
  270. public OnPlayerRequestClass(playerid, classid)
  271. {
  272. SetPlayerTeamFromClass(playerid, classid);
  273. SetPlayerPos(playerid, 2527.1042,-1664.5869,15.1666);
  274. SetPlayerFacingAngle(playerid,180);
  275. SetPlayerCameraPos(playerid,2526.9868,-1666.8330,15.1683);
  276. SetPlayerCameraLookAt(playerid,2527.1042,-1664.5869,15.1666);
  277. return 1;
  278. }
  279.  
  280. /*OnPlayerConnect will be called when players is connected to your server. So now we will need to show a register or login dialog*/
  281. public OnPlayerConnect(playerid)
  282. {
  283. 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.
  284. GetPlayerName(playerid,name,sizeof(name)); //Get player's name
  285. 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)),*/
  286. {// then
  287. INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
  288. ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
  289. }
  290. else //If the connected user is not registered,
  291. {//then we will 'force' him to register :)
  292. ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
  293. return 1;
  294. }
  295. return 1;
  296. }
  297.  
  298. public speedometer(playerid) {
  299. GetVehicleVelocity(GetPlayerVehicleID(playerid), svx[playerid], svy[playerid], svz[playerid]); // This Saves Our Velocitys To Our Varibles
  300. sp1[playerid] = floatsqroot(((svx[playerid]*svx[playerid])+(svy[playerid]*svy[playerid]))+(svz[playerid]*svz[playerid]))*136.666667; // This Is Our Forumula ( I Don't Know How It Works )
  301. sp2[playerid] = floatround(sp1[playerid],floatround_round); // This Rounds Our Output To The Nearest Whole Number
  302. format(sp3[playerid],256,"Speed: %i KM/H", sp2[playerid]); // This Format Our Text Into What We See
  303. TextDrawSetString(sdisplay[playerid], sp3[playerid]); // This Changes The Value Of Our Textdraw To What We Formatted
  304. return 1;
  305. }
  306.  
  307. public OnPlayerDisconnect(playerid, reason)
  308. {
  309. //Same as OnDialogResponse, we will save their stats inside of their user's account
  310. new INI:file = INI_Open(Path(playerid)); //will open their file
  311. INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  312. 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
  313. INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
  314. INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
  315. INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
  316. INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
  317. INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
  318. INI_Close(file);//Now after we've done saving their data, we now need to close the file
  319. return 1;
  320. }
  321.  
  322. CMD:pm(playerid, params[])
  323. {
  324. new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
  325. if(sscanf(params, "us", id, str2))
  326. {
  327. SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
  328. return 1;
  329. }
  330. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "The player is not connected");
  331. if(playerid == id) return SendClientMessage(playerid, COLOR_RED, "You can't pm yourself!");
  332. {
  333. GetPlayerName(playerid, Name1, sizeof(Name1));
  334. GetPlayerName(id, Name2, sizeof(Name2));
  335. format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
  336. SendClientMessage(playerid, COLOR_LIME, str);
  337. format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
  338. SendClientMessage(id, COLOR_LIME, str);
  339. }
  340. return 1;
  341. }
  342.  
  343. CMD:me(playerid, params[])
  344. {
  345. new string[128], action[100];
  346. if(sscanf(params, "s[100]", action))
  347. {
  348. SendClientMessage(playerid, -1, "USAGE: /me [action]");
  349. return 1;
  350. }
  351. else
  352. {
  353. format(string, sizeof(string), "* %s %s", GetName(playerid));
  354. ProxDetector(30, playerid, string, COLOR_WHITE);
  355. }
  356. return 1;
  357. }
  358.  
  359. CMD:do(playerid, params[])
  360. {
  361. new string[128], action[100];
  362. if(sscanf(params, "s[100]", action))
  363. {
  364. SendClientMessage(playerid, -1, "USAGE: /do [action]");
  365. return 1;
  366. }
  367. else
  368. {
  369. format(string, sizeof(string), "* %s (( %s ))", action, GetName(playerid));
  370. ProxDetector(30, playerid, string, COLOR_WHITE);
  371. }
  372. return 1;
  373. }
  374.  
  375. CMD:shout(playerid, params[])
  376. {
  377. new string[128], shout[100];
  378. if(sscanf(params, "s[100]", shout))
  379. {
  380. SendClientMessage(playerid, -1, "USAGE: /(s)hout [message]");
  381. return 1;
  382. }
  383. else
  384. {
  385. format(string, sizeof(string), "%s shouts: %s!",GetName(playerid),shout);
  386. ProxDetector(50.0, playerid, string, -1);
  387. }
  388. return 1;
  389. }
  390.  
  391. CMD:b(playerid, params[])
  392. {
  393. new string[128], text[100];
  394. if(sscanf(params, "s[100]", text)) return SendClientMessage(playerid, -1, "USAGE: /b [TEXT]");
  395. format(string, sizeof(string), "(( %s says: %s ))", GetName(playerid), text);
  396. ProxDetector(30.0, playerid, string, COLOR_WHITE);
  397. return 1;
  398. }
  399.  
  400. CMD:afk(playerid, params[]) {
  401. new name[MAX_PLAYER_NAME], string[128];
  402. GetPlayerName(playerid, name, sizeof(name));
  403. if( afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - You're already afk!");
  404. else
  405. {
  406. afk{ playerid } = true;
  407. SetPlayerHealth(playerid, 99999);
  408. SetPlayerArmour(playerid, 99999);
  409. TogglePlayerControllable(playerid, 0);
  410. format(string, sizeof(string), "[AFK] - %s is now afk!", name);
  411. SendClientMessageToAll(COLOR_ORANGE, string);
  412. SendClientMessage(playerid, COLOR_ORANGE, "[AFK] - When you come back, use /back!");
  413. }
  414. return 1;
  415. }
  416.  
  417. CMD:back(playerid, params[]) {
  418. if( !afk{ playerid } ) SendClientMessage(playerid, COLOR_ORANGE, "[BACK] - You aren't afk!");
  419. else
  420. {
  421. new name[MAX_PLAYER_NAME], string[128];
  422. GetPlayerName(playerid, name, sizeof(name));
  423. SetPlayerHealth(playerid, 99);
  424. SetPlayerArmour(playerid, 99);
  425. TogglePlayerControllable(playerid, 1);
  426. format(string, sizeof(string), "[BACK] - %s is now back!", name);
  427. SendClientMessageToAll(COLOR_GREEN, string);
  428. SendClientMessage(playerid, COLOR_GREEN, "[BACK] - Welcome back!");
  429. afk{ playerid } = false;
  430. }
  431. return 1;
  432. }
  433.  
  434. CMD:smoke(playerid, params[])
  435. {
  436. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_SMOKE_CIGGY);
  437. return 1;
  438. }
  439.  
  440. CMD:rules(playerid, params[])
  441. {
  442. ShowPlayerDialog(playerid, 999, DIALOG_STYLE_MSGBOX, "My Server Rules", "No Hacking Or Advertising\nNo Cbugging or Stop Animation\nNo Insulting other Player\nNo Car Ramming or HeliKilling\nNo Using 3rd Party tools that give player more advantage\nPlease Follow these rules", "Ok","");
  443. return 1;
  444. }
  445.  
  446. CMD:repair(playerid, params[])
  447. {
  448. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a vehicle!");
  449. if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You are not in the driver seat!");
  450. RepairVehicle(GetPlayerVehicleID(playerid));
  451. SendClientMessage(playerid, COLOR_GREEN, "Your vehicle has been sucessfully repaired.");
  452. PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
  453. return 1;
  454. }
  455.  
  456. CMD:flip(playerid, params[])
  457. {
  458. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be in a vehicle.");
  459. {
  460. new vehicle;
  461. new Float:zangle;
  462. vehicle = GetPlayerVehicleID(playerid);
  463. GetVehicleZAngle(vehicle,zangle);
  464. SetVehicleZAngle(vehicle,zangle);
  465. SendClientMessage(playerid,COLOR_GREEN,"Vehicle succesfully flipped.");
  466. }
  467. return 1;
  468. }
  469.  
  470. CMD:work(playerid, params[])
  471. {
  472. if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return T_NewJob(playerid);
  473. return 1;
  474. }
  475.  
  476. CMD:stopwork(playerid, params[])
  477. {
  478. if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return StopWork(playerid);
  479. return 1;
  480. }
  481.  
  482. stock T_NewJob(playerid)
  483. {
  484. new vID = GetPlayerVehicleID(playerid); //gets called on the next line
  485. if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)//this checks wether the player is in a Roadtrain, Tanker or Linerunner
  486. {
  487. if(IsTrailerAttachedToVehicle(vID))// This checks wether the player has a trailer attached
  488. {
  489. MissionStatus[playerid] = 1;// this sets the players mission status as 1 - So they are on a mission.
  490. new MisRand = random(sizeof(MisLocations));// this is the line that will call a random mission.
  491. new LoadText[128], Float:x, Float:y, Float:z;// these are where we will store each co-ord and the text for the mission
  492. x = MisLocations[MisRand][LoadX];//this sets one of the above
  493. y = MisLocations[MisRand][LoadY];//this sets one of the above
  494. z = MisLocations[MisRand][LoadZ];//this sets one of the above
  495. unx[playerid] = MisLocations[MisRand][UnloadX];//these set what we made in step 10.
  496. uny[playerid] = MisLocations[MisRand][UnloadY];//these set what we made in step 10.
  497. unz[playerid] = MisLocations[MisRand][UnloadZ];//these set what we made in step 10.
  498. iPay[playerid] = MisLocations[MisRand][Pay];//these set what we made in step 10.
  499. SetPlayerCheckpoint(playerid, x, y, z, 7);//This creates the checkpoint that the player will enter.
  500. format(LoadText, 128, "%s",MisLocations[MisRand][LoadName]);// this is formatting the text the player will see in the console
  501. SendClientMessage(playerid, COLOR_GREEN, "Mission:");//sends message in console
  502. SendClientMessage(playerid, COLOR_GREEN, "_____________________");//sends message in console
  503. SendClientMessage(playerid, COLOR_GREEN, "");//sends message in console
  504. SendClientMessage(playerid, 0xFFFFFFFF, LoadText);//sends the text we formatted earlier in console
  505. SendClientMessage(playerid, COLOR_GREEN, "_____________________");//sends message in console
  506. }
  507. else//if the player doesnt have a trailer attached
  508. {
  509. SendClientMessage(playerid, COLOR_RED, "You need a trailer!");//sends message in console
  510. }
  511. }
  512. else//if the player isnt in a truck
  513. {
  514. SendClientMessage(playerid, COLOR_RED, "You must be in a Truck to perform this!");//sends message in console
  515. }
  516. return 1;
  517. }
  518.  
  519. stock StopWork(playerid)
  520. {
  521. DisablePlayerCheckpoint(playerid);
  522. SendClientMessage(playerid, COLOR_RED, "You chose to cancel the mission and got fined $3000");
  523. GivePlayerMoney(playerid, -3000);
  524. MissionStatus[playerid] = 0;
  525. return 1;
  526. }
  527.  
  528. CMD:unlock(playerid, params[])
  529. {
  530. new engine, lights, alarm, doors, bonnet, boot, objective;
  531. new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
  532. if(IsPlayerInAnyVehicle(playerid))//Thsi will check that is a player In a vehcile or not.
  533. {
  534. GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the vehicle lock.
  535. if(doors == 1)//will check if the doors are already loocked it not.
  536. {
  537. GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  538. SetVehicleParamsEx(vehicleid,engine,lights,alarm,false,bonnet,boot,objective);//same as the engine one.
  539. GameTextForPlayer(playerid,"Vehicle unlocked!",2000,6);//for a text to appar on the screen for only 2 seconds.
  540. return 1;
  541. }
  542. }
  543. else
  544. {
  545. SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//the error message.
  546. }
  547. return 1;
  548. }
  549.  
  550. CMD:lock(playerid, params[])
  551. {
  552. new engine, lights, alarm, doors, bonnet, boot, objective;
  553. new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
  554. if(IsPlayerInAnyVehicle(playerid))//Thsi will check that is a player In a vehcile or not.
  555. {
  556. GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the vehicle lock.
  557. if(doors == 0)//will check if the doors are already loocked it not.
  558. {
  559. GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
  560. SetVehicleParamsEx(vehicleid,engine,lights,alarm,true,bonnet,boot,objective);//same as the engine one.
  561. GameTextForPlayer(playerid,"Vehicle locked!",2000,6);//for a text to appar on the screen for only 2 seconds.
  562. return 1;
  563. }
  564. }
  565. else
  566. {
  567. SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//the error message.
  568. }
  569. return 1;
  570. }
  571.  
  572. //------------------------------------------------------------------END OF COMMANDS-----------------------------------------------------------//
  573. //--------------------------------------------------------------------------------------------------------------------------------------------//
  574. SetPlayerToTeamColor(playerid);
  575. public OnPlayerSpawn(playerid)
  576. {
  577. TextDrawShowForPlayer(playerid, ServerMSG);
  578. SetPlayerToTeamColor(playerid);
  579. return 1;
  580. }
  581.  
  582. public OnPlayerDeath(playerid, killerid, reason)
  583. {
  584. pInfo[killerid][Kills]++;//Will give 1 kill to killer and it will be saved inside of his/her account
  585. pInfo[playerid][Deaths]++;//Will give 1 death each time they die and it will be saved inside of his/her account
  586. return 1;
  587. }
  588.  
  589. public OnVehicleSpawn(vehicleid)
  590. {
  591. Engine[vehicleid] = 0;
  592. Lights[vehicleid] = 0;
  593. return 1;
  594. }
  595.  
  596. public OnVehicleDeath(vehicleid, killerid)
  597. {
  598. return 1;
  599. }
  600.  
  601. public OnPlayerText( playerid, text[] )
  602. {
  603. return 1;
  604. }
  605.  
  606. public OnPlayerCommandText(playerid, cmdtext[])
  607. {
  608. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  609. {
  610. // Do something here
  611. return 1;
  612. }
  613. return 0;
  614. }
  615.  
  616. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  617. {
  618. return 1;
  619. }
  620.  
  621. public OnPlayerExitVehicle(playerid, vehicleid)
  622. {
  623. return 1;
  624. }
  625.  
  626. public OnPlayerStateChange(playerid, newstate, oldstate)
  627. {
  628. KillTimer(stimer[playerid]); // This Stops Our Timer For When You Get Out Of Your Vehicle Your Speed Doesn't Keep Going
  629. TextDrawSetString(sdisplay[playerid], " "); // This Sets Our Textdraw To Blank And Freezes Because We Stop The Timer ^
  630. if(newstate == 2) stimer[playerid] = SetTimerEx("speedometer", 255, true, "i", playerid); // This Starts The Timer When The Player Changes His/Her State To Being The Driver
  631. else if(newstate == 3) stimer[playerid] = SetTimerEx("speedometer", 250, true, "i", playerid); // This Start The Timer When The Player Changes His/Her Start To Being The Passenger
  632. if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  633. {
  634.  
  635. TextDrawSetString(td_fuel[playerid],"Fuel:");
  636. TextDrawSetString(td_vhealth[playerid],"Health:");
  637. TextDrawSetString(sdisplay[playerid],"Speed:");
  638.  
  639. TextDrawShowForPlayer(playerid,td_fuel[playerid]);
  640. TextDrawShowForPlayer(playerid,sdisplay[playerid]);
  641. TextDrawShowForPlayer(playerid,td_vhealth[playerid]);
  642. TextDrawShowForPlayer(playerid,td_box[playerid]);
  643. } else {
  644. TextDrawHideForPlayer(playerid,td_fuel[playerid]);
  645. TextDrawHideForPlayer(playerid,sdisplay[playerid]);
  646. TextDrawHideForPlayer(playerid,td_vhealth[playerid]);
  647. TextDrawHideForPlayer(playerid,td_box[playerid]);
  648. }
  649. return 1;
  650. }
  651.  
  652. CMD:refuel(playerid, params[])
  653. {
  654. if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!"); //if a player isnt in a vehicle, it stops here
  655. if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!"); //if a player is already refuelling, it stops here
  656. if (GetPlayerMoney(playerid) - 80 <0) return SendClientMessage(playerid,0xFFC800FF,"You dont have enough money!"); //if a player doesnt have $80 anymore, it stops here
  657. GivePlayerMoney(playerid,-80); //Sets the player's cash -$80
  658. SetCameraBehindPlayer(playerid); //Sets the camera behind the player (looks better because the player will be frozen for a few secs)
  659. TogglePlayerControllable(playerid,0); //freezes the player so he cant drive and refuel at the same time
  660. isrefuelling[playerid] = 1; //setting isrefuelling to 1 so the player cant spam /refuel
  661. TextDrawSetString(td_fuel[playerid],"Refuelling..."); //changing textdraw to /refuel
  662. SetTimerEx("timer_refuel",4500,false,"i",playerid); //setting refueltimer
  663. return 1;
  664. }
  665.  
  666. public timer_fuel_lower()
  667. {
  668. for(new i=0;i<MAX_PLAYERS;i++) { //loop for all players
  669. if (isrefuelling[i]) continue; //stop when a player is already refuelling
  670. new vid = GetPlayerVehicleID(i); //getting vehicle ID
  671. new engine,lights,alarm,doors,bonnet,boot,objective;//The vehicle params
  672. GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);//Getting the vehicle params
  673. if (GetPlayerVehicleSeat(i) == 0) { //if the player is a driver (it should only lower the fuel when theres an driver!)
  674. fuel[vid] = fuel[vid] -1; //lowering fuel value
  675. if (fuel[vid]<1) //if fuel is empty
  676. {
  677. fuel[vid] = 0; //setting fuel to 0 (else the timer will set it to -1 -2 -3 etc before removing player)
  678. SetVehicleParamsEx(vid,0,0,alarm,doors,bonnet,boot,objective);
  679. GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",2500,4); //show text
  680. }
  681. }
  682.  
  683. new string[125];format(string,sizeof string,"Fuel: %i",fuel[vid]); //preparing string with next fuel value
  684. TextDrawSetString(td_fuel[i],string); //updating textdraw
  685.  
  686. new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed,final_speed,Float:health;
  687.  
  688. GetVehicleVelocity(vid,speed_x,speed_y,speed_z);
  689. temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
  690. final_speed = floatround(temp_speed,floatround_round);
  691. format(string,sizeof string,"Speed: %i",final_speed);
  692. TextDrawSetString(sdisplay[i],string);
  693.  
  694. GetVehicleHealth(vid,health);
  695. if (max_vhealth[vid] == 0)//if its an random spawned vehicle
  696. {
  697. fuel[vid] = 400;
  698. GetVehicleHealth(vid,max_vhealth[vid]);
  699. }
  700. health = (((health - max_vhealth[vid]) /max_vhealth[vid]) *100)+ 100;
  701. format(string,sizeof string,"Health: %i",floatround(health,floatround_round));
  702. TextDrawSetString(td_vhealth[i],string);
  703. }
  704. return 1;
  705. }
  706.  
  707. public timer_refuel(playerid)
  708. {
  709. new vid = GetPlayerVehicleID(playerid);
  710. fuel[vid] = fuel[vid] = 400;
  711. isrefuelling[playerid] = 0;
  712. TextDrawSetString(td_fuel[playerid],"Fuel:100");
  713. TogglePlayerControllable(playerid,1);
  714. }
  715.  
  716. public OnPlayerEnterCheckpoint(playerid)
  717. {
  718. CheckpointEntered(playerid);
  719. return 1;
  720. }
  721.  
  722. stock CheckpointEntered(playerid)
  723. {
  724. new gString[128];//A new string for storage
  725. new vID = GetPlayerVehicleID(playerid);//Explained earlier
  726. if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_RED, "You need a trailer to unload!");//This line checks wether the player has a trailer attached to their truck.
  727. if(MissionStatus[playerid] == 1)//checks the players mission status
  728. {
  729. DisablePlayerCheckpoint(playerid);//disables the checkpoint
  730. SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
  731. SendClientMessage(playerid, COLOR_ORANGE, "Loaded. Please head to the second checkpoint!");//sends message
  732. MissionStatus[playerid] = 2;//sets the players mission status
  733. }
  734. else if(MissionStatus[playerid] == 2)//checks the mission status of the player
  735. {
  736. DisablePlayerCheckpoint(playerid);//disables the checkpoint
  737. GivePlayerMoney(playerid, iPay[playerid]);//gives the money that was defined earlier
  738. SendClientMessage(playerid, COLOR_GREEN, "Well done! You completed the mission!");//sends the player a message
  739. format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);//formats the message
  740. SendClientMessageToAll(COLOR_GREEN, gString);//sends everyone message saying player completed mission
  741. SetPlayerScore(playerid, GetPlayerScore(playerid)+2);//gives the player 2 score
  742. MissionStatus[playerid] = 0;//sets the mission status of the player to '0'
  743. }
  744. return 1;
  745. }
  746.  
  747. public OnPlayerLeaveCheckpoint(playerid)
  748. {
  749. return 1;
  750. }
  751.  
  752. public OnPlayerEnterRaceCheckpoint(playerid)
  753. {
  754. return 1;
  755. }
  756.  
  757. public OnPlayerLeaveRaceCheckpoint(playerid)
  758. {
  759. return 1;
  760. }
  761.  
  762. public OnRconCommand(cmd[])
  763. {
  764. return 1;
  765. }
  766.  
  767. public OnPlayerRequestSpawn( playerid )
  768. {
  769. return 1;
  770. }
  771.  
  772. public OnObjectMoved(objectid)
  773. {
  774. return 1;
  775. }
  776.  
  777. public OnPlayerObjectMoved(playerid, objectid)
  778. {
  779. return 1;
  780. }
  781.  
  782. public OnPlayerPickUpPickup(playerid, pickupid)
  783. {
  784. return 1;
  785. }
  786.  
  787. public OnVehicleMod(playerid, vehicleid, componentid)
  788. {
  789. return 1;
  790. }
  791.  
  792. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  793. {
  794. return 1;
  795. }
  796.  
  797. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  798. {
  799. return 1;
  800. }
  801.  
  802. public OnPlayerSelectedMenuRow(playerid, row)
  803. {
  804. return 1;
  805. }
  806.  
  807. public OnPlayerExitedMenu(playerid)
  808. {
  809. return 1;
  810. }
  811.  
  812. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  813. {
  814. return 1;
  815. }
  816.  
  817. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  818. {
  819. if(PRESSED(KEY_SUBMISSION))//If the player pressed KEY_SUBMISSION (2)
  820. {
  821. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)//Checks if the player is the driver
  822. {
  823. new vehicle = GetPlayerVehicleID(playerid);//Getting the players vehicle id.
  824. new engine,lights,alarm,doors,bonnet,boot,objective;//The vehicle params
  825. GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);//Getting the vehicle params
  826. if(engine == 0)//If the engine is off
  827. {
  828. SetVehicleParamsEx(vehicle,1,1,alarm,doors,bonnet,boot,objective);//We turn on the engine and lights
  829. SendClientMessage(playerid,-1,"You started the engine!");
  830. }
  831. else//Else is the engine is on
  832. {
  833. SetVehicleParamsEx(vehicle,0,0,alarm,doors,bonnet,boot,objective);//We turn off the engine and lights
  834. SendClientMessage(playerid,-1,"You stopped the engine!");//Sends a message to the player telling him he stopped the engine.
  835. }
  836. return 1;
  837. }
  838. }
  839. return 1;
  840. }
  841. public OnRconLoginAttempt(ip[], password[], success)
  842. {
  843. return 1;
  844. }
  845.  
  846. public OnPlayerUpdate(playerid)
  847. {
  848. return 1;
  849. }
  850.  
  851. public OnPlayerStreamIn(playerid, forplayerid)
  852. {
  853. return 1;
  854. }
  855.  
  856. public OnPlayerStreamOut(playerid, forplayerid)
  857. {
  858. return 1;
  859. }
  860.  
  861. public OnVehicleStreamIn(vehicleid, forplayerid)
  862. {
  863. return 1;
  864. }
  865.  
  866. public OnVehicleStreamOut(vehicleid, forplayerid)
  867. {
  868. return 1;
  869. }
  870.  
  871. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  872. {
  873. if(dialogid == dregister) //If dialog id is a register dialog
  874. {//then
  875. if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  876. if(response) //if they clicked the first button "Register"
  877. {//then
  878. if(!strlen(inputtext)) //If they didn't enter any password
  879. {// then we will tell to them to enter the password to register
  880. 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");
  881. return 1;
  882. }
  883. //If they have entered a correct password for his/her account...
  884. new hashpass[129]; //Now we will create a new variable to hash his/her password
  885. WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
  886. new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
  887. INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  888. INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
  889. 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.
  890. INI_WriteInt(file,"VIPLevel",0);//As explained above
  891. 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
  892. 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
  893. INI_WriteInt(file,"Kills",0);//As explained above
  894. INI_WriteInt(file,"Deaths",0);//As explained above
  895. INI_Close(file);//Now after we've done saving their data, we now need to close the file
  896. SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
  897. return 1;
  898. }
  899. }
  900. if(dialogid == dlogin) //If dialog id is a login dialog
  901. {//then
  902. if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  903. if(response) //if they clicked the first button "Register"
  904. {//then
  905. new hashpass[129]; //Will create a new variable to hash his/her password
  906. WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
  907. if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
  908. {//then
  909. INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
  910. SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
  911. GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
  912. SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
  913. }
  914. else //If they've entered an incorrect password
  915. {//then
  916. ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
  917. return 1;
  918. }
  919. }
  920. }
  921. return 1;
  922. }
  923.  
  924. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  925. {
  926. return 1;
  927. }
  928.  
  929. //------------------------------------------------------------------------------- STOCKS ETC ----------------------------------------//
  930.  
  931. SetPlayerTeamFromClass(playerid, classid)
  932. {
  933. if (classid == 0)
  934. {
  935. gTeam[playerid] = TEAM_TRUCKER;
  936. GameTextForPlayer(playerid, "~r~ Trucker", 5500, 5);
  937. }
  938. else
  939. {
  940. gTeam[playerid] = TEAM_POLICE;
  941. GameTextForPlayer(playerid, "~b~ Police", 5500, 5);
  942. }
  943. }
  944. SetPlayerToTeamColor(playerid)
  945. {
  946. if (gTeam[playerid] == TEAM_TRUCKER)
  947. {
  948. SetPlayerColor(playerid, COLOR_ORANGE);
  949. }
  950. else if (gTeam[playerid] == TEAM_POLICE)
  951. {
  952. SetPlayerColor(playerid, COLOR_BLUE);
  953. }
  954. }
  955.  
  956. stock pName( playerid )
  957. {
  958. new Name[ MAX_PLAYER_NAME ];
  959. GetPlayerName( playerid, Name, sizeof( Name ) );
  960. return Name;
  961. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement