Advertisement
Guest User

Lawn Mower ca pe Bugged by Irinel77 - (C) Shad0w @ bugged.ro

a guest
Aug 10th, 2021
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.89 KB | None | 0 0
  1. /*
  2. Lawn Mower ca pe Bugged - start date: 10.08.2021
  3. (C) irinel77
  4.  
  5. La define-uri sau enumeratia de dialoguri:
  6. 1. #define DIALOG_JOBS 7462
  7. 2. DIALOG_JOBS,
  8. */
  9.  
  10. #include <YSI\y_hooks>
  11. #include <YSI\y_timers>
  12. #include <YSI\y_inline>
  13.  
  14. #define LAWN_MOWER_JOB 9 // ID-ul folosit pentru job (numarul de joburi exitente pe server + 1)
  15. #define LAWN_MOWER_MONEY 100 // Banii primiti la fiecare 10 secunde.
  16.  
  17. #define LAWN_MOWER_AREA_X 1355.6140
  18. #define LAWN_MOWER_AREA_Y 2150.3335
  19. #define LAWN_MOWER_AREA_Z 11.0156
  20.  
  21. #define LAWN_MOWER_VEHICLE_MODEL 572 // Modelul vehiculului folosit pentru job.
  22. #define LAWN_MOWER_RANGE 169.0 // Raza de actiune a jobului.
  23.  
  24. new lawn_mower_job_enabled;
  25.  
  26. new PlayerText:ptd_lawn_mower;
  27.  
  28. new lawn_mower_vehicle[MAX_PLAYERS],
  29. lawn_mower_earnings[MAX_PLAYERS];
  30.  
  31. hook OnGameModeInit() {
  32. lawn_mower_job_enabled = 0; // Puteti face voi un inline/tquery sa-l incarcati din baza de date.
  33. }
  34.  
  35. hook OnPlayerConnect(playerid) {
  36. lawn_mower_vehicle[playerid] = INVALID_VEHICLE_ID;
  37. lawn_mower_earnings[playerid] = 0;
  38.  
  39. ptd_lawn_mower = CreatePlayerTextDraw(playerid, 85.000007, 319.007354, "earned: ~g~$0");
  40. PlayerTextDrawLetterSize(playerid, ptd_lawn_mower, 0.259000, 1.496296);
  41. PlayerTextDrawAlignment(playerid, ptd_lawn_mower, 2);
  42. PlayerTextDrawColor(playerid, ptd_lawn_mower, -1);
  43. PlayerTextDrawSetShadow(playerid, ptd_lawn_mower, 0);
  44. PlayerTextDrawSetOutline(playerid, ptd_lawn_mower, 1);
  45. PlayerTextDrawBackgroundColor(playerid, ptd_lawn_mower, 255);
  46. PlayerTextDrawFont(playerid, ptd_lawn_mower, 3);
  47. PlayerTextDrawSetProportional(playerid, ptd_lawn_mower, 1);
  48. PlayerTextDrawSetShadow(playerid, ptd_lawn_mower, 0);
  49. }
  50.  
  51. hook OnPlayerDisconnect(playerid, reason) {
  52. if(lawn_mower_vehicle[playerid] != INVALID_VEHICLE_ID) {
  53. DestroyVehicle(lawn_mower_vehicle[playerid]);
  54. lawn_mower_vehicle[playerid] = INVALID_VEHICLE_ID;
  55. lawn_mower_earnings[playerid] = 0;
  56. }
  57. }
  58.  
  59. hook OnPlayerStateChange(playerid, newstate, oldstate) {
  60. if(newstate == PLAYER_STATE_ONFOOT) {
  61. if(lawn_mower_vehicle[playerid] != INVALID_VEHICLE_ID) {
  62. AddBigInt(playerVariables[playerid][pCashStore], playerVariables[playerid][pCash], lawn_mower_earnings[playerid]);
  63. //GivePlayerMoney(playerid, lawn_mower_earnings[playerid]);
  64.  
  65. PlayerTextDrawHide(playerid, ptd_lawn_mower);
  66. DestroyVehicle(lawn_mower_vehicle[playerid]);
  67. SCM(playerid, COLOR_GREEN, "(+) Ai primit $%s pentru munca depusa.", FormatNumber(lawn_mower_earnings[playerid]));
  68. playerVariables[playerid][pJob] = 0;
  69. lawn_mower_earnings[playerid] = 0;
  70. lawn_mower_vehicle[playerid] = INVALID_VEHICLE_ID;
  71. }
  72. }
  73. }
  74.  
  75. // Exemplu de comanda /jobs ca pe Bugged
  76. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  77. if(dialogid == DIALOG_JOBS) {
  78. if(!response) return 1;
  79. if(lawn_mower_job_enabled == 1 && listitem == LAWN_MOWER_JOB-1) {
  80. SCM(playerid, COLOR_YELLOW, "Mergi la checkpoint-ul de pe harta pentru a ajunge la jobul Lawn Mower.");
  81. SetPlayerCheckpointEx(playerid, LAWN_MOWER_AREA_X, LAWN_MOWER_AREA_Y, LAWN_MOWER_AREA_Z, 5.0);
  82. }
  83. else {
  84. new jobid = listitem + 1;
  85.  
  86. SCM(playerid, COLOR_YELLOW, "Ti-a fost setat un checkpoint pentru a ajunge la jobul %s. Distanta: %0.1fm.", jobVariables[jobid][jName], GetPlayerDistanceFromPoint(playerid, jobVariables[jobid][jPositionX], jobVariables[jobid][jPositionY], jobVariables[jobid][jPositionZ]));
  87. SetPlayerCheckpointEx(playerid, jobVariables[jobid][jPositionX], jobVariables[jobid][jPositionY], jobVariables[jobid][jPositionZ], 5.0);
  88. }
  89. playerVariables[playerid][pCheckpoint] = 3;
  90. }
  91. return 0;
  92. }
  93.  
  94. YCMD:jobs(playerid, params[], help) {
  95. new jobDialog[1024];
  96. strcat(jobDialog, "Job name\tWorkers\n");
  97. foreach(new j : server_jobs) format(jobDialog, sizeof(jobDialog), "%s%s\t%d\n", jobDialog, jobVariables[j][jName], getJobWorkers(j));
  98. if(lawn_mower_job_enabled == 1) strcat(jobDialog, "Lawn Mower\t{FFFF00}[SPECIAL QUEST]");
  99.  
  100. ShowPlayerDialog(playerid, DIALOG_JOBS, DIALOG_STYLE_TABLIST_HEADERS, "SERVER: Jobs", jobDialog, "Select", "Exit");
  101. return 1;
  102. }
  103.  
  104. stock getJobWorkers(jobid) {
  105. new players;
  106. foreach(new playerid : Player) if(playerVariables[playerid][pJob] == jobid) players++;
  107. return players;
  108. }
  109. //
  110.  
  111. YCMD:lawnmower(playerid, params[], help) {
  112. if(playerVariables[playerid][pAdminLevel] < 6) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are not allowed to use this command.");
  113. if(lawn_mower_job_enabled == 0) {
  114. lawn_mower_job_enabled = 1;
  115. SCM(playerid, COLOR_YELLOW, "Lawn Mower job enabled (job ID: %d).", LAWN_MOWER_JOB);
  116. }
  117. else {
  118. lawn_mower_job_enabled = 0;
  119. SendClientMessage(playerid, COLOR_YELLOW, "Lawn Mower job disabled.");
  120. }
  121. return 1;
  122. }
  123.  
  124. YCMD:gotolm(playerid, params[], help) {
  125. if(playerVariables[playerid][pAdminLevel] < 6) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are not allowed to use this command.");
  126. SetPlayerPos(playerid, LAWN_MOWER_AREA_X, LAWN_MOWER_AREA_Y, LAWN_MOWER_AREA_Z);
  127. SendClientMessage(playerid, 0xCECECECE, "You have been teleported.");
  128. return 1;
  129. }
  130.  
  131. ptask lawn_mower[10000](playerid) {
  132. if(IsPlayerInRangeOfPoint(playerid, 10.0, LAWN_MOWER_AREA_X, LAWN_MOWER_AREA_Y, LAWN_MOWER_AREA_Z) && playerVariables[playerid][pJob] != LAWN_MOWER_JOB) {
  133. lawn_mower_vehicle[playerid] = AddStaticVehicle(LAWN_MOWER_VEHICLE_MODEL, LAWN_MOWER_AREA_X, LAWN_MOWER_AREA_Y, LAWN_MOWER_AREA_Z, 0.0, random(128), random(128));
  134. SetVehicleVirtualWorld(lawn_mower_vehicle[playerid], GetPlayerVirtualWorld(playerid));
  135.  
  136. PutPlayerInVehicle(playerid, lawn_mower_vehicle[playerid], 0);
  137. SendClientMessage(playerid, COLOR_YELLOW, "Acum esti Taietor de iarba!");
  138. playerVariables[playerid][pJob] = LAWN_MOWER_JOB;
  139. lawn_mower_earnings[playerid] = 0;
  140. vehicle_fuel[lawn_mower_vehicle[playerid]] = 1337;
  141. PlayerTextDrawShow(playerid, ptd_lawn_mower);
  142. return 1;
  143. }
  144. if(playerVariables[playerid][pJob] == LAWN_MOWER_JOB && lawn_mower_vehicle[playerid] != INVALID_VEHICLE_ID) {
  145. if(IsPlayerInRangeOfPoint(playerid, LAWN_MOWER_RANGE, LAWN_MOWER_AREA_X, LAWN_MOWER_AREA_Y, LAWN_MOWER_AREA_Z)) {
  146. if(GetVehicleSpeed(playerid) >= 27) {
  147. lawn_mower_earnings[playerid] += LAWN_MOWER_MONEY + random(14) + 1;
  148.  
  149. new earned[64];
  150. format(earned, 64, "earned: ~g~$%s", FormatNumber(lawn_mower_earnings[playerid]));
  151. PlayerTextDrawSetString(playerid, ptd_lawn_mower, earned);
  152. }
  153. else SendClientMessage(playerid, COLOR_LIGHTGREEN, "Trebuie sa mergi cu minim 27km/h pentru a fi platit.");
  154. }
  155. else {
  156. DestroyVehicle(lawn_mower_vehicle[playerid]);
  157. SCM(playerid, COLOR_LIGHTGREEN, "Ai parasit zona jobului.");
  158. }
  159. }
  160. return 0;
  161. }
  162.  
  163. /*
  164. stock GetVehicleSpeed(playerid) {
  165. new Float:Speed[3];
  166. GetVehicleVelocity(GetPlayerVehicleID(playerid),Speed[0],Speed[1],Speed[2]);
  167. return floatround(1.61*floatsqroot(floatpower(floatabs(Speed[0]), 2.0) + floatpower(floatabs(Speed[1]), 2.0) + floatpower(floatabs(Speed[2]), 2.0)) * 99.38);
  168. }
  169. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement