public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
new tickCountResult = GetTickCount(), reducedValue;
for(new i; i < MAX_CHECKPOINT; i++)
{
if(checkpointid == CPIndex[i][0])
{
reducedValue = tickCountResult - pInfo[playerid][CPTime];
if (reducedValue > 10000)
{
pInfo[playerid][CPTime] = GetTickCount();
SetPlayerPos(playerid, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2]);
SetPlayerInterior(playerid, CPData[i][Interior]);
SetPlayerVirtualWorld(playerid, CPData[i][World]);
Loading(playerid);
pInfo[playerid][LastEntered] = i;
}
return 1;
}
if(checkpointid == CPIndex[i][1])
{
reducedValue = tickCountResult - pInfo[playerid][CPTime];
if (reducedValue > 10000)
{
new sID = pInfo[playerid][LastEntered];
pInfo[playerid][CPTime] = GetTickCount();
SetPlayerPos(playerid, CPData[sID][EnterLoc][0], CPData[sID][EnterLoc][1], CPData[sID][EnterLoc][2]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
Loading(playerid);
}
return 1;
}
}
if(checkpointid == JobCP[0])
{
reducedValue = tickCountResult - pInfo[playerid][CPTime];
if (reducedValue > 10000)
{
pInfo[playerid][CPTime] = GetTickCount();
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, 27);
}
return 1;
}
if(checkpointid == JobCP[1])
{
reducedValue = tickCountResult - pInfo[playerid][CPTime];
if (reducedValue > 10000)
{
pInfo[playerid][CPTime] = GetTickCount();
SetPlayerPos(playerid, -1880.8790, 822.7505, 35.1774);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
}
return 1;
}
return 1;
}
public DynamicCPs()
{
new i = 0;
while(i < MAX_CHECKPOINT)
{
CPIndex[i][0] = CreateDynamicCP(CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2], 1.5, -1, -1, -1, 100.0);
CPIndex[i][1] = CreateDynamicCP(CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2], 1.5, CPData[i][World], CPData[i][Interior], -1, 100.0);
CPLabel[i][0][0] = Create3DTextLabel("WELCOME TO", 0x00FF00FF, CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2] + 0.2, 25.0, 0, 1);
CPLabel[i][0][1] = Create3DTextLabel(CPData[i][SName], 0x0000FFFF, CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2] + 0.05, 25.0, 0, 1);
CPLabel[i][1][0] = Create3DTextLabel("YOU WERE AT", 0x00FF00FF, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2] + 0.2, 7.5, CPData[i][World], 1);
CPLabel[i][1][1] = Create3DTextLabel(CPData[i][SName], 0x0000FFFF, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2] + 0.05, 7.5, CPData[i][World], 1);
i++;
}
}
enum CPsEnum
{
SID,
Float:EnterLoc[3],
Float:ExitLoc[3],
World,
Interior,
SName[25]
}
printf("[DEBUG] Player %i entered checkpoint %i", playerid ,checkpointid);
new CPIndex[MAX_CHECKPOINT][3], Text3D:CPLabel[MAX_CHECKPOINT][3][2];
forward DynamicCPs();
public DynamicCPs()
{
new i = 0;
while(i < MAX_CHECKPOINT)
{
CPIndex[i][0] = CreateDynamicCP(CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2], 1.5, -1, -1, -1, 100.0);
CPIndex[i][1] = CreateDynamicCP(CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2], 1.5, CPData[i][World], CPData[i][Interior], -1, 100.0);
CPLabel[i][0][0] = Create3DTextLabel("WELCOME TO", 0x00FF00FF, CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2] + 0.2, 25.0, 0, 1);
CPLabel[i][0][1] = Create3DTextLabel(CPData[i][SName], 0x0000FFFF, CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2] + 0.05, 25.0, 0, 1);
CPLabel[i][1][0] = Create3DTextLabel("YOU WERE AT", 0x00FF00FF, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2] + 0.2, 7.5, CPData[i][World], 1);
CPLabel[i][1][1] = Create3DTextLabel(CPData[i][SName], 0x0000FFFF, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2] + 0.05, 7.5, CPData[i][World], 1);
i++;
}
}
/* Variables I created by myself. */
new CPTime[MAX_PLAYERS];
new LastE[MAX_PLAYERS];
new CPIndex[25][2];
enum CPsEnum {
ID,
Float:EnterLoc[3],
Float:ExitLoc[3],
World,
Interior,
Name[31]
}
/* Your array. */
new CPData[25][CPsEnum] =
{
/*
- storeID - this is the store ID, continue the pattern.
- checkpointLoc - x, y, z location for entering the interior (this is also the place the player ends up being after leaving the interior)
- exitpointLoc - x, y, z location for leaving the interior (this is also the place the player ends up being after entering the interior)
- virtualWorld - this tells the server which world to throw you in, this is so you only get player markers of people who are in the same store as you.
- interiorWorld - this tells the server which interior to put you in.
- storeName - this defines the name of the store for the text labels, and robbery reports "Jake has robbed Cluckin' Bell" etc.
*/
{1, {-1492.7708, 920.1295, 7.1875}, {10081.0352, -1761.4500, 1151.4153}, 2, 3, "San Fierro Bank"},
{2, {-1616.5900, 1122.9259, 7.1875}, {-31.0479, -91.4085, 1003.5469}, 3, 18, "24/7"},
{3, {-1662.2526, 1299.8816, 7.0391}, {285.6062, -40.8603, 1000.9325}, 4, 1, "Ammunation"},
{4, {-1721.5771, 1359.7626, 7.1853}, {372.3125, -132.8916, 1001.4922}, 5, 5, "Well Stacked Pizza"},
{5, {-1694.7739, 951.6697, 24.8906}, {226.9353, -8.2048, 1002.2109}, 6, 5, "Victim's Clothing"},
{6, {-1810.3533, 902.2993, 24.8906}, {203.8098, -49.9331, 1001.8047}, 7, 1, "Sub Urban's Clothing"},
{7, {-1808.2634, 945.5615, 24.8906}, {372.3125, -132.8916, 1001.4922}, 8, 5, "Well Stacked Pizza"},
{8, {-1912.2750, 828.2113, 35.2214}, {363.4346, -74.6586, 1001.5078}, 9, 10, "Burger Shot"},
{9, {-1882.2578, 866.5031, 35.1719}, {161.4177, -96.4533, 1001.8047}, 10, 18, "Zip's Clothing"},
{10, {-1816.4827, 618.0260, 35.1719}, {365.0151, -11.0958, 1001.8516}, 11, 9, "Cluckin' Bell"},
{11, {-2269.5771, -155.9628, 35.3203}, {774.2042, -49.7428, 1000.5859}, 12, 6, "Cobra's Martial Arts"},
{12, {-2490.3750, -29.1549, 25.6172}, {203.8098, -49.9331, 1001.8047}, 13, 1, "Sub Urban's Clothing"},
{13, {-2336.2737, -166.7664, 35.5547}, {363.4346, -74.6586, 1001.5078}, 14, 10, "Burger Shot"},
{14, {-2491.3745, -38.9601, 25.7656}, {-204.3975, -8.6990, 1002.2734}, 15, 17, "Tattoo Shop"},
{15, {-2625.8135, 208.8625, 4.6174}, {315.7365, -143.0907, 999.6016}, 16, 7, "Ammunation"},
{16, {-2571.1086, 246.6828, 10.3268}, {411.6910, -22.8669, 1001.8047}, 17, 2, "Barber Shop"},
{17, {-2672.3086, 258.7005, 4.6328}, {365.0151, -11.0958, 1001.8516}, 18, 9, "Cluckin' Bell"},
{18, {-2767.7983, 788.7329, 52.7813}, {377.1708, -192.7061, 1000.6401}, 19, 17, "Tuff Nuts Donuts"},
{19, {-2523.8027, 1216.1479, 37.4283}, {377.1708, -192.7061, 1000.6401}, 20, 17, "Restaurant"},
{20, {-2624.4270, 1411.9166, 7.0938}, {-2636.7800, 1403.4661, 906.4609}, 21, 3, "Jizzy's Pleasure Dome"},
{21, {-2356.6838, 1008.1921, 50.8984}, {363.4346, -74.6586, 1001.5078}, 22, 10, "Burger Shot"},
{22, {-2419.5537, 969.7906, 45.2969}, {-31.0479, -91.4085, 1003.5469}, 23, 18, "Gas Station"},
{23, {-2374.7512, 910.1158, 45.4453}, {207.6829, -110.6515, 1005.1328}, 24, 15, "Binco"},
{24, {-2442.7688, 754.4709, 35.1719}, {-27.4370, -57.7182, 1003.5469}, 25, 6, "Supa Save"},
{25, {-2553.2563,1088.7507,55.7266}, {285.6062, -40.8603, 1000.9325}, 26, 1, "Ammunation"}
};
forward DynamicCPs();
public DynamicCPs()
{
new i = 0;
while(i < 25)
{
printf("enter: %f %f %f", CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2]);
CPIndex[i][0] = CreateDynamicCP(CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2], 1.5, -1, -1, -1, 100.0);
CPIndex[i][1] = CreateDynamicCP(CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2], 1.5, CPData[i][World], CPData[i][Interior], -1, 100.0);
/*CPLabel[i][0][0] = Create3DTextLabel("WELCOME TO", 0x00FF00FF, CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2] + 0.2, 25.0, 0, 1);
CPLabel[i][0][1] = Create3DTextLabel(CPData[i][SName], 0x0000FFFF, CPData[i][EnterLoc][0], CPData[i][EnterLoc][1], CPData[i][EnterLoc][2] + 0.05, 25.0, 0, 1);
CPLabel[i][1][0] = Create3DTextLabel("YOU WERE AT", 0x00FF00FF, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2] + 0.2, 7.5, CPData[i][World], 1);
CPLabel[i][1][1] = Create3DTextLabel(CPData[i][SName], 0x0000FFFF, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2] + 0.05, 7.5, CPData[i][World], 1);
*/
i++;
}
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
/* You should put the condition before the loop in this case, if this is false the loop doesn't run. */
if((GetTickCount() - CPTime[playerid]) > 5000)
{
/* You may keep this here because it'll run whenever the first time condition is true and OnPlayerEnterDynamicCP is called. */
CPTime[playerid] = GetTickCount();
for(new i; i < 25; i++)
{
if(checkpointid == CPIndex[i][0])
{
LastE[playerid] = i;
SetPlayerPos(playerid, CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2]);
SetPlayerInterior(playerid, CPData[i][Interior]);
SetPlayerVirtualWorld(playerid, CPData[i][World]);
//Loading(playerid);
return 1;
}
if(checkpointid == CPIndex[i][1])
{
new sID = LastE[playerid];
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, CPData[sID][EnterLoc][0], CPData[sID][EnterLoc][1], CPData[sID][EnterLoc][2]);
// Loading(playerid);
return 1;
}
}
/*if(checkpointid == JobCP[0])
{
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, 27);
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
return 1;
}
if(checkpointid == JobCP[1])
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, -1880.8790, 822.7505, 35.1774);
return 1;
}*/
}
return 1;
}
if((GetTickCount() - CPTime[playerid]) > 5000)
{
CPTime[playerid] = GetTickCount();
/* The rest of the code. */
AFAIK, you can use streamed and non-streamed checkpoints at once. That's why Incognito added a "dynamic" callback.
|