16.04.2015, 15:53
I would like to explain everything in detail but I don't have enough time to do so.
An example with 10 checkpoints.
An example with 10 checkpoints.
PHP код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <zcmd.inc>
new ProgressInRuta[MAX_PLAYERS];
new CP_ID[MAX_PLAYERS];
new Ruta[MAX_PLAYERS];
static const Float:CPS[10][3] =
{ //x //y /z
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00},
{00.00, 00.00, 00.00}
};
CMD:ruta(playerid,params[])
{/*
new Vozilo = GetPlayerVehicleID(playerid);
if(PlayerPosao[playerid][pID] != 1)
return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Niste zaposleni kao vozac autobusa");
if(Vozilo != Autobus[0] || Vozilo != Autobus[1] || Vozilo != Autobus[2] || Vozilo != Autobus[3] || Vozilo != Autobus[4])
return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Ne nalazite se u autobusu");
*/
if(Ruta[playerid] == 1)
return SendClientMessage(playerid,-1,"You are already in route");
Ruta[playerid] = 1;
SendClientMessage(playerid, -1, "You've come to ruta!");
CP_ID[playerid] = SetPlayerRaceCheckpoint(playerid, 0, CPS[0][0], CPS[0][1], CPS[0][2], CPS[1][0], CPS[1][1], CPS[1][2], 12.5);
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(Ruta[playerid])
{
ProgressInRuta[playerid] = ProgressInRuta[playerid]+1;
new
slot = ProgressInRuta[playerid];
if(ProgressInRuta[playerid] != sizeof(CPS))
{
switch(ProgressInRuta[playerid])
{
case 1,2,3,4,5,6,7,8:
CP_ID[playerid] = SetPlayerRaceCheckpoint(playerid, 0, CPS[slot][0], CPS[slot][1], CPS[slot][2], CPS[slot+1][0], CPS[slot+1][1], CPS[slot+1][2], 12.5);
case 9:
CP_ID[playerid] = SetPlayerRaceCheckpoint(playerid, 1, CPS[slot][0], CPS[slot][1], CPS[slot][2], 0.0, 0.0, 0.0, 12.5);
}
}
else if(ProgressInRuta[playerid] == sizeof(CPS))
{
DisablePlayerRaceCheckpoint(playerid);
SendClientMessage(playerid, -1, "You finished the ruta!!.");
Ruta[playerid] = false;
ProgressInRuta[playerid] = 0;
}
}
return true;
}