One Check Point to another (rep)
#1

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.
Reply
#2

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

That is how it is. Now it has to add another checkpoint
Reply
#4

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?
Reply
#5

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
Reply
#6

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.
Reply
#7

Thats what im asking help for..
Reply
#8

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;
}
Reply
#9

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.
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)