SA-MP Forums Archive
When I enter checkpoint, second checkpoint is not appearing. - 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: When I enter checkpoint, second checkpoint is not appearing. (/showthread.php?tid=570162)



When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 05.04.2015

So I made pizzaboy job, player needs to go through few checkpoints, but as soon as I enter first checkpoint, I get message that I delivered goods, but next checkpoint does not appears, I even used DisablePlayerCheckpoint but it still didn't work, see code below.

Code:
public OnPlayerEnterCheckpoint(playerid)
{
	if(checkpointStage == 1)
	{
        DisablePlayerCheckpoint(playerid);
	checkpointStage = 2;
	SendClientMessage(playerid, -1, "Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
	SetPlayerCheckpoint(playerid, 745.1824,-550.9210,17.1799, 5);
	return 1;
	}
	else if(checkpointStage == 2)
	{
	DisablePlayerCheckpoint(playerid);
	checkpointStage = 3;
 	SendClientMessage(playerid, -1, "Pizza delivered, now go to next checkpoint.");
	SetPlayerCheckpoint(playerid, 271.5015,-51.9949,1.9796, 5);
	}
	return 1;
}
by the way, checkpointStage gets set to 1 as soon as you get in the pizza bike. I am not sure what is problem, so help would be appreciated.


Re: When I enter checkpoint, second checkpoint is not appearing. - Affan - 05.04.2015

pawn Code:
new checkpointStage[MAX_PLAYERS];

public OnPlayerEnterCheckpoint(playerid)
{
    if(checkpointStage == 1)
    {
        DisablePlayerCheckpoint(playerid);
        checkpointStage[playerid] = 2;
        SendClientMessage(playerid, -1, "Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
        SetPlayerCheckpoint(playerid, 745.1824,-550.9210,17.1799, 5);
    }
    else if(checkpointStage == 2)
    {
        DisablePlayerCheckpoint(playerid);
        checkpointStage[playerid] = 3;
        SendClientMessage(playerid, -1, "Pizza delivered, now go to next checkpoint.");
        SetPlayerCheckpoint(playerid, 271.5015,-51.9949,1.9796, 5);
    }
    return 1;
}



Re: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 05.04.2015

Quote:
Originally Posted by Affan
View Post
pawn Code:
new checkpointStage[MAX_PLAYERS];

public OnPlayerEnterCheckpoint(playerid)
{
    if(checkpointStage == 1)
    {
        DisablePlayerCheckpoint(playerid);
        checkpointStage[playerid] = 2;
        SendClientMessage(playerid, -1, "Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
        SetPlayerCheckpoint(playerid, 745.1824,-550.9210,17.1799, 5);
    }
    else if(checkpointStage == 2)
    {
        DisablePlayerCheckpoint(playerid);
        checkpointStage[playerid] = 3;
        SendClientMessage(playerid, -1, "Pizza delivered, now go to next checkpoint.");
        SetPlayerCheckpoint(playerid, 271.5015,-51.9949,1.9796, 5);
    }
    return 1;
}
I am getting following errors with that script:

Code:
(111) : error 033: array must be indexed (variable "checkpointStage")
(113) : warning 217: loose indentation
(115) : warning 217: loose indentation
(130) : error 033: array must be indexed (variable "checkpointStage")
(137) : error 033: array must be indexed (variable "checkpointStage")
3 Errors.



Re: When I enter checkpoint, second checkpoint is not appearing. - CalvinC - 05.04.2015

Use [playerid]
Code:
if(checkpointStage[playerid] == 1)
else if(checkpointStage[playerid] == 2)



Re: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 05.04.2015

Okay I fixed errors but I still don't get checkpoint. I get message that I arrive at first checkpoint but second checkpoint does not appear.


Re: When I enter checkpoint, second checkpoint is not appearing. - Jimmy0wns - 05.04.2015

Give us the code you use to set the checkpoint in the first choice, this wouldn't work because you never set the value to 1.


Re: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 06.04.2015

Quote:
Originally Posted by Jimmy0wns
View Post
Give us the code you use to set the checkpoint in the first choice, this wouldn't work because you never set the value to 1.
This is where I first set checkpointstage to 1, and checkpoint too.

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	
	//if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
	 if(GetVehicleModel(vehicleid) == 448) {

        SendClientMessage(playerid, -1, "You jumped on a Pizza Boy bike!");
        checkpointStage[playerid] = 1; // stage 1 - getting on a bike.
	// do the rest
	SetPlayerCheckpoint(playerid, 1450.4535,373.7550,19.0953, 5);
    }
    return 1;
}



AW: When I enter checkpoint, second checkpoint is not appearing. - Mencent - 06.04.2015

Hello!

Where is the code that is available in OnPlayerEnterCheckpoint?

Mencent


Re: AW: When I enter checkpoint, second checkpoint is not appearing. - kingcrome - 06.04.2015

Quote:
Originally Posted by Mencent
View Post
Hello!

Where is the code that is available in OnPlayerEnterCheckpoint?

Mencent
Its at the very top...


Re: AW: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 06.04.2015

Quote:
Originally Posted by Mencent
View Post
Hello!

Where is the code that is available in OnPlayerEnterCheckpoint?

Mencent
Hi, its in original post.


AW: Re: AW: When I enter checkpoint, second checkpoint is not appearing. - Mencent - 06.04.2015

Quote:
Originally Posted by Nika1010
Посмотреть сообщение
Hi, its in original post.
Sorry, I don't saw it.

Well, what is printing?
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    print(
"OnPlayerEnterCheckpoint called");
    
DisablePlayerCheckpoint(playerid);
    if(
checkpointStage[playerid] == 1)
    {
        print(
"checkpointStage[playerid] == 1");
        
checkpointStage[playerid] = 2;
        
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
        
SetPlayerCheckpoint(playerid745.1824,-550.9210,17.17995);
        return 
1;
    }
    else if(
checkpointStage[playerid] == 2)
    {
        print(
"checkpointStage[playerid] == 2");
        
checkpointStage[playerid] = 3;
         
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint.");
        
SetPlayerCheckpoint(playerid271.5015,-51.9949,1.97965);
    }
    return 
1;

Mencent


Re: AW: Re: AW: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 06.04.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Sorry, I don't saw it.

Well, what is printing?
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    print(
"OnPlayerEnterCheckpoint called");
    
DisablePlayerCheckpoint(playerid);
    if(
checkpointStage[playerid] == 1)
    {
        print(
"checkpointStage[playerid] == 1");
        
checkpointStage[playerid] = 2;
        
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
        
SetPlayerCheckpoint(playerid745.1824,-550.9210,17.17995);
        return 
1;
    }
    else if(
checkpointStage[playerid] == 2)
    {
        print(
"checkpointStage[playerid] == 2");
        
checkpointStage[playerid] = 3;
         
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint.");
        
SetPlayerCheckpoint(playerid271.5015,-51.9949,1.97965);
    }
    return 
1;

Mencent
Well, its still same, as I commented it does print that pizza is delivered but I am getting no new checkpoint..

EDIT: I am getting this in server:
OnPlayerEnterCheckpoint called
checkpointStage[playerid] == 1


AW: When I enter checkpoint, second checkpoint is not appearing. - Mencent - 06.04.2015

You should send me your server-log.

EDIT:
@Nicka1010:
What is printing now?
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    print(
"OnPlayerEnterCheckpoint called");
    
printf("checkpointStage[playerid] = %d",checkpointStage[playerid]);
    
DisablePlayerCheckpoint(playerid);
    if(
checkpointStage[playerid] == 1)
    {
        print(
"checkpointStage[playerid] == 1");
        
checkpointStage[playerid] = 2;
        
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
        
SetPlayerCheckpoint(playerid745.1824,-550.9210,17.17995);
        
printf("checkpointStage[playerid] == %d",checkpointStage[playerid]);
        return 
1;
    }
    else if(
checkpointStage[playerid] == 2)
    {
        print(
"checkpointStage[playerid] == 2");
        
checkpointStage[playerid] = 3;
         
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint.");
        
SetPlayerCheckpoint(playerid271.5015,-51.9949,1.97965);
    }
    return 
1;

Mencent


Re: AW: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 06.04.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
You should send me your server-log.

Mencent
I edited post above, check it .


AW: When I enter checkpoint, second checkpoint is not appearing. - Mencent - 06.04.2015

Ok! I also edited my post.

Mencent


Re: AW: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 06.04.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
You should send me your server-log.

EDIT:
@Nicka1010:
What is printing now?
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    print(
"OnPlayerEnterCheckpoint called");
    
printf("checkpointStage[playerid] = %d",checkpointStage[playerid]);
    
DisablePlayerCheckpoint(playerid);
    if(
checkpointStage[playerid] == 1)
    {
        print(
"checkpointStage[playerid] == 1");
        
checkpointStage[playerid] = 2;
        
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint."); //This gets sent, but I get no checkpoint
        
SetPlayerCheckpoint(playerid745.1824,-550.9210,17.17995);
        
printf("checkpointStage[playerid] == %d",checkpointStage[playerid]);
        return 
1;
    }
    else if(
checkpointStage[playerid] == 2)
    {
        print(
"checkpointStage[playerid] == 2");
        
checkpointStage[playerid] = 3;
         
SendClientMessage(playerid, -1"Pizza delivered, now go to next checkpoint.");
        
SetPlayerCheckpoint(playerid271.5015,-51.9949,1.97965);
    }
    return 
1;

Mencent
Код:
OnPlayerEnterCheckpoint called
checkpointStage[playerid] = 1
checkpointStage[playerid] == 1
checkpointStage[playerid] == 2



AW: When I enter checkpoint, second checkpoint is not appearing. - Mencent - 06.04.2015

So, I have test it. For me it works.
Код:
[22:01:13] OnPlayerEnterCheckpoint called
[22:01:13] checkpointStage[playerid] = 1
[22:01:13] checkpointStage[playerid] == 1
[22:01:13] checkpointStage[playerid] == 2
[22:02:29] OnPlayerEnterCheckpoint called
[22:02:29] checkpointStage[playerid] = 1
[22:02:29] checkpointStage[playerid] == 1
[22:02:29] checkpointStage[playerid] == 2
[22:03:46] OnPlayerEnterCheckpoint called
[22:03:46] checkpointStage[playerid] = 2
[22:03:46] checkpointStage[playerid] == 2
If that does not work for you, then add the code once in an empty game mode, and then test it. Does it work then?

Mencent


Re: AW: When I enter checkpoint, second checkpoint is not appearing. - Nika1010 - 08.04.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
So, I have test it. For me it works.
Код:
[22:01:13] OnPlayerEnterCheckpoint called
[22:01:13] checkpointStage[playerid] = 1
[22:01:13] checkpointStage[playerid] == 1
[22:01:13] checkpointStage[playerid] == 2
[22:02:29] OnPlayerEnterCheckpoint called
[22:02:29] checkpointStage[playerid] = 1
[22:02:29] checkpointStage[playerid] == 1
[22:02:29] checkpointStage[playerid] == 2
[22:03:46] OnPlayerEnterCheckpoint called
[22:03:46] checkpointStage[playerid] = 2
[22:03:46] checkpointStage[playerid] == 2
If that does not work for you, then add the code once in an empty game mode, and then test it. Does it work then?

Mencent
Yes, it works on empty gamemode, we are going to start over whole gamemode, any tips on how to avoid it next time? or any idea what is the problem?