SHARE
TWEET

Farmer Job Azgeda Reallife

Leon1337 Nov 3rd, 2018 (edited) 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Made by LeonMrBonnie für Azgeda Reallife
  2. #define FILTERSCRIPT
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <streamer>
  6.  
  7. //****************** DEFINES ********************
  8. #define MAX_FARMCPS 5  //Anzahl an Checkpoints die abgefahren werden müssen
  9. #define MAX_CROPS 5 //Anzahl an Ernten die eingesammelt werden müssen
  10.  
  11. //******************* VARIABLEN ******************
  12. new FarmerVehicle[10];
  13. enum FarmerInfo
  14. {
  15.     bool:IsFarmer,
  16.     VehicleID,
  17.     Checkpoints,
  18.     Timer,
  19.     CurrentCheckpoint,
  20.     CurrentPickup[MAX_CROPS],
  21.     Object[MAX_CROPS]
  22. };
  23.  
  24. new Float:FarmerCheckpoints[][] =
  25. {
  26.     {-132.2704,49.2360,3.1172},
  27.     {-158.3712,33.5675,3.1172},
  28.     {-177.8053,49.0988,3.1028},
  29.     {-196.9916,67.2540,3.1172},
  30.     {-215.5738,72.9736,2.8733},
  31.     {-220.3107,63.0927,2.8472},
  32.     {-214.6486,54.1348,3.1172},
  33.     {-202.9189,29.2320,3.2286},
  34.     {-174.3460,-7.8542,3.1172},
  35.     {-175.8239,-44.3263,3.1172},
  36.     {-187.5371,-69.5558,3.1172},
  37.     {-215.5495,-74.7864,3.1172},
  38.     {-244.1431,-66.3051,3.1172},
  39.     {-261.5512,-54.8958,3.1172},
  40.     {-273.3666,-41.1953,2.4805},
  41.     {-265.3297,-21.3529,2.2943},
  42.     {-237.5191,18.5974,2.8085},
  43.     {-173.6121,32.2485,3.1172},
  44.     {-185.0257,8.4878,3.1843},
  45.     {-201.1083,-15.4735,3.1172},
  46.     {-195.5466,-34.9722,3.1172},
  47.     {-212.7732,-43.5486,3.1172},
  48.     {-226.0848,-57.8588,3.1172},
  49.     {-244.3097,-60.8449,3.1172},
  50.     {-248.3990,-44.3875,3.1172},
  51.     {-245.6273,8.8466,2.6481},
  52.     {-153.6711,47.8707,3.1172},
  53.     {-132.5385,54.4717,3.1172},
  54.     {-142.7278,19.8991,3.1172},
  55.     {-152.5054,-8.8565,3.1172},
  56.     {-159.6974,-29.1650,3.1172}
  57. };
  58.  
  59. new FarmerEnum[MAX_PLAYERS][FarmerInfo];
  60.  
  61. //****************** DEFINES ************************
  62. #define HTML_RED       "{f44242}"
  63. #define HTML_WHITE     "{FFFFFF}"
  64. #define COLOR_CYAN 0x99FFFFAA
  65.  
  66. //**************** FUNKTIONEN ********************
  67. public OnFilterScriptInit()
  68. {
  69.     print("Farmer Job geladen!");
  70.     LoadFarmerVehicles();
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerConnect(playerid)
  75. {
  76.     FarmerEnum[playerid][IsFarmer] = false;
  77.     FarmerEnum[playerid][Timer] = -1;
  78.     FarmerEnum[playerid][Checkpoints] = -1;
  79.     FarmerEnum[playerid][CurrentCheckpoint] = -1;
  80.     for(new i; i<MAX_CROPS; i++)
  81.     {
  82.         FarmerEnum[playerid][CurrentPickup][i] = -1;
  83.     }
  84.     for(new i; i<MAX_CROPS; i++)
  85.     {
  86.         FarmerEnum[playerid][Object][i] = -1;
  87.     }
  88.     FarmerEnum[playerid][VehicleID] = -1;
  89.     FarmerEnum[playerid][Object] = -1;
  90.     return 1;
  91. }
  92.  
  93. public OnPlayerDisconnect(playerid, reason)
  94. {
  95.     if(FarmerEnum[playerid][VehicleID] != -1)
  96.     {
  97.         SetVehicleToRespawn(FarmerEnum[playerid][VehicleID]);
  98.     }
  99.     return 1;
  100. }
  101.  
  102. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  103. {
  104.     if(checkpointid == FarmerEnum[playerid][CurrentCheckpoint])
  105.     {
  106.         new curstate = FarmerEnum[playerid][Checkpoints], gametext[32];
  107.         PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0);
  108.         if(curstate == -1)
  109.         {
  110.             DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  111.             SendInfoMessage(playerid, "Steig nun in einen Traktor ein.");
  112.             FarmerEnum[playerid][VehicleID] = -1;
  113.         }
  114.         else if(curstate == -1)
  115.         {
  116.             FarmerEnum[playerid][Checkpoints] = 0;
  117.             //FarmerEnum[playerid][VehicleID] = CreateVehicle(531, x, y, z, a, -1, -1, -1);
  118.             if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
  119.             PutPlayerInVehicle(playerid, FarmerEnum[playerid][VehicleID], 0);
  120.             SendInfoMessage(playerid, "Du musst zuerst die Felder bepflanzen. Fahre nun dafür die Checkpoints ab.");
  121.             if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  122.             CreateRandomFarmCP(playerid);
  123.         }
  124.         else if(curstate > -1 && curstate < MAX_FARMCPS-1)
  125.         {
  126.             FarmerEnum[playerid][Checkpoints]++;
  127.             format(gametext,sizeof(gametext),"%d/%d~n~FELDER BEPFLANZT",FarmerEnum[playerid][Checkpoints],MAX_FARMCPS);
  128.             GameTextForPlayer(playerid, gametext, 3000, 6);
  129.             if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  130.             CreateRandomFarmCP(playerid);
  131.         }
  132.         else if(curstate == MAX_FARMCPS-1)
  133.         {
  134.             FarmerEnum[playerid][Checkpoints]++;
  135.             format(gametext,sizeof(gametext),"%d/%d~n~FELDER BEPFLANZT",FarmerEnum[playerid][Checkpoints],MAX_FARMCPS);
  136.             GameTextForPlayer(playerid, gametext, 3000, 6);
  137.             if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  138.             SendInfoMessage(playerid, "Du hast nun alle Felder bepflanzt. Sammle jetzt die Ernte ein.");
  139.             for(new i; i<MAX_CROPS; i++)
  140.             {
  141.                 CreateFarmCrop(playerid, i);
  142.             }
  143.         }
  144.         else if(curstate == MAX_FARMCPS + MAX_CROPS)
  145.         {
  146.             SetVehicleVelocity(FarmerEnum[playerid][VehicleID], 0, 0, 0);
  147.             TogglePlayerControllable(playerid, 0);
  148.             GameTextForPlayer(playerid, "ERNTE WIRD ABGELADEN...", 3500, 6);
  149.             SetTimerEx("SendBack", 3000, 0, "d", playerid);
  150.         }
  151.         else if(curstate == MAX_FARMCPS + MAX_CROPS + 1)
  152.         {
  153.             SetVehicleVelocity(FarmerEnum[playerid][VehicleID], 0, 0, 0);
  154.             if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  155.             SendInfoMessage(playerid, "Du hast deine Tour als Farmer beendet.");
  156.             ShowPlayerDialog(playerid, 12504, DIALOG_STYLE_MSGBOX, "Tour beenden","Möchtest du weiterjobben?", "Weiter", "Aufhören");
  157.         }
  158.     }
  159.     return 1;
  160. }
  161.  
  162. forward SendBack(playerid);
  163. public SendBack(playerid)
  164. {
  165.     TogglePlayerControllable(playerid, 1);
  166.     FarmerEnum[playerid][Checkpoints]++;
  167.     if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  168.     FarmerEnum[playerid][CurrentCheckpoint] = CreateDynamicCP(-64.1162,-9.1987,3.1172, 2.5, -1, -1, playerid, 5000);
  169.     SendInfoMessage(playerid, "Fahre nun zurück zur Farm.");
  170. }
  171.  
  172.  
  173. public OnPlayerPickUpDynamicPickup(playerid, pickupid)
  174. {
  175.     for(new i; i<MAX_CROPS+1; i++)
  176.     {
  177.         if(pickupid == FarmerEnum[playerid][CurrentPickup][i])
  178.         {
  179.             new gametext[64];
  180.             FarmerEnum[playerid][Checkpoints]++;
  181.             format(gametext,sizeof(gametext),"%d/%d~n~ERNTEN GESAMMELT",FarmerEnum[playerid][Checkpoints]-MAX_FARMCPS,MAX_CROPS);
  182.             GameTextForPlayer(playerid, gametext, 3000, 6);
  183.             if(IsValidDynamicPickup(FarmerEnum[playerid][CurrentPickup][i])) DestroyDynamicPickup(FarmerEnum[playerid][CurrentPickup][i]);
  184.             if(IsValidDynamicObject(FarmerEnum[playerid][Object][i])) DestroyDynamicObject(FarmerEnum[playerid][Object][i]);
  185.             if(FarmerEnum[playerid][Checkpoints] == MAX_FARMCPS + MAX_CROPS)
  186.             {
  187.                 SendInfoMessage(playerid, "Du hast nun die Ernte eingesammelt. Liefer sie nun bei Fleischberg ab.");
  188.                 FarmerEnum[playerid][CurrentCheckpoint] = CreateDynamicCP(-156.6296,-289.4840,3.9053, 5.0, -1, -1, playerid, 1000);
  189.             }
  190.         }
  191.     }
  192. }
  193.  
  194. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  195. {
  196.     if(dialogid == 12504)
  197.     {
  198.         if(response)
  199.         {
  200.             FarmerEnum[playerid][Checkpoints] = 0;
  201.             SendInfoMessage(playerid, "Du musst zuerst die Felder bepflanzen. Fahre nun dafür die Checkpoints ab.");
  202.             if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  203.             CreateRandomFarmCP(playerid);
  204.         }
  205.         else
  206.         {
  207.             FarmerEnum[playerid][IsFarmer] = false;
  208.             FarmerEnum[playerid][Checkpoints] = -1;
  209.             RemovePlayerFromVehicle(playerid);
  210.             SetVehicleToRespawn(FarmerEnum[playerid][VehicleID]);
  211.             FarmerEnum[playerid][VehicleID] = -1;
  212.         }
  213.     }
  214.     return 0;
  215. }
  216.  
  217. public OnVehicleDeath(vehicleid, killerid)
  218. {
  219.     for(new i; i<GetPlayerPoolSize(); i++)
  220.     {
  221.         if(FarmerEnum[i][VehicleID] == vehicleid)
  222.         {
  223.             SendInfoMessage(i, "Die Tour wurde vorzeitig beendet, weil dein Fahrzeug zerstört wurde.");
  224.             FarmerEnum[i][IsFarmer] = false;
  225.             FarmerEnum[i][Checkpoints] = -1;
  226.             FarmerEnum[i][VehicleID] = -1;
  227.             for(new i2; i2<MAX_CROPS+1; i2++)
  228.             {
  229.                 FarmerEnum[i][CurrentPickup][i2] = -1;
  230.             }
  231.             for(new i2; i2<MAX_CROPS+1; i2++)
  232.             {
  233.                 FarmerEnum[i][Object][i2] = -1;
  234.             }
  235.             if(IsValidDynamicPickup(FarmerEnum[i][CurrentPickup])) DestroyDynamicPickup(FarmerEnum[i][CurrentPickup]);
  236.             if(IsValidDynamicCP(FarmerEnum[i][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[i][CurrentCheckpoint]);
  237.             FarmerEnum[i][CurrentCheckpoint] = -1;
  238.         }
  239.     }
  240. }
  241.  
  242. public OnPlayerDeath(playerid)
  243. {
  244.     if(FarmerEnum[playerid][IsFarmer])
  245.     {
  246.         SendInfoMessage(playerid, "Die Tour wurde vorzeitig beendet, weil du gestorben bist.");
  247.         FarmerEnum[playerid][IsFarmer] = false;
  248.         SetVehicleToRespawn(FarmerEnum[playerid][VehicleID]);
  249.         FarmerEnum[playerid][Checkpoints] = -1;
  250.         FarmerEnum[playerid][VehicleID] = -1;
  251.         for(new i2; i2<MAX_CROPS+1; i2++)
  252.         {
  253.             FarmerEnum[playerid][CurrentPickup][i2] = -1;
  254.         }
  255.         for(new i2; i2<MAX_CROPS+1; i2++)
  256.         {
  257.             FarmerEnum[playerid][Object][i2] = -1;
  258.         }
  259.         if(IsValidDynamicPickup(FarmerEnum[playerid][CurrentPickup])) DestroyDynamicPickup(FarmerEnum[playerid][CurrentPickup]);
  260.         if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  261.         FarmerEnum[playerid][CurrentCheckpoint] = -1;
  262.     }
  263. }
  264.  
  265. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  266. {
  267.     if(FarmerEnum[playerid][Checkpoints] == -1 && FarmerEnum[playerid][IsFarmer])
  268.     {
  269.         for(new i; i<(sizeof FarmerVehicle); i++)
  270.         {
  271.             if(vehicleid == FarmerVehicle[i])
  272.             {
  273.                 FarmerEnum[playerid][Checkpoints] = 0;
  274.                 FarmerEnum[playerid][VehicleID] = vehicleid;
  275.                 SendInfoMessage(playerid, "Du musst zuerst die Felder bepflanzen. Fahre nun dafür die Checkpoints ab.");
  276.                 if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  277.                 CreateRandomFarmCP(playerid);
  278.             }
  279.         }
  280.     }
  281.     if(FarmerEnum[playerid][Timer] != -1)
  282.     {
  283.         KillTimer(FarmerEnum[playerid][Timer]);
  284.         FarmerEnum[playerid][Timer] = -1;
  285.     }
  286.     return 1;
  287. }
  288.  
  289. public OnPlayerExitVehicle(playerid, vehicleid)
  290. {
  291.     if(vehicleid == FarmerEnum[playerid][VehicleID])
  292.     {
  293.         SendInfoMessage(playerid, "Die Tour wird nach 2 Minuten beendet, wenn du dein Fahrzeug nicht betrittst.");
  294.         FarmerEnum[playerid][Timer] = SetTimerEx("RespawnFarmVehicle", 125000, 0, "d", playerid);
  295.     }
  296.     return 1;
  297. }
  298.  
  299. forward RespawnFarmVehicle(playerid);
  300. public RespawnFarmVehicle(playerid)
  301. {
  302.     SendInfoMessage(playerid, "Die Tour wurde vorzeitig beendet, weil du dein Fahrzeug verlassen hast.");
  303.     SetVehicleToRespawn(FarmerEnum[playerid][VehicleID]);
  304.     FarmerEnum[playerid][IsFarmer] = false;
  305.     FarmerEnum[playerid][Checkpoints] = -1;
  306.     FarmerEnum[playerid][CurrentCheckpoint] = -1;
  307.     FarmerEnum[playerid][VehicleID] = -1;
  308.     for(new i2; i2<MAX_CROPS+1; i2++)
  309.     {
  310.         FarmerEnum[playerid][CurrentPickup][i2] = -1;
  311.     }
  312.     for(new i2; i2<MAX_CROPS+1; i2++)
  313.     {
  314.         FarmerEnum[playerid][Object][i2] = -1;
  315.     }
  316.     if(IsValidDynamicPickup(FarmerEnum[playerid][CurrentPickup])) DestroyDynamicPickup(FarmerEnum[playerid][CurrentPickup]);
  317.     if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  318.     return 1;
  319. }
  320. //*************** BEFEHLE ******************
  321. CMD:startjob(playerid)
  322. {
  323.     if(FarmerEnum[playerid][IsFarmer] == true) return SendInfoMessage(playerid, "Du bist bereits Farmer im Dienst. Du kannst den Job mit /canceljob beenden.");
  324.  
  325.     FarmerEnum[playerid][IsFarmer] = true;
  326.     SendInfoMessage(playerid, "Du bist nun als Farmer im Dienst. Begib dich nun zur Farm.");
  327.     FarmerEnum[playerid][CurrentCheckpoint] = CreateDynamicCP(-64.1162,-9.1987,3.1172, 3.0, -1, -1, playerid, 5000);
  328.     return 1;
  329. }
  330.  
  331. CMD:canceljob(playerid)
  332. {
  333.     if(FarmerEnum[playerid][IsFarmer] == false) return SendInfoMessage(playerid, "Du bist nicht als Farmer im Dienst. Du kannst den Job mit /startjob starten.");
  334.  
  335.     FarmerEnum[playerid][IsFarmer] = false;
  336.     FarmerEnum[playerid][Checkpoints] = -1;
  337.     for(new i; i<MAX_CROPS; i++)
  338.     {
  339.         FarmerEnum[playerid][CurrentPickup][i] = -1;
  340.     }
  341.     for(new i; i<MAX_CROPS; i++)
  342.     {
  343.         FarmerEnum[playerid][Object][i] = -1;
  344.     }
  345.     if(IsValidDynamicPickup(FarmerEnum[playerid][CurrentPickup])) DestroyDynamicPickup(FarmerEnum[playerid][CurrentPickup]);
  346.     if(IsValidDynamicCP(FarmerEnum[playerid][CurrentCheckpoint])) DestroyDynamicCP(FarmerEnum[playerid][CurrentCheckpoint]);
  347.     FarmerEnum[playerid][CurrentCheckpoint] = -1;
  348.     DestroyVehicle(FarmerEnum[playerid][VehicleID]);
  349.     SendInfoMessage(playerid, "Du hast den Job als Farmer vorzeitig abgebrochen.");
  350.  
  351.     return 1;
  352. }
  353.  
  354. //*************** FUNKTIONEN *****************
  355. SendInfoMessage(playerid, text[])
  356. {
  357.     new message[100];
  358.     format(message,sizeof(message),"[FARMER]: "HTML_WHITE"%s",text);
  359.     SendClientMessage(playerid, COLOR_CYAN, message);
  360.     return 1;
  361. }
  362.  
  363. CreateRandomFarmCP(playerid)
  364. {
  365.     new cprandom = random(sizeof FarmerCheckpoints);
  366.     FarmerEnum[playerid][CurrentCheckpoint] = CreateDynamicCP(FarmerCheckpoints[cprandom][0], FarmerCheckpoints[cprandom][1], FarmerCheckpoints[cprandom][2], 5.0, -1, -1, playerid, 800);
  367. }
  368.  
  369. CreateFarmCrop(playerid, id)
  370. {
  371.     new cprandom = random(sizeof FarmerCheckpoints);
  372.     FarmerEnum[playerid][CurrentPickup][id] = CreateDynamicPickup(19300, 14, FarmerCheckpoints[cprandom][0], FarmerCheckpoints[cprandom][1], FarmerCheckpoints[cprandom][2], -1, -1, playerid);
  373.     FarmerEnum[playerid][Object][id] = CreateDynamicObject(819, FarmerCheckpoints[cprandom][0], FarmerCheckpoints[cprandom][1], FarmerCheckpoints[cprandom][2], 0.0, 0.0, 0.0, -1, -1, playerid, 800);
  374. }
  375.  
  376. LoadFarmerVehicles()
  377. {
  378. FarmerVehicle[0] = CreateVehicle(531, -29.0494, -4.7820, 3.0567, 59.3324, 37, 0, 125); //Tractor
  379. FarmerVehicle[1] = CreateVehicle(531, -33.6989, -14.3286, 3.0750, 64.1862, 37, 0, 125); //Tractor
  380. FarmerVehicle[2] = CreateVehicle(531, -30.2467, -7.1155, 3.0569, 65.6999, 37, 0, 125); //Tractor
  381. FarmerVehicle[3] = CreateVehicle(531, -31.5101, -9.4533, 3.0925, 65.2910, 37, 0, 125); //Tractor
  382. FarmerVehicle[4] = CreateVehicle(531, -32.5808, -11.9046, 3.0834, 63.0222, 37, 0, 125); //Tractor
  383. FarmerVehicle[5] = CreateVehicle(531, -34.7987, -16.7234, 3.1018, 66.4541, 37, 0, 125); //Tractor
  384. FarmerVehicle[6] = CreateVehicle(531, -39.5843, -26.7351, 3.0768, 60.0999, 37, 0, 125); //Tractor
  385. FarmerVehicle[7] = CreateVehicle(531, -35.8714, -19.2989, 3.0804, 64.4000, 37, 0, 125); //Tractor
  386. FarmerVehicle[8] = CreateVehicle(531, -37.1050, -21.9419, 3.0847, 65.6999, 37, 0, 125); //Tractor
  387. FarmerVehicle[9] = CreateVehicle(531, -38.4430, -24.3589, 3.0749, 62.5000, 37, 0, 125); //Tractor
  388. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top