OnPlayerEnterDynamicCP [+REP]
#1

This simply doesn't work, I've been messing with it, but still doesn't work. I don't know why.

pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new string[128];
    for(new h = 0; h < sizeof(Houses); c++)
    {
        if(checkpointid == Houses[h][PickupID])
        {
            if(Houses[h][Owned] == 0)
            {
                SendClientMessage(playerid, COLOR_GREEN, "Would you like to buy this?");
                format(string, sizeof(string), "Price: $%d", Houses[h][HousePrice]);
                SendClientMessage(playerid, COLOR_GREEN, string);
                SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
                SendClientMessage(playerid, COLOR_WHITE, "/buyhouse");
            }
            if(Houses[h][Rentable] == 1)
            {
                new string2[128];
                format(string, sizeof(string), "[Address: %d] You're standing on %s's porch.",h,Houses[h][Owner]);
                SendClientMessage(playerid, COLOR_GREEN, string);
                format(string2, sizeof(string2), "Available commands: /enter, /ds(hout), /rentroom (Price: $%d)", Houses[h][RentCost]);
                SendClientMessage(playerid, COLOR_WHITE, string2);
            }
                format(string, sizeof(string), "[Address: %d] You're standing on %s's porch.",h,Houses[h][Owner]);
                SendClientMessage(playerid, COLOR_GREEN, string);
                SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
            }
        }
    }
    return 1;
}

Any ideas?
Reply
#2

Change
pawn Код:
for(new h = 0; h < sizeof(Houses); c++)
To
pawn Код:
for(new h = 0; h < sizeof(Houses); h++)
Reply
#3

I did, either way it still didn't work. I'm not sure why this is like this, it was working before.
Reply
#4

You're missing an if statement.
Reply
#5

Are you sure you are using Checkpoints? You compare with Pickup here.

pawn Код:
checkpointid == Houses[h][PickupID]
Reply
#6

Try it
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new string[128];
    for(new h = 0; h < sizeof(Houses); h++)
    {
        if(checkpointid == Houses[h][PickupID])
        {
            if(Houses[h][Owned] == 0)
            {
                SendClientMessage(playerid, COLOR_GREEN, "Would you like to buy this?");
                format(string, sizeof(string), "Price: $%d", Houses[h][HousePrice]);
                SendClientMessage(playerid, COLOR_GREEN, string);
                SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
                SendClientMessage(playerid, COLOR_WHITE, "/buyhouse");
            }
            if(Houses[h][Rentable] == 1)
            {
                new string2[128];
                format(string, sizeof(string), "[Address: %d] You're standing on %s's porch.",h,Houses[h][Owner]);
                SendClientMessage(playerid, COLOR_GREEN, string);
                format(string2, sizeof(string2), "Available commands: /enter, /ds(hout), /rentroom (Price: $%d)", Houses[h][RentCost]);
                SendClientMessage(playerid, COLOR_WHITE, string2);
            } 
            else
            {
               format(string, sizeof(string), "[Address: %d] You're standing on %s's porch.",h,Houses[h][Owner]);
               SendClientMessage(playerid, COLOR_GREEN, string);
               SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
            }
        }
    }
    return 1;
}
Reply
#7

Didn't work either.


And yes, I do have the checkpoint being created,
pawn Код:
Houses[idx][PickupID] = CreateDynamicCP(Houses[idx][EnterX], Houses[idx][EnterY], Houses[idx][EnterZ], 2.5, 0, 0, -1, 1.2);

EDIT: See, I dont even think the checkpoint is being created correctly.

I did this:
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new string[64];
    for(new h = 0; h < sizeof(Houses); h++)
    {
        if(checkpointid == Houses[h][PickupID])
        {
            format(string, sizeof(string), "Checkpoint: %d", checkpointid);
            SendClientMessage(playerid, COLOR_GREEN, string);
        }
    }
    return 1;
}
That didn't even work. But when I walk into the checkpoint it appears, it just doesnt say nothing
Reply
#8

The Checkpoint has to be toggled. I mean, you have to use TogglePlayerDynamicCP(playerid,checkpointid,(true/false)).

Checkpoint has to be created in OnGameModeInit(). After that, you have to make sure, that stream distance is not far enough from player.

In example:
Код:
new carcp, car;
OnGameModeInit()
{
   //array = CreateDynamicCP(x,y,z,size,virtualworld,interior,playerid(-1 for all), strdistance);
     carcp = CreateDynamicCP(-2000,-1000,20,1.0,0,0,-1,5000.0);
     return 1;
}

OnPlayerSpawn(playerid)
{
     // TogglePlayerDynamicCP(playerid,checkpointid,toggle);
     TogglePlayerDynamicCP(playerid,carcp,true);
     return 1;
}

OnPlayerEnterDynamicCP(playerid,checkpointid)
{
     if(checkpointid == carcp)
     {
         //array  CreateVehicle(modelid,x,y,z,rotation,color1,color2,respawn delay);
            car = CreateVehicle(522,-2000,-1000,20,60,6,0,120);
            TogglePlayerDynamicCP(playerid,carcp,false);
     }
     return 1;
}
OnVehicleDeath(vehicleid)
{
     if(vehicleid == car) return DestroyVehicle(car);
     return 1;
}
OnPlayerDeath(playerid)
{
     TogglePlayerDynamicCP(playerid,carcp,false);
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)