SA-MP Forums Archive
Help with Checkpoint - 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: Help with Checkpoint (/showthread.php?tid=571133)



Help with Checkpoint - NoDi522 - 16.04.2015

Hello. I'am making my first job system and i need your help.

I made command "ruta" which turns bus driver,job,on. Now i need an example with checkpoints. When i enter first the second shows,and so on... I just need an example with few checkpoint because i really don't have idea how to do that. I know it is very easy but...

Here is a command "ruta":

PHP код:
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] != 0) return SendClientMessage(playerid,-1,""COLOR_CRVENA"Greska:{FFFFFF} Vec ste zapoceli autobus rutu");
    {
        
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Zapoceli ste autobus rutu. Molimo pratite oznake na mapi.");
        
SendClientMessage(playerid,-1,""COLOR_WG"WG:{FFFFFF} Ukoliko zelite prestati odradivati rutu -"COLOR_SIVA" /zaustavirutu");
        
Ruta[playerid] = 1;
    }
    return 
1;




Respuesta: Help with Checkpoint - JuanStone - 16.04.2015

I would like to explain everything in detail but I don't have enough time to do so.

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.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.00},
    {
00.0000.0000.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(playerid0CPS[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(playerid0CPS[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(playerid1CPS[slot][0], CPS[slot][1], CPS[slot][2], 0.00.00.012.5);
            }
        }
        else if(
ProgressInRuta[playerid] == sizeof(CPS))
        {
            
DisablePlayerRaceCheckpoint(playerid);
            
SendClientMessage(playerid, -1"You finished the ruta!!.");
            
Ruta[playerid] = false;
            
ProgressInRuta[playerid] = 0;
        }
    }
    return 
true;