I need help with checkpoints..(i will +REP)
#1

I have never used Checkpoints before so i don't know why this doesn't work.. please help (i will +REP)

Код:
public OnPlayerEnterCheckpoint(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 7.0, 361.8299,173.7157,1008.3828))
	{
		ShowPlayerDialog(playerid, 50, DIALOG_STYLE_LIST, "Legal jobs", "Sweeper \nFisher",  "Select", "Cancel" );
	}
	if(CheckPoint[playerid] == 1)
	{
	    CheckPoint[playerid] = 2;
		GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2390.6677,93.3617,26.0623, 3.0);
 }
	if(CheckPoint[playerid] == 2)
	{
	    CheckPoint[playerid] = 3;
	    GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2298.4270,92.8902,26.0687, 3.0);
	}
	if(CheckPoint[playerid] == 3)
	{
	    CheckPoint[playerid] = 4;
	    GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2226.5247,93.1881,26.0639, 3.0);
	}
	if(CheckPoint[playerid] == 4)
	{
	    CheckPoint[playerid] = 5;
	    GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2226.5745,136.5735,26.0609, 3.0);
	}
	if(CheckPoint[playerid] == 5)
	{
	    CheckPoint[playerid] = 6;
	    GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2287.3296,138.5096,26.0610, 3.0);
	}
	if(CheckPoint[playerid] == 6)
	{
	    CheckPoint[playerid] = 7;
	    GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2291.4209,29.7152,26.0627, 3.0);
	}
	if(CheckPoint[playerid] == 7)
	{
	    CheckPoint[playerid] = 8;
	    GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2291.5344,-23.7885,26.0611, 3.0);
	}
	if(CheckPoint[playerid] == 8)
	{
	    CheckPoint[playerid] = 9;
		GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2291.6882,-85.8780,26.0602, 3.0);
	}
	if(CheckPoint[playerid] == 9)
	{
	    CheckPoint[playerid] = 10;
		GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2336.1030,-99.4473,26.0610, 3.0);
	}
	if(CheckPoint[playerid] == 10)
	{
	    CheckPoint[playerid] = 11;
		GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2346.3970,-18.9140,26.0585, 3.0);
	}
	if(CheckPoint[playerid] == 11)
	{
	    CheckPoint[playerid] = 12;
		GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2345.3276,82.7408,26.0637, 3.0);
	}
	if(CheckPoint[playerid] == 12)
	{
	    CheckPoint[playerid] = 13;
		GivePlayerMoney(playerid, 100);
		SetPlayerCheckpoint(playerid, 2387.1504,88.7044,26.0700, 3.0);
	}
	if(CheckPoint[playerid] == 13)
	{
		DisablePlayerCheckpoint(playerid);
		GivePlayerMoney(playerid, 100);
	}
	return 1;
}
Reply
#2

More details..
The first checkpoints shows up (when i write /start),
but none of the others shows up..
Reply
#3

A script only ends if it encounters a) the closing brace at the end of the function or b) a return statement. You set CheckPoint[playerid] to 2. But the script doesn't end there. The following if-statments checks if CheckPoint[playerid] is equal to 2. It is, because you just set it to 2 yourself. So that block is executed as well. This continues down the chain.

I recommend using a switch statement (easy) or an array of coordinates (slightly more difficult, but easier to maintain).

pawn Код:
switch(CheckPoint[playerid])
{
    case 1: {}
    case 2: {}
    case 3: {}
    // ...
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)