OnPlayerEnterDynamicCP is not called
#1

Hello all

pawn Код:
enum CheckPointPlaces
{
    //other variables
    AirPort, //number 20
};

new CheckPoint[CheckPointPlaces];
pawn Код:
CheckPoint[AirPort] = CreateDynamicCP(1318.4940,1262.3025,10.8203, 1.5, 0, -1, -1, 40.0);
Create3DTextLabel("AirPort", COLOUR_LIGHTGREEN, 1318.4940,1262.3025,11.5, 40.0, 0, 0);
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    switch(checkpointid)
    {
        case AirPort:
        {
                  //code
        }
    }
    return 0;
}
Why is'case AirPort' not called? It works when I use 'case 20', but not when I use 'case AirPort'. The value of 'AirPort' is 20. My other checkpointids work, but not this one. Anyone knows why?
Reply
#2

pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CheckPoint[AirPort])
    {
        // code
    }
    return 1;
}
Reply
#3

I just realised that I posted it in the wrong section O.o Sorry! Anyway, how would I do it with switches and cases, instead of else ifs?
Reply
#4

You cannot because CheckPoint[AirPort] is not a constant number.
Reply
#5

Quote:
Originally Posted by BpX
Посмотреть сообщение
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    switch(checkpointid)
    {
        case AirPort:
        {
                  //code
        }
    }
    return 0;
}
Err... I didn't?
Reply
#6

Quote:
Originally Posted by BpX
Посмотреть сообщение
Err... I didn't?
You used AirPort that might be a constant number (depends on the script) but you are not even sure it's the correct ID of the dynamic checkpoint.

Take a look at your code:
pawn Код:
CheckPoint[AirPort] = CreateDynamicCP(1318.4940,1262.3025,10.8203, 1.5, 0, -1, -1, 40.0);
It assigns the ID of the dynamic checkpoint to CheckPoint[AirPort]. It can be any number, so using 20 or AirPort (a constant number) will simply fail.
Reply
#7

Quote:
Originally Posted by BpX
Посмотреть сообщение
Hello all

pawn Код:
enum CheckPointPlaces
{
    //other variables
    AirPort, //number 20
};

new CheckPoint[CheckPointPlaces];
Well, I mentioned that I had other variables before AirPort. I've tested it with formatting a string with AirPort. I'm very sure that the ID of AirPort is 20.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)