Weird problem with Streamer include. (Dynamic CPs)
#6

I think I found the culprit.

Quote:

DestroyDynamicCP(Farmer[playerid][CP1]);
Farmer[playerid][CP2] = CreateDynamicCP(699.7277, 1286.4685, 11.2983, 5.0, playerid);

As you could see above, you were destroying the previous CP before creating another CP.

So just assume, the ID you've got from the first CreatDynamicCP was 1, and you'd assign that ID 1 to Farmer[playerid][CP1].

When the player enters the first CP, your code would destroy the previous CP by grabbing ID from Farmer[playerid][CP1] that is 1.

After that you tried to create another CP which is then being assigned to Farmer[playerid][CP2], here comes the culprit, as we know the ID 1 that we destroyed was still in Farmer[playerid][CP1], and the new CreateDynamicCP will also return 1 as the ID 1 slot is free.

That causes the CP to be created always in the same first place as in CP1.

You just had to reset the Farmer[playerid][CP1 to 10] to -1 in each OnPlayerEnterDynamicCP.

A modified code snippet below


Quote:

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{

if(checkpointid == Farmer[playerid][CP1])
{
SendClientMessage(playerid, -1, "1st");
new Cash = RandomEx(10, 50);
Farmer[playerid][M1] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP1]);
Farmer[playerid][CP1] = -1; //ADDED CODE
Farmer[playerid][CP2] = CreateDynamicCP(699.7277, 1286.4685, 11.2983, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP2])
{
SendClientMessage(playerid, -1, "2nd");
new Cash = RandomEx(10, 50);
Farmer[playerid][M2] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP2]);
Farmer[playerid][CP2] = -1; //ADDED CODE
Farmer[playerid][CP3] = CreateDynamicCP(763.6042, 1271.3716, 19.6916, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP3])
{
SendClientMessage(playerid, -1, "3rd");
new Cash = RandomEx(10, 50);
Farmer[playerid][M3] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP3]);
Farmer[playerid][CP3] = -1; //ADDED CODE
Farmer[playerid][CP4] = CreateDynamicCP(741.0443, 1166.6055, 19.4455, 5.0, playerid);
}
if(checkpointid == Farmer[playerid][CP4])
{
SendClientMessage(playerid, -1, "4th");
new Cash = RandomEx(10, 50);
Farmer[playerid][M4] = GivePlayerMoney(playerid, Cash);
DestroyDynamicCP(Farmer[playerid][CP4]);
Farmer[playerid][CP4] = -1; //ADDED CODE
Farmer[playerid][CP5] = CreateDynamicCP(575.7811, 1157.2560, 12.2097, 5.0, playerid);
}

Just do the same for the rest. Hope it helped you out
Reply


Messages In This Thread
Weird problem with Streamer include. (Dynamic CPs) - by DeeadPool - 04.05.2017, 21:39
Re: Weird problem with Streamer include. (Dynamic CPs) - by Sebz - 05.05.2017, 04:33
Re: Weird problem with Streamer include. (Dynamic CPs) - by ShihabSoft - 05.05.2017, 06:33
Re: Weird problem with Streamer include. (Dynamic CPs) - by DeeadPool - 05.05.2017, 08:47
Re: Weird problem with Streamer include. (Dynamic CPs) - by Logic_ - 05.05.2017, 09:04
Re: Weird problem with Streamer include. (Dynamic CPs) - by ShihabSoft - 05.05.2017, 10:01

Forum Jump:


Users browsing this thread: 2 Guest(s)