Guest User

cpJobCreator - Create & Manage Checkpoint Jobs ingame

a guest
May 28th, 2016
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 30.06 KB | None | 0 0
  1. // cpJobCreator - Create & Manage Checkpoint Jobs ingame //
  2. // Author: Artus //
  3. // You don't have the permission to (re)upload this script nor to delete my credits! //
  4.  
  5. #define FILTERSCRIPT
  6.  
  7. #define MAX_JOBS 25 // maximum amount of jobs
  8. #define MAX_CPS 25  // maximum checkpoints per job
  9.  
  10. enum
  11. {
  12.     DIALOG_JOBID = 1,
  13.     DIALOG_VMODEL,
  14.     DIALOG_PICKUPID,
  15.     DIALOG_GELD,
  16.     DIALOG_FARBE_1,
  17.     DIALOG_FARBE_2,
  18.     DIALOG_FREEZE,
  19.     DIALOG_HILFE,
  20.     DIALOG_LOESCHEN,
  21. }
  22.  
  23. #include <a_samp>
  24. #include <ocmd>
  25.  
  26. enum jobspielerdaten
  27. {
  28.     bool:spAktiv,
  29.     spJobGeld,
  30.     spJobVehicleID,
  31.     spJobID,
  32.     spCheckpoint,
  33.     bool:spErstellung
  34. }
  35. new spJobDaten[MAX_PLAYERS][jobspielerdaten];
  36.  
  37. enum cpjobdaten
  38. {
  39.     cpJobID,
  40.     cpPickupID,
  41.     cpPickupModel,
  42.     Float:cpPickupPosX,
  43.     Float:cpPickupPosY,
  44.     Float:cpPickupPosZ,
  45.     cpVehicleModel,
  46.     cpFarbe1,
  47.     cpFarbe2,
  48.     Float:cpVehiclePosX,
  49.     Float:cpVehiclePosY,
  50.     Float:cpVehiclePosZ,
  51.     Float:cpVehiclePosA,
  52.     cpGeld,
  53.     cpFreeze,
  54.     Text3D:cpTextLabel
  55. }
  56. new JobDaten[MAX_JOBS][cpjobdaten];
  57.  
  58. enum cpCPS
  59. {
  60.     Float:PosX,
  61.     Float:PosY,
  62.     Float:PosZ
  63. }
  64. new JobCheckpoint[MAX_JOBS][MAX_CPS][cpCPS];
  65.  
  66. enum jobs
  67. {
  68.     JobID,
  69.     VehicleModel,
  70.     Farbe1,
  71.     Farbe2,
  72.     Float:VehiclePosX,
  73.     Float:VehiclePosY,
  74.     Float:VehiclePosZ,
  75.     Float:VehiclePosA,
  76.     PickupID,
  77.     Float:PickupPosX,
  78.     Float:PickupPosY,
  79.     Float:PickupPosZ,
  80.     Geld,
  81.     Freeze
  82. }
  83. new Job[jobs];
  84.  
  85. new Fortschritt = 0, cvid, loeschen;
  86.  
  87. public OnFilterScriptInit()
  88. {
  89.     for(new i; i < MAX_JOBS; i++)
  90.     {
  91.         DateiJobLaden(i);
  92.     }
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerDisconnect(playerid, reason)
  97. {
  98.     if(spJobDaten[playerid][spAktiv])
  99.     {
  100.         DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
  101.     }
  102.     spJobDaten[playerid][spAktiv] = false;
  103.     spJobDaten[playerid][spJobGeld] = 0;
  104.     spJobDaten[playerid][spJobVehicleID] = 0;
  105.     spJobDaten[playerid][spJobID] = 0;
  106.     spJobDaten[playerid][spCheckpoint] = 0;
  107.     if(spJobDaten[playerid][spErstellung] == true)
  108.     {
  109.         new datei[32];
  110.         format(datei, 32, "/Jobs/%i.txt", Job[JobID]);
  111.         fremove(datei);
  112.         Job[JobID] = 0;
  113.         Job[VehicleModel] = 0;
  114.         Job[VehiclePosX] = 0.000000;
  115.         Job[VehiclePosY] = 0.000000;
  116.         Job[VehiclePosZ] = 0.000000;
  117.         Job[VehiclePosA] = 0.000000;
  118.         Job[PickupID] = 0;
  119.         Job[PickupPosX] = 0.000000;
  120.         Job[PickupPosY] = 0.000000;
  121.         Job[PickupPosZ] = 0.000000;
  122.         Job[Geld] = 0;
  123.         Job[Farbe1] = 0;
  124.         Job[Farbe2] = 0;
  125.         Job[Freeze] = 0;
  126.         Fortschritt = 0;
  127.         cvid = 0;
  128.         spJobDaten[playerid][spErstellung] = false;
  129.     }
  130.     return 1;
  131. }
  132.  
  133. public OnPlayerDeath(playerid, killerid, reason)
  134. {
  135.     if (spJobDaten[playerid][spAktiv])
  136.     {
  137.         DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
  138.         spJobDaten[playerid][spAktiv] = false;
  139.         spJobDaten[playerid][spJobVehicleID] = 0;
  140.         spJobDaten[playerid][spJobID] = 0;
  141.         spJobDaten[playerid][spCheckpoint] = 0;
  142.         DisablePlayerCheckpoint(playerid);
  143.     }
  144.     if(spJobDaten[playerid][spErstellung] == true)
  145.     {
  146.         new datei[32];
  147.         format(datei, 32, "/Jobs/%i.txt", Job[JobID]);
  148.         fremove(datei);
  149.         Job[JobID] = 0;
  150.         Job[VehicleModel] = 0;
  151.         Job[VehiclePosX] = 0.000000;
  152.         Job[VehiclePosY] = 0.000000;
  153.         Job[VehiclePosZ] = 0.000000;
  154.         Job[VehiclePosA] = 0.000000;
  155.         Job[PickupID] = 0;
  156.         Job[PickupPosX] = 0.000000;
  157.         Job[PickupPosY] = 0.000000;
  158.         Job[PickupPosZ] = 0.000000;
  159.         Job[Geld] = 0;
  160.         Job[Farbe1] = 0;
  161.         Job[Farbe2] = 0;
  162.         Job[Freeze] = 0;
  163.         Fortschritt = 0;
  164.         cvid = 0;
  165.         spJobDaten[playerid][spErstellung] = false;
  166.     }
  167.     return 1;
  168. }
  169.  
  170. ocmd:start(playerid)
  171. {
  172.     for(new i; i < MAX_JOBS; i++)
  173.     {
  174.         if(IsPlayerInRangeOfPoint(playerid, 3, JobDaten[i][cpPickupPosX], JobDaten[i][cpPickupPosY], JobDaten[i][cpPickupPosZ]))
  175.         {
  176.             spJobDaten[playerid][spAktiv] = true;
  177.             spJobDaten[playerid][spJobID] = i;
  178.             spJobDaten[playerid][spJobVehicleID] = CreateVehicle(JobDaten[i][cpVehicleModel], JobDaten[i][cpVehiclePosX], JobDaten[i][cpVehiclePosY], JobDaten[i][cpVehiclePosZ], JobDaten[i][cpVehiclePosA], JobDaten[i][cpFarbe1], JobDaten[i][cpFarbe2], -1);
  179.             PutPlayerInVehicle(playerid, spJobDaten[playerid][spJobVehicleID], 0);
  180.             spJobDaten[playerid][spCheckpoint] = 1;
  181.             SetPlayerCheckpoint(playerid, JobCheckpoint[spJobDaten[playerid][spJobID]][1][PosX], JobCheckpoint[spJobDaten[playerid][spJobID]][1][PosY], JobCheckpoint[spJobDaten[playerid][spJobID]][1][PosZ], 4);
  182.         }
  183.     }
  184.     return 1;
  185. }
  186.  
  187. ocmd:cjob(playerid)
  188. {
  189.     if(IsPlayerAdmin(playerid))
  190.     {
  191.         ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
  192.     }
  193.     return 1;
  194. }
  195.  
  196. ocmd:vsave(playerid)
  197. {
  198.     if(IsPlayerAdmin(playerid))
  199.     {
  200.         if(Fortschritt == 1 && IsPlayerInAnyVehicle(playerid))
  201.         {
  202.             new vid = GetPlayerVehicleID(playerid);
  203.             GetVehiclePos(vid, Job[VehiclePosX], Job[VehiclePosY], Job[VehiclePosZ]);
  204.             GetVehicleZAngle(vid, Job[VehiclePosA]);
  205.             spJobDaten[playerid][spErstellung] = false;
  206.             RemovePlayerFromVehicle(playerid);
  207.             spJobDaten[playerid][spErstellung] = true;
  208.             ShowPlayerDialog(playerid, DIALOG_PICKUPID, DIALOG_STYLE_LIST, "Pickup ID", "Heart\nArmor\nInfo\nBusiness\nHouse\nMoney\nPill\nWantedStar\nBomb\nSkull\nDollar\nT-Shirt\nDisk\n2 Player\nparachute\nDrugBundle", "OK", "");
  209.         }
  210.     }
  211.     return 1;
  212. }
  213.  
  214. ocmd:psave(playerid)
  215. {
  216.     if(IsPlayerAdmin(playerid))
  217.     {
  218.         if(Fortschritt == 2)
  219.         {
  220.             GetPlayerPos(playerid, Job[PickupPosX], Job[PickupPosY], Job[PickupPosZ]);
  221.             ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
  222.         }
  223.     }
  224.     return 1;
  225. }
  226.  
  227. ocmd:cpsave(playerid)
  228. {
  229.     if(IsPlayerAdmin(playerid))
  230.     {
  231.         if(Fortschritt >= 3 && IsPlayerInAnyVehicle(playerid))
  232.         {
  233.             if(Fortschritt <= MAX_JOBS+3)
  234.             {
  235.                 new stri[16], str[128], Float:X, Float:Y, Float:Z;
  236.                 GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
  237.                 JobCheckpoint[Job[JobID]][Fortschritt-2][PosX] = X;
  238.                 JobCheckpoint[Job[JobID]][Fortschritt-2][PosY] = Y;
  239.                 JobCheckpoint[Job[JobID]][Fortschritt-2][PosZ] = Z;
  240.                 format(stri, 16, "/Jobs/%i.txt", Job[JobID]);
  241.                 new File:jobn = fopen(stri,io_append);
  242.                 if(jobn)
  243.                 {
  244.                     format(str, 128, "%f, %f, %f\r\n", X, Y, Z);
  245.                     fwrite(jobn, str);
  246.                     fclose(jobn);
  247.                     Fortschritt++;
  248.                     format(str, 128, "Checkpoint (%i/%i)", Fortschritt-3, MAX_JOBS);
  249.                     SendClientMessage(playerid, 0xFFFF00FF, str);
  250.                     SendClientMessage(playerid, 0xFFFF00FF, "Want to finish? Enter /cpfinish (no final checkpoint will be created)");
  251.                 }
  252.             }
  253.             else
  254.             {
  255.                 SendClientMessage(playerid, 0xFFFF00FF, "You reached the maximum amount of checkpoints.");
  256.                 JobLaden(Job[JobID]);
  257.                 Job[JobID] = 0;
  258.                 Job[VehicleModel] = 0;
  259.                 Job[VehiclePosX] = 0.000000;
  260.                 Job[VehiclePosY] = 0.000000;
  261.                 Job[VehiclePosZ] = 0.000000;
  262.                 Job[VehiclePosA] = 0.000000;
  263.                 Job[PickupID] = 0;
  264.                 Job[PickupPosX] = 0.000000;
  265.                 Job[PickupPosY] = 0.000000;
  266.                 Job[PickupPosZ] = 0.000000;
  267.                 Job[Geld] = 0;
  268.                 Job[Farbe1] = 0;
  269.                 Job[Farbe2] = 0;
  270.                 Job[Freeze] = 0;
  271.                 Fortschritt = 0;
  272.                 cvid = 0;
  273.                 spJobDaten[playerid][spErstellung] = false;
  274.             }
  275.         }
  276.     }
  277.     return 1;
  278. }
  279. ocmd:cphelp(playerid)
  280. {
  281.     if(IsPlayerAdmin(playerid))
  282.     {
  283.         ShowPlayerDialog(playerid, DIALOG_HILFE, DIALOG_STYLE_MSGBOX, "Help", "/cjob to create a job\n\n/abjob to abort the creation of a job\n\n/deljob to delete a job", "OK", "");
  284.     }
  285.     return 1;
  286. }
  287.  
  288. ocmd:cpfinish(playerid)
  289. {
  290.     if(IsPlayerAdmin(playerid))
  291.     {
  292.         if(Fortschritt >= 4)
  293.         {
  294.             RemovePlayerFromVehicle(playerid);
  295.             DestroyVehicle(cvid);
  296.             JobLaden(Job[JobID]);
  297.             Job[JobID] = 0;
  298.             Job[VehicleModel] = 0;
  299.             Job[VehiclePosX] = 0.000000;
  300.             Job[VehiclePosY] = 0.000000;
  301.             Job[VehiclePosZ] = 0.000000;
  302.             Job[VehiclePosA] = 0.000000;
  303.             Job[PickupID] = 0;
  304.             Job[PickupPosX] = 0.000000;
  305.             Job[PickupPosY] = 0.000000;
  306.             Job[PickupPosZ] = 0.000000;
  307.             Job[Geld] = 0;
  308.             Job[Farbe1] = 0;
  309.             Job[Farbe2] = 0;
  310.             Job[Freeze] = 0;
  311.             Fortschritt = 0;
  312.             cvid = 0;
  313.             spJobDaten[playerid][spErstellung] = false;
  314.         }
  315.     }
  316.     return 1;
  317. }
  318.  
  319. ocmd:abjob(playerid)
  320. {
  321.     if(IsPlayerAdmin(playerid))
  322.     {
  323.         new datei[32];
  324.         format(datei, 32, "/Jobs/%i.txt", Job[JobID]);
  325.         fremove(datei);
  326.         if(GetPlayerVehicleID(playerid) == cvid)
  327.         {
  328.             RemovePlayerFromVehicle(playerid);
  329.         }
  330.         if(cvid > 0)
  331.         {
  332.             DestroyVehicle(cvid);
  333.         }
  334.         for(new i; i < MAX_CPS; i++)
  335.         {
  336.             JobCheckpoint[Job[JobID]][i][PosX] = 0.000000;
  337.             JobCheckpoint[Job[JobID]][i][PosY] = 0.000000;
  338.             JobCheckpoint[Job[JobID]][i][PosZ] = 0.000000;
  339.         }
  340.         JobDaten[Job[JobID]][cpJobID] = 0;
  341.         JobDaten[Job[JobID]][cpPickupModel] = 0;
  342.         JobDaten[Job[JobID]][cpPickupPosX] = 0.000000;
  343.         JobDaten[Job[JobID]][cpPickupPosY] = 0.000000;
  344.         JobDaten[Job[JobID]][cpPickupPosZ] = 0.000000;
  345.         JobDaten[Job[JobID]][cpVehicleModel] = 0;
  346.         JobDaten[Job[JobID]][cpVehiclePosX] = 0.000000;
  347.         JobDaten[Job[JobID]][cpVehiclePosY] = 0.000000;
  348.         JobDaten[Job[JobID]][cpVehiclePosZ] = 0.000000;
  349.         JobDaten[Job[JobID]][cpVehiclePosA] = 0.000000;
  350.         JobDaten[Job[JobID]][cpGeld] = 0;
  351.         JobDaten[Job[JobID]][cpFarbe1] = 0;
  352.         JobDaten[Job[JobID]][cpFarbe2] = 0;
  353.         JobDaten[Job[JobID]][cpFreeze] = 0;
  354.         Job[JobID] = 0;
  355.         Job[VehicleModel] = 0;
  356.         Job[VehiclePosX] = 0.000000;
  357.         Job[VehiclePosY] = 0.000000;
  358.         Job[VehiclePosZ] = 0.000000;
  359.         Job[VehiclePosA] = 0.000000;
  360.         Job[PickupID] = 0;
  361.         Job[PickupPosX] = 0.000000;
  362.         Job[PickupPosY] = 0.000000;
  363.         Job[PickupPosZ] = 0.000000;
  364.         Job[Geld] = 0;
  365.         Job[Farbe1] = 0;
  366.         Job[Farbe2] = 0;
  367.         Job[Freeze] = 0;
  368.         Fortschritt = 0;
  369.         cvid = 0;
  370.         spJobDaten[playerid][spErstellung] = false;
  371.     }
  372.     return 1;
  373. }
  374.  
  375. ocmd:deljob(playerid)
  376. {
  377.     if(IsPlayerAdmin(playerid))
  378.     {
  379.         for(new i; i < MAX_JOBS; i++)
  380.         {
  381.             if(IsPlayerInRangeOfPoint(playerid, 3, JobDaten[i][cpPickupPosX], JobDaten[i][cpPickupPosY], JobDaten[i][cpPickupPosZ]))
  382.             {
  383.                 new datei[32];
  384.                 format(datei, 32, "/Jobs/%i.txt", i);
  385.                 fremove(datei);
  386.                 DestroyPickup(JobDaten[i][cpPickupID]);
  387.                 Delete3DTextLabel(JobDaten[i][cpTextLabel]);
  388.                 for(new o; o < MAX_CPS; o++)
  389.                 {
  390.                     JobCheckpoint[i][o][PosX] = 0.000000;
  391.                     JobCheckpoint[i][o][PosY] = 0.000000;
  392.                     JobCheckpoint[i][o][PosZ] = 0.000000;
  393.                 }
  394.                 JobDaten[i][cpJobID] = 0;
  395.                 JobDaten[i][cpPickupModel] = 0;
  396.                 JobDaten[i][cpPickupPosX] = 0.000000;
  397.                 JobDaten[i][cpPickupPosY] = 0.000000;
  398.                 JobDaten[i][cpPickupPosZ] = 0.000000;
  399.                 JobDaten[i][cpVehicleModel] = 0;
  400.                 JobDaten[i][cpVehiclePosX] = 0.000000;
  401.                 JobDaten[i][cpVehiclePosY] = 0.000000;
  402.                 JobDaten[i][cpVehiclePosZ] = 0.000000;
  403.                 JobDaten[i][cpVehiclePosA] = 0.000000;
  404.                 JobDaten[i][cpGeld] = 0;
  405.                 JobDaten[i][cpFarbe1] = 0;
  406.                 JobDaten[i][cpFarbe2] = 0;
  407.                 JobDaten[i][cpFreeze] = 0;
  408.                 loeschen = 1;
  409.             }
  410.         }
  411.         if(!loeschen)
  412.         {
  413.             ShowPlayerDialog(playerid, DIALOG_LOESCHEN, DIALOG_STYLE_INPUT, "Delete a job", "Please enter the ID of the job you want to delete.", "OK", "Abort");
  414.         }
  415.         loeschen = 0;
  416.     }
  417.     return 1;
  418. }
  419.  
  420. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  421. {
  422.     switch (dialogid)
  423.     {
  424.         case DIALOG_JOBID:
  425.         {
  426.             if(response)
  427.             {
  428.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
  429.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
  430.                 new str[128];
  431.                 format(str, 128, "/Jobs/%s.txt", inputtext);
  432.                 if(fexist(str))
  433.                 {
  434.                     ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Job ID in use!\nPlease enter another Job-ID.", "OK", "");
  435.                 }
  436.                 else
  437.                 {
  438.                     if(strval(inputtext) > 0 && strval(inputtext) <= MAX_JOBS)
  439.                     {
  440.                         Job[JobID] = strval(inputtext);
  441.                         new strang[16];
  442.                         format(strang, 16, "/Jobs/%i.txt", Job[JobID]);
  443.                         new File:create = fopen(strang, io_write);
  444.                         if(create)
  445.                         {
  446.                             fclose(create);
  447.                             spJobDaten[playerid][spErstellung] = true;
  448.                         }
  449.                         ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
  450.                     }
  451.                     else ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
  452.                 }
  453.             }
  454.             else ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
  455.         }
  456.         case DIALOG_VMODEL:
  457.         {
  458.             if(response)
  459.             {
  460.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
  461.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
  462.                 if(strval(inputtext) < 400 || strval(inputtext) > 611)
  463.                 {
  464.                     ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
  465.                 }
  466.                 else
  467.                 {
  468.                     ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
  469.                     Job[VehicleModel] = strval(inputtext);
  470.                 }
  471.             }
  472.             else ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
  473.         }
  474.         case DIALOG_FARBE_1:
  475.         {
  476.             if(response)
  477.             {
  478.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
  479.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
  480.                 if(strval(inputtext) >= 0 && strval(inputtext) <= 255)
  481.                 {
  482.                     Job[Farbe1] = strval(inputtext);
  483.                     ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Color", "Please enter the second Color ID.", "OK", "");
  484.                 }
  485.             }
  486.             else ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
  487.         }
  488.         case DIALOG_FARBE_2:
  489.         {
  490.             if(response)
  491.             {
  492.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Color", "Please enter the second Color ID.", "OK", "");
  493.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Color", "Please enter the second Color ID.", "OK", "");
  494.                 if(strval(inputtext) >= 0 && strval(inputtext) <= 255)
  495.                 {
  496.                     Job[Farbe2] = strval(inputtext);
  497.                     ShowPlayerDialog(playerid, DIALOG_FREEZE, DIALOG_STYLE_INPUT, "Freeze (Milliseconds)", "How long should the Player be freezed at every checkpoint?\n(in ms)\nShouldn't get freezed? Type in '0'.", "OK", "");
  498.                 }
  499.             }
  500.             else ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Farbe", "Bitte gebe die 2. Farb-ID ein.", "Weiter", "");
  501.         }
  502.         case DIALOG_FREEZE:
  503.         {
  504.             if(response)
  505.             {
  506.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FREEZE, DIALOG_STYLE_INPUT, "Freeze (Milliseconds)", "How long should the Player be freezed at every checkpoint?\n(in ms)\nShouldn't get freezed? Type in '0'.", "OK", "");
  507.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FREEZE, DIALOG_STYLE_INPUT, "Freeze (Milliseconds)", "How long should the Player be freezed at every checkpoint?\n(in ms)\nShouldn't get freezed? Type in '0'.", "OK", "");
  508.                 Job[Freeze] = strval(inputtext);           
  509.                 new Float:X, Float:Y, Float:Z, Float:A;
  510.                 GetPlayerPos(playerid, X, Y, Z);
  511.                 GetPlayerFacingAngle(playerid, A);
  512.                 cvid = CreateVehicle(Job[VehicleModel], X, Y, Z, A, Job[Farbe1], Job[Farbe2], -1);
  513.                 PutPlayerInVehicle(playerid, cvid, 0);
  514.                 Fortschritt = 1;
  515.                 SendClientMessage(playerid, 0xFFFF00FF, "Drive to the spawn location of the vehicle.");
  516.                 SendClientMessage(playerid, 0xFFFF00FF, "and type /vsave");
  517.             }
  518.             else ShowPlayerDialog(playerid, DIALOG_FREEZE, DIALOG_STYLE_INPUT, "Freeze (Milliseconds)", "How long should the Player be freezed at every checkpoint?\n(in ms)\nShouldn't get freezed? Type in '0'.", "OK", "");
  519.         }
  520.         case DIALOG_PICKUPID:
  521.         {
  522.             if(response)
  523.             {
  524.                 switch (listitem)
  525.                 {
  526.                     case 0: Job[PickupID] = 1240;
  527.                     case 1: Job[PickupID] = 1242;
  528.                     case 2: Job[PickupID] = 1239;
  529.                     case 3: Job[PickupID] = 1272;
  530.                     case 4: Job[PickupID] = 1273;
  531.                     case 5: Job[PickupID] = 1212;
  532.                     case 6: Job[PickupID] = 1241;
  533.                     case 7: Job[PickupID] = 1247;
  534.                     case 8: Job[PickupID] = 1252;
  535.                     case 9: Job[PickupID] = 1254;
  536.                     case 10: Job[PickupID] = 1274;
  537.                     case 11: Job[PickupID] = 1275;
  538.                     case 12: Job[PickupID] = 1277;
  539.                     case 13: Job[PickupID] = 1314;
  540.                     case 14: Job[PickupID] = 1310;
  541.                     case 15: Job[PickupID] = 1279;
  542.                 }
  543.                 Fortschritt = 2;
  544.                 SendClientMessage(playerid, 0xFFFF00FF, "Run to the spawn location of the pickup.");
  545.                 SendClientMessage(playerid, 0xFFFF00FF, "and type /psave");
  546.             }
  547.             else ShowPlayerDialog(playerid, DIALOG_PICKUPID, DIALOG_STYLE_LIST, "Pickup ID", "Heart\nArmor\nInfo\nBusiness\nHouse\nMoney\nPill\nWantedStar\nBomb\nSkull\nDollar\nT-Shirt\nDisk\n2 Player\nparachute\nDrugBundle", "OK", "");
  548.         }
  549.         case DIALOG_GELD:
  550.         {
  551.             if(response)
  552.             {
  553.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
  554.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
  555.                 Job[Geld] = strval(inputtext);
  556.                 new str[128], stri[16];
  557.                 format(stri, 16, "/Jobs/%i.txt", Job[JobID]);
  558.                 new File:jobn = fopen(stri,io_append);
  559.                 if(jobn)
  560.                 {
  561.                     format(str, 128, "%i\r\n", Job[JobID]);
  562.                     fwrite(jobn, str);
  563.                     format(str, 128, "%i\r\n", Job[PickupID]);
  564.                     fwrite(jobn, str);
  565.                     format(str, 128, "%f, %f, %f\r\n", Job[PickupPosX], Job[PickupPosY], Job[PickupPosZ]);
  566.                     fwrite(jobn, str);
  567.                     format(str, 128, "%i\r\n", Job[VehicleModel]);
  568.                     fwrite(jobn, str);
  569.                     format(str, 128, "%f, %f, %f, %f\r\n", Job[VehiclePosX], Job[VehiclePosY], Job[VehiclePosZ], Job[VehiclePosA]);
  570.                     fwrite(jobn, str);
  571.                     format(str, 128, "%i\r\n", Job[Geld]);
  572.                     fwrite(jobn, str);
  573.                     format(str, 128, "%i\r\n", Job[Farbe1]);
  574.                     fwrite(jobn, str);
  575.                     format(str, 128, "%i\r\n", Job[Farbe2]);
  576.                     fwrite(jobn, str);
  577.                     format(str, 128, "%i\r\n", Job[Freeze]);
  578.                     fwrite(jobn, str);
  579.                     fclose(jobn);
  580.                    
  581.                     JobDaten[Job[JobID]][cpJobID] = Job[JobID];
  582.                     JobDaten[Job[JobID]][cpPickupModel] = Job[PickupID];
  583.                     JobDaten[Job[JobID]][cpPickupPosX] = Job[PickupPosX];
  584.                     JobDaten[Job[JobID]][cpPickupPosY] = Job[PickupPosY];
  585.                     JobDaten[Job[JobID]][cpPickupPosZ] = Job[PickupPosZ];
  586.                     JobDaten[Job[JobID]][cpVehicleModel] = Job[VehicleModel];
  587.                     JobDaten[Job[JobID]][cpVehiclePosX] = Job[VehiclePosX];
  588.                     JobDaten[Job[JobID]][cpVehiclePosY] = Job[VehiclePosY];
  589.                     JobDaten[Job[JobID]][cpVehiclePosZ] = Job[VehiclePosZ];
  590.                     JobDaten[Job[JobID]][cpVehiclePosA] = Job[VehiclePosA];
  591.                     JobDaten[Job[JobID]][cpGeld] = Job[Geld];
  592.                     JobDaten[Job[JobID]][cpFarbe1] = Job[Farbe1];
  593.                     JobDaten[Job[JobID]][cpFarbe2] = Job[Farbe2];
  594.                     JobDaten[Job[JobID]][cpFreeze] = Job[Freeze];
  595.                 }
  596.                 Fortschritt = 3;
  597.                 PutPlayerInVehicle(playerid, cvid, 0);
  598.                 SendClientMessage(playerid, 0xFFFF00FF, "Drive to the positions of the checkpoints.");
  599.                 SendClientMessage(playerid, 0xFFFF00FF, "Use /cpsave to create a checkpoint at your location.");
  600.             }
  601.             else ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
  602.         }
  603.         case DIALOG_LOESCHEN:
  604.         {
  605.             if(response)
  606.             {
  607.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOESCHEN, DIALOG_STYLE_INPUT, "Delete a job", "Please enter the ID of the job you want to delete.", "OK", "Abort");
  608.                 if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOESCHEN, DIALOG_STYLE_INPUT, "Delete a job", "Please enter the ID of the job you want to delete.", "OK", "Abort");
  609.                 new job = strval(inputtext);
  610.                 new datei[32];
  611.                 format(datei, 32, "/Jobs/%i.txt", job);
  612.                 if(fexist(datei))
  613.                 {
  614.                     fremove(datei);
  615.                     DestroyPickup(JobDaten[job][cpPickupID]);
  616.                     Delete3DTextLabel(JobDaten[job][cpTextLabel]);
  617.                     for(new i; i < MAX_CPS; i++)
  618.                     {
  619.                         JobCheckpoint[job][i][PosX] = 0.000000;
  620.                         JobCheckpoint[job][i][PosY] = 0.000000;
  621.                         JobCheckpoint[job][i][PosZ] = 0.000000;
  622.                     }
  623.                     JobDaten[job][cpJobID] = 0;
  624.                     JobDaten[job][cpPickupModel] = 0;
  625.                     JobDaten[job][cpPickupPosX] = 0.000000;
  626.                     JobDaten[job][cpPickupPosY] = 0.000000;
  627.                     JobDaten[job][cpPickupPosZ] = 0.000000;
  628.                     JobDaten[job][cpVehicleModel] = 0;
  629.                     JobDaten[job][cpVehiclePosX] = 0.000000;
  630.                     JobDaten[job][cpVehiclePosY] = 0.000000;
  631.                     JobDaten[job][cpVehiclePosZ] = 0.000000;
  632.                     JobDaten[job][cpVehiclePosA] = 0.000000;
  633.                     JobDaten[job][cpGeld] = 0;
  634.                     JobDaten[job][cpFarbe1] = 0;
  635.                     JobDaten[job][cpFarbe2] = 0;
  636.                     JobDaten[job][cpFreeze] = 0;
  637.                     loeschen = 0;
  638.                 }
  639.                 else ShowPlayerDialog(playerid, DIALOG_LOESCHEN, DIALOG_STYLE_INPUT, "Delete a job", "Invalid ID! Please enter the ID of the job you want to delete.", "OK", "Abort");
  640.             }
  641.         }
  642.     }
  643.     return 0;
  644. }
  645.  
  646. public OnVehicleDeath(vehicleid, killerid)
  647. {
  648.     for(new i; i < MAX_VEHICLES; i++)
  649.     {
  650.         if(vehicleid == spJobDaten[i][spJobVehicleID])
  651.         {
  652.             DestroyVehicle(vehicleid);
  653.         }
  654.     }
  655.     if(spJobDaten[killerid][spAktiv] == true)
  656.     {
  657.         spJobDaten[killerid][spAktiv] = false;
  658.         spJobDaten[killerid][spJobID] = 0;
  659.         spJobDaten[killerid][spJobVehicleID] = 0;
  660.         spJobDaten[killerid][spCheckpoint] = 0;
  661.         DisablePlayerCheckpoint(killerid);
  662.     }
  663.     return 1;
  664. }
  665.  
  666. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  667. {
  668.     if(spJobDaten[playerid][spAktiv] == true && vehicleid != spJobDaten[playerid][spJobVehicleID])
  669.     {
  670.         spJobDaten[playerid][spAktiv] = false;
  671.         spJobDaten[playerid][spJobID] = 0;
  672.         DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
  673.     }
  674.     return 1;
  675. }
  676.  
  677. public OnPlayerExitVehicle(playerid, vehicleid)
  678. {
  679.     if(spJobDaten[playerid][spAktiv] == true)
  680.     {
  681.         spJobDaten[playerid][spAktiv] = false;
  682.         spJobDaten[playerid][spJobID] = 0;
  683.         DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
  684.         DisablePlayerCheckpoint(playerid);
  685.         spJobDaten[playerid][spJobVehicleID] = 0;
  686.         spJobDaten[playerid][spCheckpoint] = 0;
  687.     }
  688.     return 1;
  689. }
  690.  
  691. public OnPlayerEnterCheckpoint(playerid)
  692. {
  693.     if(spJobDaten[playerid][spAktiv] == true)
  694.     {
  695.         DisablePlayerCheckpoint(playerid);
  696.         spJobDaten[playerid][spCheckpoint]++;
  697.         if(JobCheckpoint[spJobDaten[playerid][spJobID]][spJobDaten[playerid][spCheckpoint]][PosX] == 0.000000)
  698.         {
  699.             RemovePlayerFromVehicle(playerid);
  700.             DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
  701.             spJobDaten[playerid][spJobGeld] += JobDaten[spJobDaten[playerid][spJobID]][cpGeld];
  702.            
  703.             // GivePlayerMoney(playerid, JobDaten[spJobDaten[playerid][spJobID]][cpGeld]);
  704.             /*
  705.                 Here you have to enter your code for giving the player the money for completing the job!
  706.                 Maybe you use "CallRemoteFunction" for editing the money of the player in the gamemode.
  707.                
  708.                 example: CallRemoteFunction("IncreasePlayerMoney", "dd", playerid, JobDaten[spJobDaten[playerid][spJobID]][cpGeld]);
  709.                
  710.                 In your gamemode there should be a similiar public:
  711.                
  712.                 forward IncreasePlayerMoney(playerid, amount);
  713.                 public IncreasePlayerMoney(playerid, amount)
  714.                 {
  715.                     pData[playerid][pMoney] += amount; // Player money variable
  716.                     GivePlayerMoney(playerid, amount); // Updating the Money on the player's screen
  717.                     return 1;
  718.                 }
  719.             */
  720.            
  721.             spJobDaten[playerid][spJobGeld] = 0; // Resetting the Player's amount of money he got from finishing the job
  722.  
  723.             spJobDaten[playerid][spAktiv] = false;
  724.             spJobDaten[playerid][spJobID] = 0;
  725.             spJobDaten[playerid][spJobVehicleID] = 0;
  726.             spJobDaten[playerid][spCheckpoint] = 0;
  727.         }
  728.         else
  729.         {
  730.             if(JobDaten[spJobDaten[playerid][spJobID]][cpFreeze] > 0)
  731.             {
  732.                 TogglePlayerControllable(playerid, 0);
  733.                 SetTimerEx("JobCheckpointFreeze", JobDaten[spJobDaten[playerid][spJobID]][cpFreeze], false, "i", playerid);
  734.             }
  735.             SetPlayerCheckpoint(playerid, JobCheckpoint[spJobDaten[playerid][spJobID]][spJobDaten[playerid][spCheckpoint]][PosX], JobCheckpoint[spJobDaten[playerid][spJobID]][spJobDaten[playerid][spCheckpoint]][PosY], JobCheckpoint[spJobDaten[playerid][spJobID]][spJobDaten[playerid][spCheckpoint]][PosZ], 4);
  736.         }
  737.     }
  738.     return 1;
  739. }
  740.  
  741. new Fahrzeugnamen[][] = {
  742.     "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto",
  743.     "Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion",
  744.     "Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van",
  745.     "Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina",
  746.     "Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson",
  747.     "Mesa","RC Goblin","Hotring Racer","Hotring Racer","Bloodring Banger","Rancher","Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic","Buccaneer","Shamal",
  748.     "Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex",
  749.     "Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster","Monster","Uranus","Jester",
  750.     "Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley",
  751.     "Stafford","BF-400","Newsvan","Tug","Trailer","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer","Trailer","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)","Police Car (LVPD)","Police Ranger",
  752.     "Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer","Luggage Trailer","Stair Trailer","Boxville","Farm Plow","Utility Trailer"
  753. };
  754.  
  755. stock GetVehicleName(modelid)
  756. {
  757.     new String[128];
  758.     format(String,sizeof(String),"%s",Fahrzeugnamen[modelid - 400]);
  759.     return String;
  760. }
  761.  
  762. IsNumeric(const string[])
  763. {
  764.     for(new i, j = strlen(string); i < j; i++)
  765.     {
  766.         if (string[i] > '9' || string[i] < '0') return 0;
  767.     }
  768.     return 1;
  769. }
  770.  
  771. stock DateiJobLaden(jobid)
  772. {
  773.     new string[16], save[128], line=1, i;
  774.     format(string, sizeof(string), "/Jobs/%i.txt", jobid);
  775.     if(!fexist(string)) return 1;
  776.     else
  777.     {
  778.         new File:job = fopen(string, io_read);
  779.         if(job)
  780.         {
  781.             while(fread(job, save))
  782.             {
  783.                 new idx;
  784.                 switch(line)
  785.                 {
  786.                     case 1: JobDaten[jobid][cpJobID] = strval(strtok(save, idx));
  787.                     case 2: JobDaten[jobid][cpPickupModel] = strval(strtok(save, idx));
  788.                         case 3:
  789.                     {
  790.                         JobDaten[jobid][cpPickupPosX] = floatstr(strtok(save, idx));
  791.                         JobDaten[jobid][cpPickupPosY] = floatstr(strtok(save, idx));
  792.                         JobDaten[jobid][cpPickupPosZ] = floatstr(strtok(save, idx));
  793.                     }
  794.                     case 4: JobDaten[jobid][cpVehicleModel] = strval(strtok(save, idx));
  795.                     case 5:
  796.                     {
  797.                         JobDaten[jobid][cpVehiclePosX] = floatstr(strtok(save, idx));
  798.                         JobDaten[jobid][cpVehiclePosY] = floatstr(strtok(save, idx));
  799.                         JobDaten[jobid][cpVehiclePosZ] = floatstr(strtok(save, idx));
  800.                         JobDaten[jobid][cpVehiclePosA] = floatstr(strtok(save, idx));
  801.                     }
  802.                     case 6: JobDaten[jobid][cpGeld] = strval(strtok(save, idx));
  803.                     case 7: JobDaten[jobid][cpFarbe1] = strval(strtok(save, idx));
  804.                     case 8: JobDaten[jobid][cpFarbe2] = strval(strtok(save, idx));
  805.                     case 9: JobDaten[jobid][cpFreeze] = strval(strtok(save, idx));
  806.                     case 10..(MAX_CPS+9):
  807.                     {
  808.                         JobCheckpoint[jobid][i][PosX] = floatstr(strtok(save, idx));
  809.                         JobCheckpoint[jobid][i][PosY] = floatstr(strtok(save, idx));
  810.                         JobCheckpoint[jobid][i][PosZ] = floatstr(strtok(save, idx));
  811.                         i++;
  812.                     }
  813.                    
  814.                 }
  815.                 line++;
  816.             }
  817.             fclose(job);
  818.         }
  819.         JobDaten[jobid][cpPickupID] = CreatePickup(JobDaten[jobid][cpPickupModel], 1, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ]);
  820.         new str[128];
  821.         format(str, sizeof(str), "/start\nVehicle: %s", GetVehicleName(JobDaten[jobid][cpVehicleModel]));
  822.         JobDaten[jobid][cpTextLabel] = Create3DTextLabel(str, 0xFFFF00FF, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ], 50, 0);
  823.         printf("Job %i loaded successfully.", jobid);
  824.     }
  825.     return 1;
  826. }
  827.  
  828. stock JobLaden(jobid)
  829. {
  830.     JobDaten[jobid][cpPickupID] = CreatePickup(JobDaten[jobid][cpPickupModel], 1, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ]);
  831.     new str[128];
  832.     format(str, sizeof(str), "/start\nVehicle: %s", GetVehicleName(JobDaten[jobid][cpVehicleModel]));
  833.     JobDaten[jobid][cpTextLabel] = Create3DTextLabel(str, 0xFFFF00FF, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ], 50, 0);
  834.     return 1;
  835. }
  836.  
  837. strtok(const string[], &index)
  838. {
  839.     new length = strlen(string);
  840.     while ((index < length) && (string[index] <= ' '))
  841.     {
  842.         index++;
  843.     }
  844.  
  845.     new offset = index;
  846.     new result[20];
  847.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  848.     {
  849.         result[index - offset] = string[index];
  850.         index++;
  851.     }
  852.     result[index - offset] = EOS;
  853.     return result;
  854. }
  855.  
  856. forward JobCheckpointFreeze(playerid);
  857. public JobCheckpointFreeze(playerid)
  858. {
  859.     TogglePlayerControllable(playerid, 1);
  860.     return 1;
  861. }
  862.  
  863. stock SpielerName(playerid)
  864. {
  865.     new name[MAX_PLAYER_NAME];
  866.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  867.     return name;
  868. }
Add Comment
Please, Sign In to add comment