Checkpoints mixing.
#1

Hey guys. Well, i made 2 jobs. Street sweeping, and Trucking, but trucking is sending me to sweeping checkpoints..
Here is the code, thanks.

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 Float:TCP[][3] =
{
    {-1565.1646,-2811.4785,46.6490},
    {-2130.9924,-2532.9590,30.4688},
    {-199.8498,-2335.5718,28.4854},
    {-56.6326,-1136.9395,1.0781}
};

new sCP[MAX_PLAYERS];
new tCP[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.");
}
CMD:starttruck(playerid, params[])
{
    if(PlayerInfo[playerid][Job] == 2)
    {
        new vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 514)
        {
            if(IsTrailerAttachedToVehicle(vehicleid))
            {
                SetPlayerCheckpoint(playerid, -2051.4927,-2488.2144,30.1957, 5.0);
                tCP[playerid] = 0;
                SendClientMessage(playerid, COLOR_LIGHTRED, "You started your job. Follow the checkpoint.");
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_LIGHTRED, "No trailler is attached.");
        }
        else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not inside any Trucking vehicle.");
    }
    else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a trucker.");
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(sCP[playerid] != -1)
    {
        GivePlayerMoney(playerid, 40);
        if(sCP[playerid] < (sizeof(BCP) - 1))
        {
            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;
        }
    }
    if(tCP[playerid] != -1)
    {
        GivePlayerMoney(playerid, 250);
        if(tCP[playerid] < (sizeof(TCP) - 1))
        {
            tCP[playerid]++;
            SetPlayerCheckpoint(playerid, TCP[tCP[playerid]][0], TCP[tCP[playerid]][1], TCP[tCP[playerid]][2], 5.0);
        }
        else
        {
            SendClientMessage(playerid, 0x999999AA, "Route finished");
            DisablePlayerCheckpoint(playerid);
            tCP[playerid] = -1;
        }
    }
}
Reply
#2

Anyone? I know we shouldn't bump, but all know that second page threads are forgetten and i really need this to continue with other jobs.
Reply
#3

Dont doublepost.
Reply
#4

Quote:
Originally Posted by faff
Посмотреть сообщение
Dont doublepost.
Serious? I know it, and said sorry... But i really need this fixed, no idea why it is happening. xD
Reply
#5

Make sure only one variable is 0 or higher, and ALL others are set to -1.
If thats not the case it will pick the upper variable in the script, which is probably happening.


And I see you used my trick with the if(sCP[playerid] != -1) I once told you:P

EXAMPLE:

this is part of my OnPlayerConnect:

oCP[playerid] = -1;
pCP[playerid] = -1;
lCP[playerid] = -1;
CarTest[playerid] = -1;
qCP[playerid] = -1;
wCP[playerid] = -1;
kCP[playerid] = -1;
rCP[playerid] = -1;
Reply
#6

What you mean? What variables i have to change to -1? I am so tired of trying to figure this out that my head is blowing..
Reply
#7

Well you check if a variable is set to 0.

But what if both jobs are set to 0?

It will try to set two checkpoints at the same time, but since this is impossible it will only set one, and sometimes the wrong one.
Reply
#8

Changed that.. Will it be solved?

pawn Код:
CMD:starttruck(playerid, params[])
{
    if(PlayerInfo[playerid][Job] == 2)
    {
        new vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 514)
        {
            if(IsTrailerAttachedToVehicle(vehicleid))
            {
                SetPlayerCheckpoint(playerid, -2051.4927,-2488.2144,30.1957, 5.0);
                tCP[playerid] = -1;
                SendClientMessage(playerid, COLOR_LIGHTRED, "You started your job. Follow the checkpoint.");
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_LIGHTRED, "No trailler is attached.");
        }
        else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not inside any Trucking vehicle.");
    }
    else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a trucker.");
}
Reply
#9

I guess it is. let me show you one of my jobs:

like /startsweep

pawn Код:
CMD:startsweep(playerid, params[])
{
    if(vjob[GetPlayerVehicleID(playerid)] == 5)
    {
        if(PlayerInfo[playerid][pJob] == pJob_5)
        {
            if(isjob[playerid] == 1) return error(playerid,"You are already on a job!");
            isjob[playerid] = 1;
            SetPlayerCheckpoint(playerid, 2089.6030,-2038.8513,13.5469, 4.0);
            SendClientMessage(playerid, 0xFFFF00, "You can start sweeping..");
            qCP[playerid] = -1;
            pCP[playerid] = -1;
            lCP[playerid] = 0;
            oCP[playerid] = -1;
            CarTest[playerid] = -1;
            ontaxi[playerid] = -1;
            wCP[playerid] = -1;
            kCP[playerid] = -1;
            return 1;
        }
        else return SendClientMessage(playerid, 0xFFFF00, "You are not street sweeper.");
    }
    else return SendClientMessage(playerid, 0xFFFF00, "You need to be in a sweeper car to Start.");
}
Notice how I set all other jobs to -1?
Reply
#10

Hmm, so is this bettr like that:
pawn Код:
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] = -1;
            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.");
}
CMD:starttruck(playerid, params[])
{
    if(PlayerInfo[playerid][Job] == 2)
    {
        new vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 514)
        {
            if(IsTrailerAttachedToVehicle(vehicleid))
            {
                SetPlayerCheckpoint(playerid, -2051.4927,-2488.2144,30.1957, 5.0);
                tCP[playerid] = -1;
                SendClientMessage(playerid, COLOR_LIGHTRED, "You started your job. Follow the checkpoint.");
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_LIGHTRED, "No trailler is attached.");
        }
        else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not inside any Trucking vehicle.");
    }
    else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a trucker.");
}
Or like that?

pawn Код:
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;
                tCP[playerid] = -1;
            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.");
}
CMD:starttruck(playerid, params[])
{
    if(PlayerInfo[playerid][Job] == 2)
    {
        new vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 514)
        {
            if(IsTrailerAttachedToVehicle(vehicleid))
            {
                SetPlayerCheckpoint(playerid, -2051.4927,-2488.2144,30.1957, 5.0);
                tCP[playerid] = 0;
                        sCP[playerid] = -1;
                SendClientMessage(playerid, COLOR_LIGHTRED, "You started your job. Follow the checkpoint.");
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_LIGHTRED, "No trailler is attached.");
        }
        else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not inside any Trucking vehicle.");
    }
    else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a trucker.");
}
Like, On the first job, it's street sweeper, and sweeper variable is sCP[playerid].
On OnPlayerEnterCheckpoint, it checks this:

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(sCP[playerid] != -1)
    {
        GivePlayerMoney(playerid, 40);
        if(sCP[playerid] < (sizeof(BCP) - 1))
        {
            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;
        }
    }
    if(tCP[playerid] != -1)
    {
        GivePlayerMoney(playerid, 250);
        if(tCP[playerid] < (sizeof(TCP) - 1))
        {
            tCP[playerid]++;
            SetPlayerCheckpoint(playerid, TCP[tCP[playerid]][0], TCP[tCP[playerid]][1], TCP[tCP[playerid]][2], 5.0);
        }
        else
        {
            SendClientMessage(playerid, 0x999999AA, "Route finished");
            DisablePlayerCheckpoint(playerid);
            tCP[playerid] = -1;
        }
    }
}
I am so damn confused.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)