SA-MP Forums Archive
One Check Point to another (rep) - 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: One Check Point to another (rep) (/showthread.php?tid=322885)



One Check Point to another (rep) - SnG.Scot_MisCuDI - 03.03.2012

Im making a truck driving script and i want it to set another checkpoint as the player enters the first.
I made it so when he enters the checkpoint it removes the map icon and checkpoint, but i want it to make a new checkpoint and the next location, then the next and return it back to the first location. So here is how the checkpoints are made. Each time you do /truckjob it makes a new checkpoint at one of the three locations.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/truckjob", cmdtext, true, 10) == 0)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
        {
            if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); DisablePlayerCheckpoint(job); RemovePlayerMapIcon(playerid,1); return 1; }
            if(PetrolJob[playerid] != 1 && PetrolJob[playerid] != 2 && PetrolJob[playerid] != 3){ PetrolJob[playerid] = 1; }

            new name[MAX_PLAYER_NAME], string[48], str[48];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "* %s is now a Petrol Trucker.", name );
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(str, sizeof(str), "* Drive to the yellow marker on your map");
            SendClientMessage(playerid,COLOR_YELLOW, str);

            if(PetrolJob[playerid] == 1){
                PetrolJob[playerid] = 2;
                job = SetPlayerCheckpoint(playerid, 1944.7424,-1771.1267,13.1157, 10.0);
                SetPlayerMapIcon(playerid, 1, 1944.7424,-1771.1267,13.1157,56, 0, MAPICON_GLOBAL);
                return 1;
            }
            if(PetrolJob[playerid] == 2){
                PetrolJob[playerid] = 3;
                job = SetPlayerCheckpoint(playerid,1003.4263,-941.8485,41.8079,10);
                SetPlayerMapIcon( playerid, 1, 1003.4263,-941.8485,41.8079,56, 0,MAPICON_GLOBAL);
                return 1;
            }
            if(PetrolJob[playerid] == 3){
                PetrolJob[playerid] = 1;
                job = SetPlayerCheckpoint(playerid,-97.8173,-1166.7585,2.2650,10);
                SetPlayerMapIcon( playerid, 1, -97.8173,-1166.7585,2.2650,56, 0, MAPICON_GLOBAL);
                return 1;
            }
            return 1;
        }
        SendClientMessage(playerid, COLOR_RED,"You have to be in a courier truck to start the job"); DisablePlayerCheckpoint(job); RemovePlayerMapIcon(playerid,1);
    }
    return 0;
}
But after you go to the first location it should make a new checkpoint at location 2 .. then 3 then back to 1

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
     {
        if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); DisablePlayerCheckpoint(job); RemovePlayerMapIcon(playerid,1); return 1; }
        GivePlayerMoney(playerid,50000);
        SendClientMessage(playerid,COLOR_YELLOW,"* You have earned $50,000!");
        RemovePlayerMapIcon(playerid,1);
        DisablePlayerCheckpoint(job);
     }
     return 1;
}
Ok so. Say you do /truckjob It will make the first checkpoint. You drive into that first checkpoint, you get the cash, and the first checkpoint is gone. Now the Second checkpoint appears and you drive to that and get cash, second checkpoint is gone. Now a third checkpoint appears and you drive and get cash. Then the third checkpoint is gone and the FIRST checkpoint comes up again and it loops through all 3 over and over over.


Re: One Check Point to another (rep) - ArmyOps - 03.03.2012

Try add "DisablePlayerCheckpoint(playerid);" if player is reached to first checkpoint


Re: One Check Point to another (rep) - SnG.Scot_MisCuDI - 03.03.2012

That is how it is. Now it has to add another checkpoint


Re: One Check Point to another (rep) - ArmyOps - 03.03.2012

hmm readed once again ur explonation and i was thinking, do u understand urself what u want?
U have already done 3 markers, also if u enter first it gives u second one.
So u want more of them? So why dont u keep adding more?


Re: One Check Point to another (rep) - SnG.Scot_MisCuDI - 03.03.2012

No. It doesnt add another checkpoint when you enter the first. I want it to ADD the second checkpoint and remove the FIRST. Then when you go into the second checkpoint it adds the third checkpoint. Then it loops back to first and so on


Re: One Check Point to another (rep) - Nuke547 - 03.03.2012

