SA-MP Forums Archive
Need help with fixing a Job. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with fixing a Job. (/showthread.php?tid=320923)



Need help with fixing a Job. - rangerxxll - 25.02.2012

Hello,
I'm a little rusty, I haven't scripted for a while now.

First, let me explain the job I'm trying to make. I'm trying to make it, so you have to be in a truck in order to even start the job, and if you exit the truck while delivering it cancels your delivery. So once you're in the truck, you need to drive to point A to point B, to a checkpoint where you will then unload and earn 2500.

I'm having a problem with (!IsPlayerInRangeOfPoint). I want it so if you're "Not" near the spot where you start the job, then a message will pop up saying "You must be at the correct spot to start the job" And if you are at the correct spot, then you'll start and receive a message saying "Drive to the checkpoint"

Here's my current code. I know, it's not much.
pawn Code:
new deliveryjob[MAX_PLAYERS] = 0;

CMD:delivery(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid,3.0, -62.0572,-1121.8473,1.3233)) return SendClientMessage(playerid, COLOR_RED, "You're not in range of the Delivery place");
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498) return SendClientMessage(playerid, COLOR_RED, "You must be in a Delivery Truck.");
        {
            deliveryjob[playerid] = 1;
            SetPlayerCheckpoint(playerid, 680.8652,-441.9654,16.3359, 4.0);
        }
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(deliveryjob[playerid] == 1)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498) return SendClientMessage(playerid, COLOR_RED, "You must be in a Delivery Truck in order to deliver");
        {
            GivePlayerMoney(playerid, 2500);
            SendClientMessage(playerid, COLOR_GREEN, "Congratulations, you've earned 2500");
        }
    }
    return 1;
}
I know I'm doing a lot wrong, most likely. Anyone want to help me out?


Re: Need help with fixing a Job. - FalconX - 25.02.2012

Quote:
Originally Posted by rangerxxll
View Post
Hello,
I'm a little rusty, I haven't scripted for a while now.

First, let me explain the job I'm trying to make. I'm trying to make it, so you have to be in a truck in order to even start the job, and if you exit the truck while delivering it cancels your delivery. So once you're in the truck, you need to drive to point A to point B, to a checkpoint where you will then unload and earn 2500.

I'm having a problem with (!IsPlayerInRangeOfPoint). I want it so if you're "Not" near the spot where you start the job, then a message will pop up saying "You must be at the correct spot to start the job" And if you are at the correct spot, then you'll start and receive a message saying "Drive to the checkpoint"

Here's my current code. I know, it's not much.
pawn Code:
new deliveryjob[MAX_PLAYERS] = 0;

CMD:delivery(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid,3.0, -62.0572,-1121.8473,1.3233)) return SendClientMessage(playerid, COLOR_RED, "You're not in range of the Delivery place");
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498) return SendClientMessage(playerid, COLOR_RED, "You must be in a Delivery Truck.");
        {
            deliveryjob[playerid] = 1;
            SetPlayerCheckpoint(playerid, 680.8652,-441.9654,16.3359, 4.0);
        }
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(deliveryjob[playerid] == 1)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498) return SendClientMessage(playerid, COLOR_RED, "You must be in a Delivery Truck in order to deliver");
        {
            GivePlayerMoney(playerid, 2500);
            SendClientMessage(playerid, COLOR_GREEN, "Congratulations, you've earned 2500");
        }
    }
    return 1;
}
I know I'm doing a lot wrong, most likely. Anyone want to help me out?
pawn Code:
new deliveryjob[MAX_PLAYERS] = 0;

CMD:delivery(playerid, params[])
{
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498) return SendClientMessage(playerid, COLOR_RED, "You       must be in a Delivery Truck.");
    if(IsPlayerInRangeOfPoint(playerid,3.0, x y z of your main cp))
        {
           deliveryjob[playerid] = 1;
           SetPlayerCheckpoint(playerid, 680.8652,-441.9654,16.3359, 4.0);
     }
else
         {
            SendClientMessage(playerid, color, "you are not near the cp");
         }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(deliveryjob[playerid] == 1)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498)
            {
            GivePlayerMoney(playerid, 2500);
            SendClientMessage(playerid, COLOR_GREEN, "Congratulations, you've earned 2500");
            }
            else
           {
              SendClientMessage(playerid, COLOR_RED, "You must be in a Delivery Truck in order to deliver");
            }

        }

}
    return 1;
I just wrote fast from my phone, many identations are f**ked up :P

Well i changed few lines from the command, check and also
If worked reply down so i know it worked

-FalconX