DynamicCP problem
#6

Look, I used the next code in my gamemode and it worked perfectly:
PHP код:
/* 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.7708920.12957.1875}, {10081.0352, -1761.45001151.4153}, 23"San Fierro Bank"},
    {
2, {-1616.59001122.92597.1875}, {-31.0479, -91.40851003.5469}, 318"24/7"},
    {
3, {-1662.25261299.88167.0391}, {285.6062, -40.86031000.9325}, 41"Ammunation"},
    {
4, {-1721.57711359.76267.1853}, {372.3125, -132.89161001.4922}, 55"Well Stacked Pizza"},
    {
5, {-1694.7739951.669724.8906}, {226.9353, -8.20481002.2109}, 65"Victim's Clothing"},
    {
6, {-1810.3533902.299324.8906}, {203.8098, -49.93311001.8047}, 71"Sub Urban's Clothing"},
    {
7, {-1808.2634945.561524.8906}, {372.3125, -132.89161001.4922}, 85"Well Stacked Pizza"},
    {
8, {-1912.2750828.211335.2214}, {363.4346, -74.65861001.5078}, 910"Burger Shot"},
    {
9, {-1882.2578866.503135.1719}, {161.4177, -96.45331001.8047}, 1018"Zip's Clothing"},
    {
10, {-1816.4827618.026035.1719}, {365.0151, -11.09581001.8516}, 119"Cluckin' Bell"},
    {
11, {-2269.5771, -155.962835.3203}, {774.2042, -49.74281000.5859}, 126"Cobra's Martial Arts"},
    {
12, {-2490.3750, -29.154925.6172}, {203.8098, -49.93311001.8047}, 131"Sub Urban's Clothing"},
    {
13, {-2336.2737, -166.766435.5547}, {363.4346, -74.65861001.5078}, 1410"Burger Shot"},
    {
14, {-2491.3745, -38.960125.7656}, {-204.3975, -8.69901002.2734}, 1517"Tattoo Shop"},
    {
15, {-2625.8135208.86254.6174}, {315.7365, -143.0907999.6016}, 167"Ammunation"},
    {
16, {-2571.1086246.682810.3268}, {411.6910, -22.86691001.8047}, 172"Barber Shop"},
    {
17, {-2672.3086258.70054.6328}, {365.0151, -11.09581001.8516}, 189"Cluckin' Bell"},
    {
18, {-2767.7983788.732952.7813}, {377.1708, -192.70611000.6401}, 1917"Tuff Nuts Donuts"},
    {
19, {-2523.80271216.147937.4283}, {377.1708, -192.70611000.6401}, 2017"Restaurant"},
    {
20, {-2624.42701411.91667.0938}, {-2636.78001403.4661906.4609}, 213"Jizzy's Pleasure Dome"},
    {
21, {-2356.68381008.192150.8984}, {363.4346, -74.65861001.5078}, 2210"Burger Shot"},
    {
22, {-2419.5537969.790645.2969}, {-31.0479, -91.40851003.5469}, 2318"Gas Station"},
    {
23, {-2374.7512910.115845.4453}, {207.6829, -110.65151005.1328}, 2415"Binco"},
    {
24, {-2442.7688754.470935.1719}, {-27.4370, -57.71821003.5469}, 256"Supa Save"},
    {
25, {-2553.2563,1088.7507,55.7266}, {285.6062, -40.86031000.9325}, 261"Ammunation"}
};
forward DynamicCPs();
public 
DynamicCPs()
{
    new 
0;
    while(
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, -1100.0);
        
CPIndex[i][1] = CreateDynamicCP(CPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2], 1.5CPData[i][World], CPData[i][Interior], -1100.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(playeridcheckpointid)
{
    
/* 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 
i25i++)
        {
            if(
checkpointid == CPIndex[i][0])
            {
                
LastE[playerid] = i;
                
SetPlayerPos(playeridCPData[i][ExitLoc][0], CPData[i][ExitLoc][1], CPData[i][ExitLoc][2]);
                
SetPlayerInterior(playeridCPData[i][Interior]);
                
SetPlayerVirtualWorld(playeridCPData[i][World]);
                
//Loading(playerid);
                
return 1;
            }
            if(
checkpointid == CPIndex[i][1])
            {
                 new 
sID LastE[playerid];
                
SetPlayerInterior(playerid0);
                
SetPlayerVirtualWorld(playerid0);
                
SetPlayerPos(playeridCPData[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;

I modified it a bit to adapt it to my gamemode, but you'll understand it. I changed MAX_CHECKPOINTS to 25, you should do that also.

The time condition must look like this:
PHP код:
if((GetTickCount() - CPTime[playerid]) > 5000)
{
    
CPTime[playerid] = GetTickCount();
    
/* The rest of the code. */ 
Reply


Messages In This Thread
DynamicCP problem - by Quinncell - 19.07.2016, 12:13
Re: DynamicCP problem - by Quinncell - 19.07.2016, 12:31
Re: DynamicCP problem - by Quinncell - 19.07.2016, 13:33
Re: DynamicCP problem - by Sew_Sumi - 19.07.2016, 13:46
Re: DynamicCP problem - by Quinncell - 19.07.2016, 13:52
Re: DynamicCP problem - by RIDE2DAY - 19.07.2016, 14:06
Re: DynamicCP problem - by Sew_Sumi - 19.07.2016, 14:06
Re: DynamicCP problem - by Quinncell - 19.07.2016, 14:18
Re: DynamicCP problem - by Sew_Sumi - 19.07.2016, 14:31
Re: DynamicCP problem - by Quinncell - 19.07.2016, 15:35

Forum Jump:


Users browsing this thread: 3 Guest(s)