What I think you should do is instead of making the person type it in each time, go into OnPLayerenterCheckpoint, and make it so it checks which checkpoint your on, then after that, you make it set your next check point and so on.


Re: One Check Point to another (rep) - SnG.Scot_MisCuDI - 03.03.2012

Thats what im asking help for..


Re: One Check Point to another (rep) - Nuke547 - 03.03.2012

EDIT: Fixed

This should work.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/truckjob", cmdtext, true, 10) == 0)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
        {
            if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
            if(PetrolJob[playerid] != 1 && PetrolJob[playerid] != 2 && PetrolJob[playerid] != 3){ PetrolJob[playerid] = 1; }

            new name[MAX_PLAYER_NAME], string[48], str[48];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "* %s is now a Petrol Trucker.", name );
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(str, sizeof(str), "* Drive to the yellow marker on your map");
            SendClientMessage(playerid,COLOR_YELLOW, str);
            SetPlayerCheckpoint(playerid, 1944.7424,-1771.1267,13.1157, 10.0);
            SetPlayerMapIcon(playerid, 1, 1944.7424,-1771.1267,13.1157,56, 0, MAPICON_GLOBAL);
           
            return 1;
        }
        SendClientMessage(playerid, COLOR_RED,"You have to be in a courier truck to start the job");
    }
    return 0;
}
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
     {
        if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); DisablePlayerCheckpoint(playerid); RemovePlayerMapIcon(playerid,1); return 1; }
        if(PetrolJob[playerid] == 1){
            PetrolJob[playerid] = 2;
            DisablePlayerCheckpoint(playerid);
            RemovePlayerMapIcon(playerid,1);
            SetPlayerCheckpoint(playerid, 1944.7424,-1771.1267,13.1157, 10.0);
            SetPlayerMapIcon(playerid, 1, 1944.7424,-1771.1267,13.1157,56, 0, MAPICON_GLOBAL);
            GivePlayerMoney(playerid,50000);
            SendClientMessage(playerid,COLOR_YELLOW,"* You have earned $50,000!");
            return 1;
        }
        if(PetrolJob[playerid] == 2){
            PetrolJob[playerid] = 3;
            DisablePlayerCheckpoint(playerid);
            RemovePlayerMapIcon(playerid,1);
            SetPlayerCheckpoint(playerid,1003.4263,-941.8485,41.8079,10);
            SetPlayerMapIcon( playerid, 1, 1003.4263,-941.8485,41.8079,56, 0,MAPICON_GLOBAL);
            GivePlayerMoney(playerid,50000);
            SendClientMessage(playerid,COLOR_YELLOW,"* You have earned $50,000!");
            return 1;
        }
        if(PetrolJob[playerid] == 3){
            PetrolJob[playerid] = 1;
            DisablePlayerCheckpoint(playerid);
            RemovePlayerMapIcon(playerid,1);
            SetPlayerCheckpoint(playerid,-97.8173,-1166.7585,2.2650,10);
            SetPlayerMapIcon( playerid, 1, -97.8173,-1166.7585,2.2650,56, 0, MAPICON_GLOBAL);
            GivePlayerMoney(playerid,50000);
            SendClientMessage(playerid,COLOR_YELLOW,"* You have earned $50,000!");
            return 1;
        }
     }
     return 1;
}



Re: One Check Point to another (rep) - SnG.Scot_MisCuDI - 03.03.2012

Thanks worked perfect. But when im on foot and i do /truckjob it says
You have to be in a courier truck to start the job
SERVER: Unknown Command.


Re: One Check Point to another (rep) - Nuke547 - 03.03.2012

Try this, and anytime.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/truckjob", cmdtext, true, 10) == 0)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
        {
            if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
            if(PetrolJob[playerid] != 1 && PetrolJob[playerid] != 2 && PetrolJob[playerid] != 3){ PetrolJob[playerid] = 1; }

            new name[MAX_PLAYER_NAME], string[48], str[48];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "* %s is now a Petrol Trucker.", name );
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(str, sizeof(str), "* Drive to the yellow marker on your map");
            SendClientMessage(playerid,COLOR_YELLOW, str);
            SetPlayerCheckpoint(playerid, 1944.7424,-1771.1267,13.1157, 10.0);
            SetPlayerMapIcon(playerid, 1, 1944.7424,-1771.1267,13.1157,56, 0, MAPICON_GLOBAL);
           
            return 1;
        }
    }
    return 0;
}