Problem with checkpoints. Last one, only be gone after passing 2 times. - 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: Problem with checkpoints. Last one, only be gone after passing 2 times. (
/showthread.php?tid=345518)
Problem with checkpoints. Last one, only be gone after passing 2 times. -
ricardo178 - 25.05.2012
Hello. I've been working in a sweeper job, but the last checkpoint, only be gone if i pass in it 2 times.. :/
How could i fix this?
pawn Код:
new Float:BCP[][3] =
{
{-2231.5911,-2456.8728,30.4688},
{-2130.9924,-2532.9590,30.4688},
{-1982.1638,-2538.2822,36.8082},
{-2259.3906,-2561.3916,31.9347}
};
new sCP[MAX_PLAYERS];
CMD:startsweep(playerid, params[])
{
if(PlayerInfo[playerid][Job] == 1)
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 574)
{
SetPlayerCheckpoint(playerid, -2106.6787,-2361.6228,30.4688, 5.0);
sCP[playerid] = 0;
SendClientMessage(playerid, COLOR_LIGHTRED, "You started your job. Follow the checkpoints.");
return 1;
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not inside any sweeping vehicle.");
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a sweeper.");
}
public OnPlayerEnterCheckpoint(playerid)
{
if(sCP[playerid] != -1)
{
GivePlayerMoney(playerid, 40);
if(sCP[playerid] < sizeof(BCP))
{
sCP[playerid]++;
SetPlayerCheckpoint(playerid, BCP[sCP[playerid]][0], BCP[sCP[playerid]][1], BCP[sCP[playerid]][2], 5.0);
}
else
{
SendClientMessage(playerid, 0x999999AA, "Route finished");
DisablePlayerCheckpoint(playerid);
sCP[playerid] = -1;
}
}
}
Thanks.
Re: Problem with checkpoints. Last one, only be gone after passing 2 times. -
Mandrakke - 25.05.2012
Код:
if(sCP[playerid] < sizeof(BCP))
change to;
Код:
if(sCP[playerid] < (sizeof(BCP) - 1))
Re: Problem with checkpoints. Last one, only be gone after passing 2 times. -
MP2 - 25.05.2012
Debug it using print(). This will allow you to see what is happening. (though SendClientMessage would be better really as it's in-game).
Re: Problem with checkpoints. Last one, only be gone after passing 2 times. -
ricardo178 - 25.05.2012
Will test, than i say if it worked. Thanks anyways.