Error in checkpiont -
Rissam - 04.06.2015
this is my code
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
if(IsPlayerInCheckpoint(playerid) == 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(IsPlayerInCheckpoint(playerid) == 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;
}
if I enter in second checkpoint the first code is returned that is I am given $25000 instead of $20000.
please help
Re: Error in checkpiont -
dusk - 04.06.2015
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.
Re: Error in checkpiont -
Vince - 04.06.2015
Or use streamer plugin if you aren't already. Much easier.
Re: Error in checkpiont -
Rissam - 13.06.2015
two warnings
PHP код:
warning 235: public function lacks forward declaration (symbol "OnPlayerEntercheckpoint")
warning 235: public function lacks forward declaration (symbol "OnPlayerEnterCheckpointEx")
Re: Error in checkpiont -
Konstantinos - 13.06.2015
It's OnPlayerEnter
Checkpoint, not OnPlayerEnter
checkpoint.
Re: Error in checkpiont -
Rissam - 13.06.2015
thanks konstantinos but what about the second one?
Re: Error in checkpiont -
Konstantinos - 13.06.2015
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.
Re: Error in checkpiont -
Rissam - 13.06.2015
thanks konstantinos once again +rep
Re: Error in checkpiont -
Rissam - 13.06.2015
now another problem lol nothing is happening when player is entering in the checkpoint
Re: Error in checkpiont -
Rissam - 14.06.2015
please help