• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Please help me out with a basic job.
#3
(2024-05-03, 06:39 PM)carl_anderson Wrote: created this code for harvesting job, go try it out
it just creates array of points player has to go through.

Code:
new bool:IsPlayerHarvesting[MAX_PLAYERS];
new HarvestingPointIndex[MAX_PLAYERS];

// creates array of harvesting points, player has to go through
new Float:HarvestingPoints[][] = {
    {21.3124, 62.0883, 3.1172},
    {13.2968, 37.2150, 3.1172},
    {64.9920, -32.5298, 0.7534},
    {72.8307, 19.9228, 0.6094}
};

SetHarvestingPoint(playerid) {
    new index = HarvestingPointIndex[playerid];
    SetPlayerCheckpoint(playerid,
        HarvestingPoints[index][0], HarvestingPoints[index][1], HarvestingPoints[index][2],
        10.0
    );
}

// https://www.open.mp/docs/scripting/callbacks/OnPlayerEnterVehicle
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
    // player enters vehicle as driver
    if (ispassenger == 0) {
        // gets vehicle model id
        new modelid = GetVehicleModel(vehicleid);
        // https://sampwiki.blast.hk/wiki/Vehicles:All (vehicle model ids are here)
        if (modelid == 532) {
            SendClientMessage(playerid, -1, "You entered harvester, drive through checkpoints and get $50!");
            IsPlayerHarvesting[playerid] = true;
            HarvestingPointIndex[playerid] = 0;
            SetHarvestingPoint(playerid);
        }
    }
    return 1;
}

// https://www.open.mp/docs/scripting/callbacks/OnPlayerEnterCheckpoint
public OnPlayerEnterCheckpoint(playerid) {
    DisablePlayerCheckpoint(playerid);
    // checks if player is doing harvesting job
    if (IsPlayerHarvesting[playerid]) {
        HarvestingPointIndex[playerid] += 1; // goes to next point
        if (HarvestingPointIndex[playerid] == sizeof(HarvestingPoints)) {
            IsPlayerHarvesting[playerid] = false; // not harvesting anymore
            GivePlayerMoney(playerid, 50);
        } else {
            SetHarvestingPoint(playerid);
        }
    }
    return 1;
}

Thanks for your help but the strange thing is when I go in the combine harvester nothing happens. I've tried to make a filterscript out of it but it's like the code isn't even there. No checkpoints and it ain't marked on the map either I've tried to drive around the coordinates just to see if I get the $50 but nothing.
  Reply


Messages In This Thread
Please help me out with a basic job. - by x3nt1s - 2024-05-03, 07:19 AM
RE: Please help me out with a basic job. - by x3nt1s - 2024-05-04, 09:26 AM

Forum Jump: