daily pastebin goal
40%
SHARE
TWEET

Bestatter Job Azgeda Reallife

Leon1337 Nov 4th, 2018 (edited) 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Bestatter Job von LeonMrBonnie für Azgeda Reallife
  2. #define FILTERSCRIPT
  3.  
  4. //**************** INCLUDES **********************
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <zones>
  8. #include <streamer>
  9. //************************************************
  10. //**************** VARIABLEN *********************
  11. #define HTML_WHITE     "{FFFFFF}"
  12. #define COLOR_CYAN 0x99FFFFAA
  13.  
  14. new corpses;
  15. new BestatterVehicle[6];
  16.  
  17. enum JobInfo
  18. {
  19.     CorpseID,
  20.     State,
  21.     Vehicle,
  22.     Checkpoint,
  23.     Timer,
  24.     OldSkin,
  25.     bool:OnDuty,
  26.     bool:IsBestatting
  27. }
  28. new JobEnum[MAX_PLAYERS][JobInfo];
  29.  
  30. enum CorpseInfo
  31. {
  32.     ID,
  33.     Bestatter,
  34.     Playername[MAX_PLAYER_NAME],
  35.     Zone[MAX_ZONE_NAME],
  36.     Float:X,
  37.     Float:Y,
  38.     Float:Z,
  39.     bool:Exists,
  40.     bool:Active
  41. }
  42. new CorpseEnum[MAX_PLAYERS][CorpseInfo];
  43.  
  44. //************************************************
  45. //**************** PUBLICS ***********************
  46. public OnFilterScriptInit()
  47. {
  48.     print("Bestatter Job geladen!");
  49.     corpses = 0;
  50.     CreateBestatterVehicles();
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56.     JobEnum[playerid][OnDuty] = false;
  57.     JobEnum[playerid][IsBestatting] = false;
  58.     JobEnum[playerid][State] = 0;
  59.     JobEnum[playerid][Timer] = -1;
  60.     JobEnum[playerid][CorpseID] = -1;
  61.     JobEnum[playerid][Checkpoint] = -1;
  62.     JobEnum[playerid][Vehicle] = -1;
  63.     JobEnum[playerid][OldSkin] = -1;
  64.  
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerDisconnect(playerid, reason)
  69. {
  70.     if(JobEnum[playerid][Vehicle] != -1)
  71.     {
  72.         SetVehicleToRespawn(JobEnum[playerid][Vehicle]);
  73.         CorpseEnum[JobEnum[playerid][CorpseID]][Bestatter] = -1;
  74.         CorpseEnum[JobEnum[playerid][CorpseID]][Active] = true;
  75.     }
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerDeath(playerid, killerid, reason)
  80. {
  81.     if(JobEnum[playerid][IsBestatting])
  82.     {
  83.         SendInfoMessage(playerid, "Die Tour wurde vorzeitig beendet, weil du gestorben bist.");
  84.         JobEnum[playerid][IsBestatting] = false;
  85.         JobEnum[playerid][OnDuty] = false;
  86.         SetVehicleToRespawn(JobEnum[playerid][Vehicle]);
  87.         JobEnum[playerid][State] = -1;
  88.         JobEnum[playerid][Vehicle] = -1;
  89.         if(IsValidDynamicCP(JobEnum[playerid][Checkpoint])) DestroyDynamicCP(JobEnum[playerid][Checkpoint]);
  90.         JobEnum[playerid][Checkpoint] = -1;
  91.     }
  92.     new Float:x,Float:y,Float:z,zone[28];
  93.     GetPlayerPos(playerid, x,y,z);
  94.     GetPlayer2DZone(playerid, zone, 28);
  95.     corpses++;
  96.     CorpseEnum[corpses][Exists] = true;
  97.     CorpseEnum[corpses][Active] = true;
  98.     CorpseEnum[corpses][Bestatter] = -1;
  99.     format(CorpseEnum[corpses][Zone],28,"%s",zone);
  100.     format(CorpseEnum[corpses][Playername],24,"%s",GetName(playerid));
  101.     CorpseEnum[corpses][ID] = corpses;
  102.     CorpseEnum[corpses][X] = x;
  103.     CorpseEnum[corpses][Y] = y;
  104.     CorpseEnum[corpses][Z] = z;
  105.     new string[128];
  106.     format(string,sizeof(string),"%s ist in %s gestorben. Nimm den Auftrag bei /corpses an.",GetName(playerid),zone);
  107.     for(new i; i<GetPlayerPoolSize()+1; i++)
  108.     {
  109.         if(JobEnum[i][OnDuty])
  110.         {
  111.             SendInfoMessage(i, string);
  112.         }
  113.     }
  114.     return 1;
  115. }
  116.  
  117. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  118. {
  119.     if(dialogid == 12500)
  120.     {
  121.         if(response)
  122.         {
  123.             if(JobEnum[playerid][State] == 2)
  124.             {
  125.                 SendInfoMessage(playerid, "Du musst die Leiche nun abholen. Begib dich zum Checkpoint.");
  126.                 new corpseid = strval(inputtext);
  127.                 JobEnum[playerid][CorpseID] = corpseid;
  128.                 JobEnum[playerid][State] = 3;
  129.                 JobEnum[playerid][Checkpoint] = CreateDynamicCP(CorpseEnum[corpseid][X], CorpseEnum[corpseid][Y], CorpseEnum[corpseid][Z], 3.0, -1, -1, playerid, 5000);
  130.             }
  131.             else
  132.             {
  133.                 SendInfoMessage(playerid, "Du musst nun zuerst zum Friedhof einen Leichenwagen besorgen.");
  134.                 new corpseid = strval(inputtext);
  135.                 JobEnum[playerid][CorpseID] = corpseid;
  136.                 JobEnum[playerid][IsBestatting] = true;
  137.                 JobEnum[playerid][State] = 1;
  138.                 CorpseEnum[corpseid][Active] = false;
  139.                 CorpseEnum[corpseid][Bestatter] = playerid;
  140.                 JobEnum[playerid][Checkpoint] = CreateDynamicCP(930.5751,-1114.8217,24.1278, 3.0, -1, -1, playerid, 5000);
  141.             }
  142.         }
  143.     }
  144.     if(dialogid == 12501)
  145.     {
  146.         if(response)
  147.         {
  148.             JobEnum[playerid][State] = 2;
  149.             return cmd_corpses(playerid);
  150.         }
  151.         else
  152.         {
  153.             RemovePlayerFromVehicle(playerid);
  154.             SetVehicleToRespawn(JobEnum[playerid][Vehicle]);
  155.             JobEnum[playerid][Timer] = -1;
  156.             JobEnum[playerid][Vehicle] = -1;
  157.             JobEnum[playerid][OnDuty] = false;
  158.             SetPlayerSkin(playerid, JobEnum[playerid][OldSkin]);
  159.             SendInfoMessage(playerid, "Du bist nun nichtmehr als Bestatter im Dienst.");
  160.         }
  161.     }
  162.     return 0;
  163. }
  164.  
  165. public OnVehicleDeath(vehicleid, killerid)
  166. {
  167.     for(new i; i<GetPlayerPoolSize()+1; i++)
  168.     {
  169.         if(vehicleid == JobEnum[i][Vehicle])
  170.         {
  171.             CorpseEnum[JobEnum[i][CorpseID]][Bestatter] = -1;
  172.             CorpseEnum[JobEnum[i][CorpseID]][Active] = true;
  173.             JobEnum[i][IsBestatting] = false;
  174.             JobEnum[i][Timer] = -1;
  175.             JobEnum[i][CorpseID] = -1;
  176.             SendInfoMessage(i, "Der Auftrag wurde abgebrochen, weil dein Fahrzeug zerstört wurde.");
  177.         }
  178.     }
  179. }
  180.  
  181. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  182. {
  183.     if(checkpointid == JobEnum[playerid][Checkpoint])
  184.     {
  185.         PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0);
  186.         if(JobEnum[playerid][State] == 1)
  187.         {
  188.             DestroyDynamicCP(JobEnum[playerid][Checkpoint]);
  189.             JobEnum[playerid][State] = 2;
  190.             SendInfoMessage(playerid, "Steig nun in einen Leichenwagen ein.");
  191.         }
  192.         if(JobEnum[playerid][State] == 3)
  193.         {
  194.             if(IsPlayerInAnyVehicle(playerid)) return 1;
  195.             DestroyDynamicCP(JobEnum[playerid][Checkpoint]);
  196.             SetPlayerSpecialAction(playerid, 25);
  197.             new Float:x,Float:y,Float:z;
  198.             GetPlayerPos(playerid,x,y,z);
  199.             SetPlayerAttachedObject(playerid, 0, 19944, 1, -0.0639, 0.5919, 0.0000, -1.0000, 85.6999, 81.8999, 0.5880, 0.6990, 0.6490, 0xFFFFFFFF, 0xFFFFFFFF);
  200.             new Float:x2,Float:y2,Float:z2;
  201.             GetPosBehindVehicle(JobEnum[playerid][Vehicle], x2,y2,z2);
  202.             JobEnum[playerid][Checkpoint] = CreateDynamicCP(x2, y2, z2, 1.5, -1, -1, playerid, 5000);
  203.             JobEnum[playerid][State] = 4;
  204.         }
  205.         else if(JobEnum[playerid][State] == 4)
  206.         {
  207.             SendInfoMessage(playerid, "Du hast die Leiche nun eingeladen. Fahre zurück zum Friedhof.");
  208.             DestroyDynamicCP(JobEnum[playerid][Checkpoint]);
  209.             RemovePlayerAttachedObject(playerid, 0);
  210.             SetPlayerSpecialAction(playerid, 0);
  211.             JobEnum[playerid][Checkpoint] = CreateDynamicCP(940.5775,-1086.8916,24.2962, 3.5, -1, -1, playerid, 5000);
  212.             JobEnum[playerid][State] = 5;
  213.         }
  214.         else if(JobEnum[playerid][State] == 5)
  215.         {
  216.             if(!IsPlayerInVehicle(playerid, JobEnum[playerid][Vehicle])) return SendInfoMessage(playerid, "Du musst dich in deinem Leichenwagen befinden.");
  217.             DestroyDynamicCP(JobEnum[playerid][Checkpoint]);
  218.             new corpseid = JobEnum[playerid][CorpseID];
  219.             CorpseEnum[corpseid][Active] = false;
  220.             CorpseEnum[corpseid][Exists] = false;
  221.             CorpseEnum[corpseid][Bestatter] = -1;
  222.             JobEnum[playerid][IsBestatting] = false;
  223.             JobEnum[playerid][Timer] = -1;
  224.             JobEnum[playerid][CorpseID] = -1;
  225.             JobEnum[playerid][Checkpoint] = -1;
  226.             JobEnum[playerid][State] = 0;
  227.  
  228.             SendInfoMessage(playerid, "Du hast die Leiche erfolgreich abgeliefert. Deine Tour ist damit beendet.");
  229.             ShowPlayerDialog(playerid, 12501, DIALOG_STYLE_MSGBOX, "Tour beenden","Möchtest du weiterjobben?", "Weiter", "Aufhören");
  230.         }
  231.     }
  232.     return 1;
  233. }
  234.  
  235. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  236. {
  237.     for(new i; i<(sizeof BestatterVehicle); i++)
  238.     {
  239.         if(vehicleid == BestatterVehicle[i] && JobEnum[playerid][State] == 2)
  240.         {
  241.             SendInfoMessage(playerid, "Du musst die Leiche nun abholen. Begib dich zum Checkpoint.");
  242.             new corpseid = JobEnum[playerid][CorpseID];
  243.             JobEnum[playerid][State] = 3;
  244.             JobEnum[playerid][Vehicle] = vehicleid;
  245.             JobEnum[playerid][Checkpoint] = CreateDynamicCP(CorpseEnum[corpseid][X], CorpseEnum[corpseid][Y], CorpseEnum[corpseid][Z], 3.0, -1, -1, playerid, 5000);
  246.         }
  247.     }
  248.     if(JobEnum[playerid][Timer] != -1 && JobEnum[playerid][IsBestatting])
  249.     {
  250.         KillTimer(JobEnum[playerid][Timer]);
  251.         JobEnum[playerid][Timer] = -1;
  252.     }
  253.     return 1;
  254. }
  255.  
  256. public OnPlayerExitVehicle(playerid, vehicleid)
  257. {
  258.     if(vehicleid == JobEnum[playerid][Vehicle] && JobEnum[playerid][IsBestatting])
  259.     {
  260.         SendInfoMessage(playerid, "Die Tour wird nach 2 Minuten beendet, wenn du dein Fahrzeug nicht betrittst.");
  261.         JobEnum[playerid][Timer] = SetTimerEx("RespawnVehicle", 125000, 0, "d", playerid);
  262.     }
  263.  
  264.     return 1;
  265. }
  266.  
  267. forward RespawnVehicle(playerid);
  268. public RespawnVehicle(playerid)
  269. {
  270.     CorpseEnum[JobEnum[playerid][CorpseID]][Bestatter] = -1;
  271.     CorpseEnum[JobEnum[playerid][CorpseID]][Active] = true;
  272.     JobEnum[playerid][IsBestatting] = false;
  273.     JobEnum[playerid][Timer] = -1;
  274.     JobEnum[playerid][CorpseID] = -1;
  275.     SendInfoMessage(playerid, "Die Tour wurde vorzeitig beendet, weil du dein Fahrzeug verlassen hast.");
  276. }
  277. //************************************************
  278. //**************** BEFEHLE ***********************
  279. CMD:jobduty(playerid)
  280. {
  281.     if(JobEnum[playerid][OnDuty])
  282.     {
  283.         if(JobEnum[playerid][IsBestatting]) return SendInfoMessage(playerid, "Du musst zuerst deinen Auftrag beenden. Du kannst diesen mit /cancelcorpse vorzeitig abbrechen.");
  284.         JobEnum[playerid][OnDuty] = false;
  285.         SetPlayerSkin(playerid, JobEnum[playerid][OldSkin]);
  286.         SendInfoMessage(playerid, "Du bist nun nichtmehr als Bestatter im Dienst.");
  287.     }
  288.     else
  289.     {
  290.         JobEnum[playerid][OldSkin] = GetPlayerSkin(playerid);
  291.         SetPlayerSkin(playerid, 68);
  292.         JobEnum[playerid][OnDuty] = true;
  293.         JobEnum[playerid][State] = 0;
  294.         SendInfoMessage(playerid, "Du bist nun als Bestatter im Dienst.");
  295.     }
  296.  
  297.     return 1;
  298. }
  299.  
  300. CMD:corpses(playerid)
  301. {
  302.     if(!JobEnum[playerid][OnDuty]) return SendInfoMessage(playerid, "Du bist nicht als Bestatter im Dienst.");
  303.     if(JobEnum[playerid][IsBestatting]) return SendInfoMessage(playerid, "Du hast bereits einen Auftrag angenommen. Du kannst diesen mit /cancelcorpse beenden.");
  304.     new dialogstr[2048],addstr[128],amount;
  305.     dialogstr = "ID\tSpieler\tOrt\n";
  306.     for(new i; i<corpses+1; i++)
  307.     {
  308.         if(CorpseEnum[i][Active] && CorpseEnum[i][Exists])
  309.         {
  310.             format(addstr, sizeof(addstr), "%d\t%s\t%s\n",CorpseEnum[i][ID],CorpseEnum[i][Playername],CorpseEnum[i][Zone]);
  311.             strcat(dialogstr, addstr);
  312.             amount++;
  313.         }
  314.     }
  315.     if(amount == 0) return SendInfoMessage(playerid, "Es sind momentan keine Leichen verfügbar.");
  316.     ShowPlayerDialog(playerid, 12500, DIALOG_STYLE_TABLIST_HEADERS, "Verfügbare Leichen", dialogstr, "Annehmen", "Schliessen");
  317.  
  318.     return 1;
  319. }
  320.  
  321. CMD:cancelcorpse(playerid)
  322. {
  323.     if(!JobEnum[playerid][OnDuty]) return SendInfoMessage(playerid, "Du bist nicht als Bestatter im Dienst.");
  324.     if(!JobEnum[playerid][IsBestatting]) return SendInfoMessage(playerid, "Du hast keinen Auftrag angenommen. Du kannst einen bei /corpses annehmen.");
  325.     new corpseid = JobEnum[playerid][CorpseID];
  326.     CorpseEnum[corpseid][Bestatter] = -1;
  327.     CorpseEnum[corpseid][Active] = true;
  328.     JobEnum[playerid][IsBestatting] = false;
  329.     JobEnum[playerid][CorpseID] = -1;
  330.  
  331.     SendInfoMessage(playerid, "Du hast deinen Auftrag vorzeitig abgebrochen.");
  332.  
  333.     return 1;
  334. }
  335. //********************************************
  336. //*************** FUNKTIONEN *****************
  337. GetName(playerid)
  338. {
  339.     new pnameid[24];
  340.     GetPlayerName(playerid,pnameid,sizeof(pnameid));
  341.     return pnameid;
  342. }
  343.  
  344. SendInfoMessage(playerid, text[])
  345. {
  346.     new message[100];
  347.     format(message,sizeof(message),"[BESTATTER]: "HTML_WHITE"%s",text);
  348.     SendClientMessage(playerid, COLOR_CYAN, message);
  349.     return 1;
  350. }
  351.  
  352. CreateBestatterVehicles()
  353. {
  354.     BestatterVehicle[0] = CreateVehicle(442, 922.0735, -1123.8618, 23.7318, 0.3634, 0, 0, 125); //Stretch
  355.     BestatterVehicle[1] = CreateVehicle(442, 929.1399, -1123.8614, 23.6785, 359.4256, 0, 0, 125); //Stretch
  356.     BestatterVehicle[2] = CreateVehicle(442, 935.7604, -1123.8312, 23.7600, 0.1883, 0, 0, 125); //Stretch
  357.     BestatterVehicle[3] = CreateVehicle(442, 925.6629, -1123.8359, 23.7680, 359.9471, 0, 0, 125); //Stretch
  358.     BestatterVehicle[4] = CreateVehicle(442, 932.3648, -1123.8609, 23.7647, 359.7719, 0, 0, 125); //Stretch
  359.     BestatterVehicle[5] = CreateVehicle(442, 939.6359, -1123.8365, 23.7702, 359.7358, 0, 0, 125); //Stretch
  360. }
  361.  
  362. stock GetPosBehindVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5) //Credits go to MP2
  363. {
  364.     new Float:vehicleSize[3], Float:vehiclePos[3];
  365.     GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
  366.     GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
  367.     GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
  368.     x = vehiclePos[0];
  369.     y = vehiclePos[1];
  370.     z = vehiclePos[2];
  371.     return 1;
  372. }
  373.  
  374. GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)//Credits go to MP2
  375. {
  376.     new Float:a;
  377.     GetVehiclePos(vehicleid, q, w, a);
  378.     GetVehicleZAngle(vehicleid, a);
  379.     q += (distance * -floatsin(-a, degrees));
  380.     w += (distance * -floatcos(-a, degrees));
  381. }
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