Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cpJobCreator - Create & Manage Checkpoint Jobs ingame //
- // Author: Artus //
- // You don't have the permission to (re)upload this script nor to delete my credits! //
- #define FILTERSCRIPT
- #define MAX_JOBS 25 // maximum amount of jobs
- #define MAX_CPS 25 // maximum checkpoints per job
- enum
- {
- DIALOG_JOBID = 1,
- DIALOG_VMODEL,
- DIALOG_PICKUPID,
- DIALOG_GELD,
- DIALOG_FARBE_1,
- DIALOG_FARBE_2,
- DIALOG_FREEZE,
- DIALOG_HILFE,
- DIALOG_LOESCHEN,
- }
- #include <a_samp>
- #include <ocmd>
- enum jobspielerdaten
- {
- bool:spAktiv,
- spJobGeld,
- spJobVehicleID,
- spJobID,
- spCheckpoint,
- bool:spErstellung
- }
- new spJobDaten[MAX_PLAYERS][jobspielerdaten];
- enum cpjobdaten
- {
- cpJobID,
- cpPickupID,
- cpPickupModel,
- Float:cpPickupPosX,
- Float:cpPickupPosY,
- Float:cpPickupPosZ,
- cpVehicleModel,
- cpFarbe1,
- cpFarbe2,
- Float:cpVehiclePosX,
- Float:cpVehiclePosY,
- Float:cpVehiclePosZ,
- Float:cpVehiclePosA,
- cpGeld,
- cpFreeze,
- Text3D:cpTextLabel
- }
- new JobDaten[MAX_JOBS][cpjobdaten];
- enum cpCPS
- {
- Float:PosX,
- Float:PosY,
- Float:PosZ
- }
- new JobCheckpoint[MAX_JOBS][MAX_CPS][cpCPS];
- enum jobs
- {
- JobID,
- VehicleModel,
- Farbe1,
- Farbe2,
- Float:VehiclePosX,
- Float:VehiclePosY,
- Float:VehiclePosZ,
- Float:VehiclePosA,
- PickupID,
- Float:PickupPosX,
- Float:PickupPosY,
- Float:PickupPosZ,
- Geld,
- Freeze
- }
- new Job[jobs];
- new Fortschritt = 0, cvid, loeschen;
- public OnFilterScriptInit()
- {
- for(new i; i < MAX_JOBS; i++)
- {
- DateiJobLaden(i);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(spJobDaten[playerid][spAktiv])
- {
- DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
- }
- spJobDaten[playerid][spAktiv] = false;
- spJobDaten[playerid][spJobGeld] = 0;
- spJobDaten[playerid][spJobVehicleID] = 0;
- spJobDaten[playerid][spJobID] = 0;
- spJobDaten[playerid][spCheckpoint] = 0;
- if(spJobDaten[playerid][spErstellung] == true)
- {
- new datei[32];
- format(datei, 32, "/Jobs/%i.txt", Job[JobID]);
- fremove(datei);
- Job[JobID] = 0;
- Job[VehicleModel] = 0;
- Job[VehiclePosX] = 0.000000;
- Job[VehiclePosY] = 0.000000;
- Job[VehiclePosZ] = 0.000000;
- Job[VehiclePosA] = 0.000000;
- Job[PickupID] = 0;
- Job[PickupPosX] = 0.000000;
- Job[PickupPosY] = 0.000000;
- Job[PickupPosZ] = 0.000000;
- Job[Geld] = 0;
- Job[Farbe1] = 0;
- Job[Farbe2] = 0;
- Job[Freeze] = 0;
- Fortschritt = 0;
- cvid = 0;
- spJobDaten[playerid][spErstellung] = false;
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if (spJobDaten[playerid][spAktiv])
- {
- DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
- spJobDaten[playerid][spAktiv] = false;
- spJobDaten[playerid][spJobVehicleID] = 0;
- spJobDaten[playerid][spJobID] = 0;
- spJobDaten[playerid][spCheckpoint] = 0;
- DisablePlayerCheckpoint(playerid);
- }
- if(spJobDaten[playerid][spErstellung] == true)
- {
- new datei[32];
- format(datei, 32, "/Jobs/%i.txt", Job[JobID]);
- fremove(datei);
- Job[JobID] = 0;
- Job[VehicleModel] = 0;
- Job[VehiclePosX] = 0.000000;
- Job[VehiclePosY] = 0.000000;
- Job[VehiclePosZ] = 0.000000;
- Job[VehiclePosA] = 0.000000;
- Job[PickupID] = 0;
- Job[PickupPosX] = 0.000000;
- Job[PickupPosY] = 0.000000;
- Job[PickupPosZ] = 0.000000;
- Job[Geld] = 0;
- Job[Farbe1] = 0;
- Job[Farbe2] = 0;
- Job[Freeze] = 0;
- Fortschritt = 0;
- cvid = 0;
- spJobDaten[playerid][spErstellung] = false;
- }
- return 1;
- }
- ocmd:start(playerid)
- {
- for(new i; i < MAX_JOBS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3, JobDaten[i][cpPickupPosX], JobDaten[i][cpPickupPosY], JobDaten[i][cpPickupPosZ]))
- {
- spJobDaten[playerid][spAktiv] = true;
- spJobDaten[playerid][spJobID] = i;
- 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);
- PutPlayerInVehicle(playerid, spJobDaten[playerid][spJobVehicleID], 0);
- spJobDaten[playerid][spCheckpoint] = 1;
- SetPlayerCheckpoint(playerid, JobCheckpoint[spJobDaten[playerid][spJobID]][1][PosX], JobCheckpoint[spJobDaten[playerid][spJobID]][1][PosY], JobCheckpoint[spJobDaten[playerid][spJobID]][1][PosZ], 4);
- }
- }
- return 1;
- }
- ocmd:cjob(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
- }
- return 1;
- }
- ocmd:vsave(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(Fortschritt == 1 && IsPlayerInAnyVehicle(playerid))
- {
- new vid = GetPlayerVehicleID(playerid);
- GetVehiclePos(vid, Job[VehiclePosX], Job[VehiclePosY], Job[VehiclePosZ]);
- GetVehicleZAngle(vid, Job[VehiclePosA]);
- spJobDaten[playerid][spErstellung] = false;
- RemovePlayerFromVehicle(playerid);
- spJobDaten[playerid][spErstellung] = true;
- 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", "");
- }
- }
- return 1;
- }
- ocmd:psave(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(Fortschritt == 2)
- {
- GetPlayerPos(playerid, Job[PickupPosX], Job[PickupPosY], Job[PickupPosZ]);
- ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
- }
- }
- return 1;
- }
- ocmd:cpsave(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(Fortschritt >= 3 && IsPlayerInAnyVehicle(playerid))
- {
- if(Fortschritt <= MAX_JOBS+3)
- {
- new stri[16], str[128], Float:X, Float:Y, Float:Z;
- GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
- JobCheckpoint[Job[JobID]][Fortschritt-2][PosX] = X;
- JobCheckpoint[Job[JobID]][Fortschritt-2][PosY] = Y;
- JobCheckpoint[Job[JobID]][Fortschritt-2][PosZ] = Z;
- format(stri, 16, "/Jobs/%i.txt", Job[JobID]);
- new File:jobn = fopen(stri,io_append);
- if(jobn)
- {
- format(str, 128, "%f, %f, %f\r\n", X, Y, Z);
- fwrite(jobn, str);
- fclose(jobn);
- Fortschritt++;
- format(str, 128, "Checkpoint (%i/%i)", Fortschritt-3, MAX_JOBS);
- SendClientMessage(playerid, 0xFFFF00FF, str);
- SendClientMessage(playerid, 0xFFFF00FF, "Want to finish? Enter /cpfinish (no final checkpoint will be created)");
- }
- }
- else
- {
- SendClientMessage(playerid, 0xFFFF00FF, "You reached the maximum amount of checkpoints.");
- JobLaden(Job[JobID]);
- Job[JobID] = 0;
- Job[VehicleModel] = 0;
- Job[VehiclePosX] = 0.000000;
- Job[VehiclePosY] = 0.000000;
- Job[VehiclePosZ] = 0.000000;
- Job[VehiclePosA] = 0.000000;
- Job[PickupID] = 0;
- Job[PickupPosX] = 0.000000;
- Job[PickupPosY] = 0.000000;
- Job[PickupPosZ] = 0.000000;
- Job[Geld] = 0;
- Job[Farbe1] = 0;
- Job[Farbe2] = 0;
- Job[Freeze] = 0;
- Fortschritt = 0;
- cvid = 0;
- spJobDaten[playerid][spErstellung] = false;
- }
- }
- }
- return 1;
- }
- ocmd:cphelp(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- 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", "");
- }
- return 1;
- }
- ocmd:cpfinish(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(Fortschritt >= 4)
- {
- RemovePlayerFromVehicle(playerid);
- DestroyVehicle(cvid);
- JobLaden(Job[JobID]);
- Job[JobID] = 0;
- Job[VehicleModel] = 0;
- Job[VehiclePosX] = 0.000000;
- Job[VehiclePosY] = 0.000000;
- Job[VehiclePosZ] = 0.000000;
- Job[VehiclePosA] = 0.000000;
- Job[PickupID] = 0;
- Job[PickupPosX] = 0.000000;
- Job[PickupPosY] = 0.000000;
- Job[PickupPosZ] = 0.000000;
- Job[Geld] = 0;
- Job[Farbe1] = 0;
- Job[Farbe2] = 0;
- Job[Freeze] = 0;
- Fortschritt = 0;
- cvid = 0;
- spJobDaten[playerid][spErstellung] = false;
- }
- }
- return 1;
- }
- ocmd:abjob(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- new datei[32];
- format(datei, 32, "/Jobs/%i.txt", Job[JobID]);
- fremove(datei);
- if(GetPlayerVehicleID(playerid) == cvid)
- {
- RemovePlayerFromVehicle(playerid);
- }
- if(cvid > 0)
- {
- DestroyVehicle(cvid);
- }
- for(new i; i < MAX_CPS; i++)
- {
- JobCheckpoint[Job[JobID]][i][PosX] = 0.000000;
- JobCheckpoint[Job[JobID]][i][PosY] = 0.000000;
- JobCheckpoint[Job[JobID]][i][PosZ] = 0.000000;
- }
- JobDaten[Job[JobID]][cpJobID] = 0;
- JobDaten[Job[JobID]][cpPickupModel] = 0;
- JobDaten[Job[JobID]][cpPickupPosX] = 0.000000;
- JobDaten[Job[JobID]][cpPickupPosY] = 0.000000;
- JobDaten[Job[JobID]][cpPickupPosZ] = 0.000000;
- JobDaten[Job[JobID]][cpVehicleModel] = 0;
- JobDaten[Job[JobID]][cpVehiclePosX] = 0.000000;
- JobDaten[Job[JobID]][cpVehiclePosY] = 0.000000;
- JobDaten[Job[JobID]][cpVehiclePosZ] = 0.000000;
- JobDaten[Job[JobID]][cpVehiclePosA] = 0.000000;
- JobDaten[Job[JobID]][cpGeld] = 0;
- JobDaten[Job[JobID]][cpFarbe1] = 0;
- JobDaten[Job[JobID]][cpFarbe2] = 0;
- JobDaten[Job[JobID]][cpFreeze] = 0;
- Job[JobID] = 0;
- Job[VehicleModel] = 0;
- Job[VehiclePosX] = 0.000000;
- Job[VehiclePosY] = 0.000000;
- Job[VehiclePosZ] = 0.000000;
- Job[VehiclePosA] = 0.000000;
- Job[PickupID] = 0;
- Job[PickupPosX] = 0.000000;
- Job[PickupPosY] = 0.000000;
- Job[PickupPosZ] = 0.000000;
- Job[Geld] = 0;
- Job[Farbe1] = 0;
- Job[Farbe2] = 0;
- Job[Freeze] = 0;
- Fortschritt = 0;
- cvid = 0;
- spJobDaten[playerid][spErstellung] = false;
- }
- return 1;
- }
- ocmd:deljob(playerid)
- {
- if(IsPlayerAdmin(playerid))
- {
- for(new i; i < MAX_JOBS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3, JobDaten[i][cpPickupPosX], JobDaten[i][cpPickupPosY], JobDaten[i][cpPickupPosZ]))
- {
- new datei[32];
- format(datei, 32, "/Jobs/%i.txt", i);
- fremove(datei);
- DestroyPickup(JobDaten[i][cpPickupID]);
- Delete3DTextLabel(JobDaten[i][cpTextLabel]);
- for(new o; o < MAX_CPS; o++)
- {
- JobCheckpoint[i][o][PosX] = 0.000000;
- JobCheckpoint[i][o][PosY] = 0.000000;
- JobCheckpoint[i][o][PosZ] = 0.000000;
- }
- JobDaten[i][cpJobID] = 0;
- JobDaten[i][cpPickupModel] = 0;
- JobDaten[i][cpPickupPosX] = 0.000000;
- JobDaten[i][cpPickupPosY] = 0.000000;
- JobDaten[i][cpPickupPosZ] = 0.000000;
- JobDaten[i][cpVehicleModel] = 0;
- JobDaten[i][cpVehiclePosX] = 0.000000;
- JobDaten[i][cpVehiclePosY] = 0.000000;
- JobDaten[i][cpVehiclePosZ] = 0.000000;
- JobDaten[i][cpVehiclePosA] = 0.000000;
- JobDaten[i][cpGeld] = 0;
- JobDaten[i][cpFarbe1] = 0;
- JobDaten[i][cpFarbe2] = 0;
- JobDaten[i][cpFreeze] = 0;
- loeschen = 1;
- }
- }
- if(!loeschen)
- {
- ShowPlayerDialog(playerid, DIALOG_LOESCHEN, DIALOG_STYLE_INPUT, "Delete a job", "Please enter the ID of the job you want to delete.", "OK", "Abort");
- }
- loeschen = 0;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch (dialogid)
- {
- case DIALOG_JOBID:
- {
- if(response)
- {
- if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
- new str[128];
- format(str, 128, "/Jobs/%s.txt", inputtext);
- if(fexist(str))
- {
- ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Job ID in use!\nPlease enter another Job-ID.", "OK", "");
- }
- else
- {
- if(strval(inputtext) > 0 && strval(inputtext) <= MAX_JOBS)
- {
- Job[JobID] = strval(inputtext);
- new strang[16];
- format(strang, 16, "/Jobs/%i.txt", Job[JobID]);
- new File:create = fopen(strang, io_write);
- if(create)
- {
- fclose(create);
- spJobDaten[playerid][spErstellung] = true;
- }
- ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
- }
- else ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
- }
- }
- else ShowPlayerDialog(playerid, DIALOG_JOBID, DIALOG_STYLE_INPUT, "Job ID", "Please enter a Job-ID.", "OK", "");
- }
- case DIALOG_VMODEL:
- {
- if(response)
- {
- if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
- if(strval(inputtext) < 400 || strval(inputtext) > 611)
- {
- ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
- Job[VehicleModel] = strval(inputtext);
- }
- }
- else ShowPlayerDialog(playerid, DIALOG_VMODEL, DIALOG_STYLE_INPUT, "Job Vehicle", "Please enter a Vehicle-ID.", "OK", "");
- }
- case DIALOG_FARBE_1:
- {
- if(response)
- {
- if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
- if(strval(inputtext) >= 0 && strval(inputtext) <= 255)
- {
- Job[Farbe1] = strval(inputtext);
- ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Color", "Please enter the second Color ID.", "OK", "");
- }
- }
- else ShowPlayerDialog(playerid, DIALOG_FARBE_1, DIALOG_STYLE_INPUT, "1. Color", "Please enter the first Color ID.", "OK", "");
- }
- case DIALOG_FARBE_2:
- {
- if(response)
- {
- if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Color", "Please enter the second Color ID.", "OK", "");
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Color", "Please enter the second Color ID.", "OK", "");
- if(strval(inputtext) >= 0 && strval(inputtext) <= 255)
- {
- Job[Farbe2] = strval(inputtext);
- 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", "");
- }
- }
- else ShowPlayerDialog(playerid, DIALOG_FARBE_2, DIALOG_STYLE_INPUT, "2. Farbe", "Bitte gebe die 2. Farb-ID ein.", "Weiter", "");
- }
- case DIALOG_FREEZE:
- {
- if(response)
- {
- 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", "");
- 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", "");
- Job[Freeze] = strval(inputtext);
- new Float:X, Float:Y, Float:Z, Float:A;
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, A);
- cvid = CreateVehicle(Job[VehicleModel], X, Y, Z, A, Job[Farbe1], Job[Farbe2], -1);
- PutPlayerInVehicle(playerid, cvid, 0);
- Fortschritt = 1;
- SendClientMessage(playerid, 0xFFFF00FF, "Drive to the spawn location of the vehicle.");
- SendClientMessage(playerid, 0xFFFF00FF, "and type /vsave");
- }
- 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", "");
- }
- case DIALOG_PICKUPID:
- {
- if(response)
- {
- switch (listitem)
- {
- case 0: Job[PickupID] = 1240;
- case 1: Job[PickupID] = 1242;
- case 2: Job[PickupID] = 1239;
- case 3: Job[PickupID] = 1272;
- case 4: Job[PickupID] = 1273;
- case 5: Job[PickupID] = 1212;
- case 6: Job[PickupID] = 1241;
- case 7: Job[PickupID] = 1247;
- case 8: Job[PickupID] = 1252;
- case 9: Job[PickupID] = 1254;
- case 10: Job[PickupID] = 1274;
- case 11: Job[PickupID] = 1275;
- case 12: Job[PickupID] = 1277;
- case 13: Job[PickupID] = 1314;
- case 14: Job[PickupID] = 1310;
- case 15: Job[PickupID] = 1279;
- }
- Fortschritt = 2;
- SendClientMessage(playerid, 0xFFFF00FF, "Run to the spawn location of the pickup.");
- SendClientMessage(playerid, 0xFFFF00FF, "and type /psave");
- }
- 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", "");
- }
- case DIALOG_GELD:
- {
- if(response)
- {
- if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
- Job[Geld] = strval(inputtext);
- new str[128], stri[16];
- format(stri, 16, "/Jobs/%i.txt", Job[JobID]);
- new File:jobn = fopen(stri,io_append);
- if(jobn)
- {
- format(str, 128, "%i\r\n", Job[JobID]);
- fwrite(jobn, str);
- format(str, 128, "%i\r\n", Job[PickupID]);
- fwrite(jobn, str);
- format(str, 128, "%f, %f, %f\r\n", Job[PickupPosX], Job[PickupPosY], Job[PickupPosZ]);
- fwrite(jobn, str);
- format(str, 128, "%i\r\n", Job[VehicleModel]);
- fwrite(jobn, str);
- format(str, 128, "%f, %f, %f, %f\r\n", Job[VehiclePosX], Job[VehiclePosY], Job[VehiclePosZ], Job[VehiclePosA]);
- fwrite(jobn, str);
- format(str, 128, "%i\r\n", Job[Geld]);
- fwrite(jobn, str);
- format(str, 128, "%i\r\n", Job[Farbe1]);
- fwrite(jobn, str);
- format(str, 128, "%i\r\n", Job[Farbe2]);
- fwrite(jobn, str);
- format(str, 128, "%i\r\n", Job[Freeze]);
- fwrite(jobn, str);
- fclose(jobn);
- JobDaten[Job[JobID]][cpJobID] = Job[JobID];
- JobDaten[Job[JobID]][cpPickupModel] = Job[PickupID];
- JobDaten[Job[JobID]][cpPickupPosX] = Job[PickupPosX];
- JobDaten[Job[JobID]][cpPickupPosY] = Job[PickupPosY];
- JobDaten[Job[JobID]][cpPickupPosZ] = Job[PickupPosZ];
- JobDaten[Job[JobID]][cpVehicleModel] = Job[VehicleModel];
- JobDaten[Job[JobID]][cpVehiclePosX] = Job[VehiclePosX];
- JobDaten[Job[JobID]][cpVehiclePosY] = Job[VehiclePosY];
- JobDaten[Job[JobID]][cpVehiclePosZ] = Job[VehiclePosZ];
- JobDaten[Job[JobID]][cpVehiclePosA] = Job[VehiclePosA];
- JobDaten[Job[JobID]][cpGeld] = Job[Geld];
- JobDaten[Job[JobID]][cpFarbe1] = Job[Farbe1];
- JobDaten[Job[JobID]][cpFarbe2] = Job[Farbe2];
- JobDaten[Job[JobID]][cpFreeze] = Job[Freeze];
- }
- Fortschritt = 3;
- PutPlayerInVehicle(playerid, cvid, 0);
- SendClientMessage(playerid, 0xFFFF00FF, "Drive to the positions of the checkpoints.");
- SendClientMessage(playerid, 0xFFFF00FF, "Use /cpsave to create a checkpoint at your location.");
- }
- else ShowPlayerDialog(playerid, DIALOG_GELD, DIALOG_STYLE_INPUT, "Payment", "Please enter the amount of money.", "OK", "");
- }
- case DIALOG_LOESCHEN:
- {
- if(response)
- {
- 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");
- 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");
- new job = strval(inputtext);
- new datei[32];
- format(datei, 32, "/Jobs/%i.txt", job);
- if(fexist(datei))
- {
- fremove(datei);
- DestroyPickup(JobDaten[job][cpPickupID]);
- Delete3DTextLabel(JobDaten[job][cpTextLabel]);
- for(new i; i < MAX_CPS; i++)
- {
- JobCheckpoint[job][i][PosX] = 0.000000;
- JobCheckpoint[job][i][PosY] = 0.000000;
- JobCheckpoint[job][i][PosZ] = 0.000000;
- }
- JobDaten[job][cpJobID] = 0;
- JobDaten[job][cpPickupModel] = 0;
- JobDaten[job][cpPickupPosX] = 0.000000;
- JobDaten[job][cpPickupPosY] = 0.000000;
- JobDaten[job][cpPickupPosZ] = 0.000000;
- JobDaten[job][cpVehicleModel] = 0;
- JobDaten[job][cpVehiclePosX] = 0.000000;
- JobDaten[job][cpVehiclePosY] = 0.000000;
- JobDaten[job][cpVehiclePosZ] = 0.000000;
- JobDaten[job][cpVehiclePosA] = 0.000000;
- JobDaten[job][cpGeld] = 0;
- JobDaten[job][cpFarbe1] = 0;
- JobDaten[job][cpFarbe2] = 0;
- JobDaten[job][cpFreeze] = 0;
- loeschen = 0;
- }
- 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");
- }
- }
- }
- return 0;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- for(new i; i < MAX_VEHICLES; i++)
- {
- if(vehicleid == spJobDaten[i][spJobVehicleID])
- {
- DestroyVehicle(vehicleid);
- }
- }
- if(spJobDaten[killerid][spAktiv] == true)
- {
- spJobDaten[killerid][spAktiv] = false;
- spJobDaten[killerid][spJobID] = 0;
- spJobDaten[killerid][spJobVehicleID] = 0;
- spJobDaten[killerid][spCheckpoint] = 0;
- DisablePlayerCheckpoint(killerid);
- }
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(spJobDaten[playerid][spAktiv] == true && vehicleid != spJobDaten[playerid][spJobVehicleID])
- {
- spJobDaten[playerid][spAktiv] = false;
- spJobDaten[playerid][spJobID] = 0;
- DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- if(spJobDaten[playerid][spAktiv] == true)
- {
- spJobDaten[playerid][spAktiv] = false;
- spJobDaten[playerid][spJobID] = 0;
- DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
- DisablePlayerCheckpoint(playerid);
- spJobDaten[playerid][spJobVehicleID] = 0;
- spJobDaten[playerid][spCheckpoint] = 0;
- }
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- if(spJobDaten[playerid][spAktiv] == true)
- {
- DisablePlayerCheckpoint(playerid);
- spJobDaten[playerid][spCheckpoint]++;
- if(JobCheckpoint[spJobDaten[playerid][spJobID]][spJobDaten[playerid][spCheckpoint]][PosX] == 0.000000)
- {
- RemovePlayerFromVehicle(playerid);
- DestroyVehicle(spJobDaten[playerid][spJobVehicleID]);
- spJobDaten[playerid][spJobGeld] += JobDaten[spJobDaten[playerid][spJobID]][cpGeld];
- // GivePlayerMoney(playerid, JobDaten[spJobDaten[playerid][spJobID]][cpGeld]);
- /*
- Here you have to enter your code for giving the player the money for completing the job!
- Maybe you use "CallRemoteFunction" for editing the money of the player in the gamemode.
- example: CallRemoteFunction("IncreasePlayerMoney", "dd", playerid, JobDaten[spJobDaten[playerid][spJobID]][cpGeld]);
- In your gamemode there should be a similiar public:
- forward IncreasePlayerMoney(playerid, amount);
- public IncreasePlayerMoney(playerid, amount)
- {
- pData[playerid][pMoney] += amount; // Player money variable
- GivePlayerMoney(playerid, amount); // Updating the Money on the player's screen
- return 1;
- }
- */
- spJobDaten[playerid][spJobGeld] = 0; // Resetting the Player's amount of money he got from finishing the job
- spJobDaten[playerid][spAktiv] = false;
- spJobDaten[playerid][spJobID] = 0;
- spJobDaten[playerid][spJobVehicleID] = 0;
- spJobDaten[playerid][spCheckpoint] = 0;
- }
- else
- {
- if(JobDaten[spJobDaten[playerid][spJobID]][cpFreeze] > 0)
- {
- TogglePlayerControllable(playerid, 0);
- SetTimerEx("JobCheckpointFreeze", JobDaten[spJobDaten[playerid][spJobID]][cpFreeze], false, "i", playerid);
- }
- 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);
- }
- }
- return 1;
- }
- new Fahrzeugnamen[][] = {
- "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto",
- "Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion",
- "Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van",
- "Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina",
- "Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson",
- "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",
- "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",
- "Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster","Monster","Uranus","Jester",
- "Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley",
- "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",
- "Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer","Luggage Trailer","Stair Trailer","Boxville","Farm Plow","Utility Trailer"
- };
- stock GetVehicleName(modelid)
- {
- new String[128];
- format(String,sizeof(String),"%s",Fahrzeugnamen[modelid - 400]);
- return String;
- }
- IsNumeric(const string[])
- {
- for(new i, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- stock DateiJobLaden(jobid)
- {
- new string[16], save[128], line=1, i;
- format(string, sizeof(string), "/Jobs/%i.txt", jobid);
- if(!fexist(string)) return 1;
- else
- {
- new File:job = fopen(string, io_read);
- if(job)
- {
- while(fread(job, save))
- {
- new idx;
- switch(line)
- {
- case 1: JobDaten[jobid][cpJobID] = strval(strtok(save, idx));
- case 2: JobDaten[jobid][cpPickupModel] = strval(strtok(save, idx));
- case 3:
- {
- JobDaten[jobid][cpPickupPosX] = floatstr(strtok(save, idx));
- JobDaten[jobid][cpPickupPosY] = floatstr(strtok(save, idx));
- JobDaten[jobid][cpPickupPosZ] = floatstr(strtok(save, idx));
- }
- case 4: JobDaten[jobid][cpVehicleModel] = strval(strtok(save, idx));
- case 5:
- {
- JobDaten[jobid][cpVehiclePosX] = floatstr(strtok(save, idx));
- JobDaten[jobid][cpVehiclePosY] = floatstr(strtok(save, idx));
- JobDaten[jobid][cpVehiclePosZ] = floatstr(strtok(save, idx));
- JobDaten[jobid][cpVehiclePosA] = floatstr(strtok(save, idx));
- }
- case 6: JobDaten[jobid][cpGeld] = strval(strtok(save, idx));
- case 7: JobDaten[jobid][cpFarbe1] = strval(strtok(save, idx));
- case 8: JobDaten[jobid][cpFarbe2] = strval(strtok(save, idx));
- case 9: JobDaten[jobid][cpFreeze] = strval(strtok(save, idx));
- case 10..(MAX_CPS+9):
- {
- JobCheckpoint[jobid][i][PosX] = floatstr(strtok(save, idx));
- JobCheckpoint[jobid][i][PosY] = floatstr(strtok(save, idx));
- JobCheckpoint[jobid][i][PosZ] = floatstr(strtok(save, idx));
- i++;
- }
- }
- line++;
- }
- fclose(job);
- }
- JobDaten[jobid][cpPickupID] = CreatePickup(JobDaten[jobid][cpPickupModel], 1, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ]);
- new str[128];
- format(str, sizeof(str), "/start\nVehicle: %s", GetVehicleName(JobDaten[jobid][cpVehicleModel]));
- JobDaten[jobid][cpTextLabel] = Create3DTextLabel(str, 0xFFFF00FF, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ], 50, 0);
- printf("Job %i loaded successfully.", jobid);
- }
- return 1;
- }
- stock JobLaden(jobid)
- {
- JobDaten[jobid][cpPickupID] = CreatePickup(JobDaten[jobid][cpPickupModel], 1, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ]);
- new str[128];
- format(str, sizeof(str), "/start\nVehicle: %s", GetVehicleName(JobDaten[jobid][cpVehicleModel]));
- JobDaten[jobid][cpTextLabel] = Create3DTextLabel(str, 0xFFFF00FF, JobDaten[jobid][cpPickupPosX], JobDaten[jobid][cpPickupPosY], JobDaten[jobid][cpPickupPosZ], 50, 0);
- return 1;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- forward JobCheckpointFreeze(playerid);
- public JobCheckpointFreeze(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- return 1;
- }
- stock SpielerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- return name;
- }
Add Comment
Please, Sign In to add comment