Checkpoints messing up, displaying to wrong people, randomly.
#1

This issue has been killing me for ages.

I can't understand why. I'm killing the checkpoints at all the correct times.

pawn Код:
for(new c = 0; c < 7; c++)
    {
        DestroyDynamicCP(DrivingCheck[playerid][c]);
        DrivingCheck[playerid][c] = -1;
    }
    for(new x = 0; x < 8; x++)
    {
        DestroyDynamicRaceCP(SweepCheck[playerid][x]);
        SweepCheck[playerid][x] = -1;
    }
    for(new y = 0; y < 3; y++)
    {
        DestroyDynamicCP(TruckCheck[playerid][y]);
        TruckCheck[playerid][y] = -1;
    }
    for(new z = 0; z < 3; z++)
    {
        DestroyDynamicCP(TrashCheck[playerid][z]);
        TrashCheck[playerid][z] = -1;
    }
    for(new a = 0; a < 2; a++)
    {
        DestroyDynamicCP(PizzaCheck[playerid][a]);
        PizzaCheck[playerid][a] = -1;
    }
When the player disconnects ^

pawn Код:
else if(checkpointid == PizzaCheck[playerid][1])
    {
        format(string, sizeof(string), "Pizza Delivery Job: "COL_WHITE"Well done! You have earned a total of "COL_GREEN"$%s on this job.", AddCommas(PizzaTips[playerid]));
        SendClientMessage(playerid, COLOUR_REALRED, string);
        DestroyDynamicCP(PizzaCheck[playerid][1]);
        RemovePlayerMapIcon(playerid, 0);
        PlayerMoney[playerid] += PizzaTips[playerid];
        GivePlayerMoney(playerid, PizzaTips[playerid]);
        SetVehicleToRespawn(PizzaBikeID[playerid]);
        PizzaCooldown[playerid] = 5;
        PizzaJob[playerid] = 0;
        PizzaBikeID[playerid] = -1;
        PizzaAmount[playerid] = 0;
        PizzaTips[playerid] = 0;
        RemovePlayerFromVehicle(playerid);
        new skin = GetPlayerSkinEx(playerid);
        SetPlayerSkin(playerid, skin);
        MySQL_SetInteger(PlayerSQLID[playerid], "PizzaCooldown" , 5, "accounts");
        for(new x = 0; x < 2; x++)
        {
            DestroyDynamicCP(PizzaCheck[playerid][x]);
            PizzaCheck[playerid][x] = -1;
        }
    }
    else if(checkpointid == PizzaCheck[playerid][0])
    {
        new tip, maxhouse;
        if(PizzaJob[playerid] == 1)
        {
            if(!IsPlayerAttachedObjectSlotUsed(playerid, 0))return SendClientMessage(playerid, COLOUR_GREY, "Use /getpizza at your delivery bike before entering the checkpoint.");
            RemovePlayerAttachedObject(playerid, 0);
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
            if(PizzaAmount[playerid] < 4)
            {
                PizzaAmount[playerid] ++;
            }
            new chance = RandomEx(1, 10000);
            if(chance < 10000)
            {
                tip = RandomEx(1, 45);
                format(string, sizeof(string), "PIZZA DELIVERED: "COL_WHITE"You received a tip of "COL_GREEN"$%d "COL_WHITE"for delivering this pizza.", tip);
                SendClientMessage(playerid, COLOUR_REALRED, string);
            }
            if(chance == 10000)
            {
                format(string, sizeof(string), "PIZZA DELIVERED: "COL_WHITE"You received an "COL_ORANGE"INCREDIBLE "COL_WHITE"tip of "COL_GREEN"$10,000.");
                tip = 10000;
                SendClientMessage(playerid, COLOUR_REALRED, string);
            }
            PizzaTips[playerid] += tip;
            ServerStartMoney += tip;
            if(PizzaAmount[playerid] == 4)
            {
                RemovePlayerMapIcon(playerid, 0);
                format(string, sizeof(string), "Pizza Delivery Job: "COL_WHITE"Please return the bike to the Pizza Stack to collect your payment.");
                SendClientMessage(playerid, COLOUR_REALRED, string);
                PizzaCheck[playerid][1] = CreateDynamicCP(VehSpawnX[PizzaBikeID[playerid]], VehSpawnY[PizzaBikeID[playerid]], VehSpawnZ[PizzaBikeID[playerid]], 2, 0, 0, playerid, 100.0);
                DestroyDynamicCP(PizzaCheck[playerid][0]);
                SetPlayerMapIcon(playerid, 0, VehSpawnX[PizzaBikeID[playerid]], VehSpawnY[PizzaBikeID[playerid]], VehSpawnZ[PizzaBikeID[playerid]], 0, COLOUR_RED, MAPICON_LOCAL);
            }
            else
            {
                for(new x = 1; x < MAX_HOUSES; x++)
                {
                    if(HouseEntX[x] != 0)
                    {
                        maxhouse++;
                    }
                }
                new house = RandomEx(1, maxhouse);
                RemovePlayerMapIcon(playerid, 0);
                if(HouseEntVW[house] > 0)
                {
                    for(new a = 1; a < MAX_APARTS; a++)
                    {
                        if(HouseVW[house] == ApartVW[a])
                        {
                            format(string, sizeof(string), "Pizza Order Address: "COL_ORANGE"%s, "COL_WHITE"please proceed to the checkpoint on your map to deliver the pizza.", ApartName[a]);
                            SendClientMessage(playerid, COLOUR_WHITE, string);
                            PizzaCheck[playerid][0] = CreateDynamicCP(ApartEntX[a], ApartEntY[a], ApartEntZ[a], 2, 0, 0, playerid, 100.0);
                            SetPlayerMapIcon(playerid, 0, ApartEntX[a], ApartEntY[a], ApartEntZ[a], 0, COLOUR_RED, MAPICON_LOCAL);
                        }
                    }
                }
                else
                {
                    format(string, sizeof(string), "Pizza Order Address: "COL_ORANGE"%s, "COL_WHITE"please proceed to the checkpoint on your map to deliver the pizza.", HouseName[house]);
                    SendClientMessage(playerid, COLOUR_WHITE, string);
                    PizzaCheck[playerid][0] = CreateDynamicCP(HouseEntX[house], HouseEntY[house], HouseEntZ[house], 2, 0, 0, playerid, 100.0);
                    DestroyDynamicCP(PizzaCheck[playerid][0]);
                    SetPlayerMapIcon(playerid, 0, HouseEntX[house], HouseEntY[house], HouseEntZ[house], 0, COLOUR_RED, MAPICON_LOCAL);

                }
            }
        }
    }
