Error in checkpiont
#1

this is my code
PHP код:

public OnPlayerEnterCheckpoint(playerid)
{
    if(
IsPlayerInCheckpoint(playerid) == pizza_cp1)
    {
        new 
model GetVehicleModel(GetPlayerVehicleID(playerid));
        if(
model == 448)
        {
            
GivePlayerMoney(playerid25000);
            
SetPlayerScore(playeridGetPlayerScore(playerid) + 1);
            
SendClientMessage(playerid,COLOR_RED,"Recieved $25000!");
            
DisablePlayerCheckpoint(playerid);
        }
        return 
0;
    }
    if(
IsPlayerInCheckpoint(playerid) == pizza_cp2)
    {
        new 
model GetVehicleModel(GetPlayerVehicleID(playerid));
        if(
model == 448)
        {
            
GivePlayerMoney(playerid20000);
            
SetPlayerScore(playeridGetPlayerScore(playerid) + 1);
            
SendClientMessage(playerid,COLOR_RED,"Recieved $20000!");
            
DisablePlayerCheckpoint(playerid);
        }
        return 
0;
    }
    return 
1;

if I enter in second checkpoint the first code is returned that is I am given $25000 instead of $20000.
please help
Reply
#2

The function IsPlayerInCheckpoint does not return some sort of checkpoint ID. It merely checks if the player is ANY checkpoint at all.

You can create something like this to help you distinguish checkpoints:

pawn Код:
new PlayerCheckpoint[ MAX_PLAYERS ] = {-1, ...};

public OnPlayerDisconnect(playerid, reason)
{
    PlayerCheckpoint[ playerid ] = -1;
}

stock SetPlayerCheckpointEx(playerid, checkpointid, Float:x, Float:y, Float:z, Float:size)
{
     PlayerCheckpoint[ playerid ] = checkpointid;
     return SetPlayerCheckpoint(playerid, x, y, z, size);
}

public OnPlayerEntercheckpoint(playerid)
{
     if(PlayerCheckpoint[ playerid ] != -1)
     {
          return OnPlayerEnterCheckpointEx(playerid, PlayerCheckpoint[ playerid ]);
     }
     return 0;
}

public OnPlayerEnterCheckpointEx(playerid, checkpointid)
{
     if(checkpointid == pizza_cp1)
    {
        new model = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(model == 448)
        {
            GivePlayerMoney(playerid, 25000);
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
            SendClientMessage(playerid,COLOR_RED,"Recieved $25000!");
            DisablePlayerCheckpoint(playerid);

        }
        return 0;
    }
    if(checkpointid == pizza_cp2)
    {
        new model = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(model == 448)
        {
            GivePlayerMoney(playerid, 20000);
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
            SendClientMessage(playerid,COLOR_RED,"Recieved $20000!");
            DisablePlayerCheckpoint(playerid);
        }
        return 0;
    }
    return 1;
}
But if you use this, don't forget to use SetPlayerCheckpointEx instead of SetPlayerCheckpoint.
Reply
#3

Or use streamer plugin if you aren't already. Much easier.
Reply
#4

two warnings
PHP код:
warning 235: public function lacks forward declaration (symbol "OnPlayerEntercheckpoint"
warning 235: public function lacks forward declaration (symbol "OnPlayerEnterCheckpointEx"
Reply
#5

It's OnPlayerEnterCheckpoint, not OnPlayerEntercheckpoint.
Reply
#6

thanks konstantinos but what about the second one?
Reply
#7

Would need:
pawn Код:
forward OnPlayerEnterCheckpointEx(playerid, checkpointid);
but what's the point of trying to get the checkpoint ID in PAWN when streamer does that for you (plus it's written in C++)? None.
Reply
#8

thanks konstantinos once again +rep
Reply
#9

now another problem lol nothing is happening when player is entering in the checkpoint
Reply
#10

please help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)