OnPlayerEnterCheckpoint Not working
#1

Hi,

I'm trying to make simple an RP Fedex job.

I'm creating the SetPlayerCheckpoint, then i want the player to go thorugh the checkpoints and every checkpoint he enter another checkpoint appears and the last dissapears.

But it doesn't appears after entering the first checkpoint.

So here's the code:

Код:
new FedexJob[MAX_PLAYERS];
new FedexStep[MAX_PLAYERS];
Using Enum
Код:
DrivingStep[playerid] = 0; FedexJob[playerid] = 0;
Then Creating Command
Код:
CMD:loadmail(playerid, params[])
{
    FedexJob[playerid] = 1;
    FedexStep[playerid] = 1;
    SetPlayerCheckpoint(playerid,1965.1832,-1992.3107,13.4766,5);
    return 1;
}
Then under public OnPlayerEnterCheckpoint(playerid)
Код:
if(IsFedexVehicle(playerid))
{
	if(FedexJob[playerid] == 1) // Fedex Route
	{
		if(IsPlayerInRangeOfPoint(playerid,5,1965.1832,-1992.3107,13.4766)) // Checkpoint 1
		{
			FedexStep[playerid] = 2;
			SetPlayerCheckpoint(playerid,1932.7761,-1777.1222,13.1099,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1932.7761,-1777.1222,13.1099)) // Checkpoint 2
		{
			FedexStep[playerid] = 3;
			SetPlayerCheckpoint(playerid,2095.7678,-1799.1807,13.1115,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,2095.7678,-1799.1807,13.1115)) // Checkpoint 3
		{
			FedexStep[playerid] = 4;
			SetPlayerCheckpoint(playerid,2245.0481,-1659.6323,15.0141,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,2245.0481,-1659.6323,15.0141)) // Checkpoint 4
		{
			FedexStep[playerid] = 5;
			SetPlayerCheckpoint(playerid,1696.4751,-1505.9568,13.1099,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1696.4751,-1505.9568,13.1099)) // Checkpoint 5
		{
			FedexStep[playerid] = 6;
			SetPlayerCheckpoint(playerid,1533.3690,-1658.0847,13.1099,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1533.3690,-1658.0847,13.1099)) // Checkpoint 6
		{
			FedexStep[playerid] = 7;
			SetPlayerCheckpoint(playerid,1325.7488,-1568.8619,13.0892,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1325.7488,-1568.8619,13.0892)) // Checkpoint 7
		{
			FedexStep[playerid] = 8;
			SetPlayerCheckpoint(playerid,1227.0610,-1826.7629,13.1372,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1227.0610,-1826.7629,13.1372)) // Checkpoint 8
		{
			FedexStep[playerid] = 9;
			SetPlayerCheckpoint(playerid,1357.6099,-1754.7562,13.0843,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1357.6099,-1754.7562,13.0843)) // Checkpoint 9
		{
			FedexStep[playerid] = 10;
			SetPlayerCheckpoint(playerid,1734.1602,-1736.1362,13.1144,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1734.1602,-1736.1362,13.1144)) // Checkpoint 10
		{
			FedexStep[playerid] = 11;
			SetPlayerCheckpoint(playerid,1772.5981,-1736.2996,13.1099,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1772.5981,-1736.2996,13.1099)) // Checkpoint 11
		{
			FedexStep[playerid] = 12;
			SetPlayerCheckpoint(playerid,1958.0129,-1980.9946,13.1177,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1958.0129,-1980.9946,13.1177)) // Checkpoint 12
		{
			FedexStep[playerid] = 13;
			SetPlayerCheckpoint(playerid,1787.9861,-2059.3037,13.3097,5);
		}
		else if(IsPlayerInRangeOfPoint(playerid,5,1787.9861,-2059.3037,13.3097)) // Checkpoint DONE
		{
			FedexJob[playerid] = 0;
			FedexStep[playerid] = 0;
			GiveDodMoney(playerid, 5000);
			SendClientMessage(playerid, COLOR_LIGHTGREEN, "Thank you for delivering mails for the businesses. Job is done. Heres Your Paycheck, {FF6347}5000${FFFFFF}.");
		}
	}
}// FEDEX END
So, anyone knows why after entering the first Checkpoint it dissapears and the 2nd checkpoint doesn't appears?
Reply
#2

Replace

pawn Код:
if(FedexJob[playerid] == 1) // Fedex Route
With

pawn Код:
if(FedexJob[playerid] >= 1) // Fedex Route
Reply
#3

Quote:
Originally Posted by Skimmer
Посмотреть сообщение
Replace

pawn Код:
if(FedexJob[playerid] == 1) // Fedex Route
With

pawn Код:
if(FedexJob[playerid] >= 1) // Fedex Route
Same thing. when I'm entering the first checkpoint it disappears and the 2nd checkpoint doesn't appears.
Reply
#4

Where is that function, IsFedexVehicle placed?
Which callback?
Reply
#5

I found another bug.

This should still like this.

pawn Код:
if(FedexJob[playerid] >= 1) // Fedex Route
In the first check, where you use IsPlayerInRangeOfPoint, there's a miss.

Here it is.

pawn Код:
if(IsPlayerInRangeOfPoint(playerid,5,1965.1832,-1992.3107,13.4766)) // Checkpoint 1
The 5 is size and it should stay in last place.

This

pawn Код:
if(IsPlayerInRangeOfPoint(playerid,1965.1832,-1992.3107,13.4766,5)) // Checkpoint 1
Reply
#6

Quote:
Originally Posted by Tagathron
Посмотреть сообщение
Where is that function, IsFedexVehicle placed?
Which callback?
I tried to fix the problem maybe using specific vehicles but it responses the same as if(IsPlayerInAnyVehicle(playerid))




wait a minute!

I tried to make if(IsPlayerInAnyVehicle(playerid)) with the >= solution and it worked! thanks guys!!
Reply
#7

Why would you need IsPlayerInRangeOfPoint()? It's absolute non-sense entering a checkpoint IMPLIES your within range of a point there is no need for that check, it serves absolutely no purpose but to fuck up your code like it has. You only need to keep track of a checkpoint index for example....

pawn Код:
#define FEDEX_STEP_1

CPIndex[playerid] = FEDEX_STEP_1

OnPlayerEnterCheckPoint(playerid)
{
    switch(CPIndex[playerid])
    {
        case FEDEX_STEP_1: { }
        case FEDEX_STEP_2: { }
        case FEDEX_STEP_3: { }
        case FEDEX_STEP_4: { }
        case FEDEX_STEP_5: { }
        case FEDEX_STEP_6: { }

    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)