Example job where I'm using the checkpoints.

These aren't the only ones that display randomly, all checkpoints seem to do it.
Reply
#2

Let me clarify it: streamer plugin creates those checkpoints globally. Whenever the player is streamed to the distance specified will see the checkpoint no matter if you saw it on a place for a single player.

What you can actually do is create the checkpoints once (when the server starts) and remove the dimension in the array (per-player) to store them correctly. When a player connects, hide all those checkpoints using Streamer_RemoveArrayData function. When a job is starting and want to show a checkpoint use Streamer_AppendArrayData function (if it's not the first checkpoint, don't forget to hide the previous).
Reply
#3

I've never heard of this to be honest, is there any links with more info?
Reply
#4

https://github.com/samp-incognito/sa...ppendArrayData
Reply
#5

Why can't I use ToggleDynamicCP? As opposed to that.

I'm extremely confused and find this hard to understand.
Reply
#6

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Why can't I use ToggleDynamicCP? As opposed to that.

I'm extremely confused and find this hard to understand.
Honestly, I didn't even remember this function but I guess it works too. I used to work with the 2 functions I mentioned in the past so I said them out of habit.
Reply
#7

It's very difficult and confusing, I haven't had any trouble as such like this. I'm not even sure how to go around this.

Do I need to like create all the checkpoints for each player or? I've really no idea.
Reply
#8

TogglePlayerDynamicCP(playerid, CP_ID, toggle);
Reply
#9

Where should I create the Checkpoints and also should they be local or global in this case?
Reply
#10

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Where should I create the Checkpoints and also should they be local or global in this case?
Example:
Код:
for(new c = 0; c < 7; c++)
{
        TogglePlayerDynamicCP(playerid, CheckPoint_1, 0); // hide CP 1
        TogglePlayerDynamicCP(playerid, CheckPoint_2, 1); // show CP 2
        DrivingCheck[playerid][c] = -1;
}
Reply
#11

Dynamic checkpoints are used if you want to display many of them at a time. If what you are trying to do is like missions that goes from one checkpoint to another, you may as well use SetPlayerCheckpoint but that would be more confusing as there would too much variables checking. Now, as you have it with dynamic checkpoints: create all checkpoints once (when the server starts) like:
pawn Код:
// global:
new PizzaCheck[2];

// in OnGameModeInit:
PizzaCheck[0] = CreateDynamicCP(..);
PizzaCheck[1] = CreateDynamicCP(..);

// When a player connects:
for(new a = 0; a < sizeof PizzaCheck; a++)
{
    TogglePlayerDynamicCP(playerid, PizzaCheck[a], 0);
}
Setting the third parameter 'toggle' to 1 will show the checkpoint to the player.
Reply
#12

I hate to ask, could you show me using the above code as an example,

this part specifically:
pawn Код:
PizzaCheck[playerid][0] = CreateDynamicCP(HouseEntX[house], HouseEntY[house], HouseEntZ[house], 2, 0, 0, playerid, 100.0);
                    DestroyDynamicCP(PizzaCheck[playerid][0]);
When I create it and then toggle it, will it actually change the co-ordinates, or rather how do I change a checkpoint completely and when in this case would I destroy it? Do I destroy when they disconnect or?
Reply
#13

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Dynamic checkpoints are used if you want to display many of them at a time. If what you are trying to do is like missions that goes from one checkpoint to another, you may as well use SetPlayerCheckpoint but that would be more confusing as there would too much variables checking. Now, as you have it with dynamic checkpoints: create all checkpoints once (when the server starts) like:
pawn Код:
// global:
new PizzaCheck[2];

// in OnGameModeInit:
PizzaCheck[0] = CreateDynamicCP(..);
PizzaCheck[1] = CreateDynamicCP(..);

// When a player connects:
for(new a = 0; a < sizeof PizzaCheck; a++)
{
    TogglePlayerDynamicCP(playerid, PizzaCheck[a], 0);
}
Setting the third parameter 'toggle' to 1 will show the checkpoint to the player.
I see!

However, the checkpoints always change the locations as I make it on a random house, how would I update this?

Thanks again.
Reply
#14

If you want to update the position of a checkpoint, you should use Streamer_SetFloatData function. Here's a function to make it easier:
PHP код:
UpdateDynamicCPPos(cpidFloatcpxFloatcpyFloatcpz)
{
    return 
Streamer_SetFloatData(STREAMER_TYPE_CPcpidE_STREAMER_Xcpx) && Streamer_SetFloatData(STREAMER_TYPE_CPcpidE_STREAMER_Ycpy) && Streamer_SetFloatData(STREAMER_TYPE_CPcpidE_STREAMER_Zcpz);

Reply
#15

You are honestly the nicest guys ever, thank you so very much. I will use this, thank you endlessly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)