Checkpoints not disappearing?
#1

Hi, I have a little script for my server which isn't working as well as I hoped, everything is working correctly apart from the last checkpoint isn't disappearing. Here's my code for the command:
pawn Код:
CMD:fly(playerid, params[])
{
    new rand = random(sizeof(RandAirports));
    new string[256];
    if(IsPlayerInDynamicArea(playerid, LSAP))
    {
        airportcheckpoint = CreateDynamicCP(RandAirports[rand][FromX], RandAirports[rand][FromY], RandAirports[rand][FromZ], 15.0, 0, 0, playerid, 10000.0);
        format(string, sizeof(string), "Radio: Hello, Captain {009DFF}%s{FFFFFF}. You will be traveling from {009DFF}%s{FFFFFF}.", PlayerName(playerid), RandAirports[rand][Info]);
        SendClientMessage(playerid, COLOR_WHITE, string);
        Flying[playerid] = 1;
    }
    if(IsPlayerInDynamicArea(playerid, SFAP))
    {
        airportcheckpoint = CreateDynamicCP(RandSFAirports[rand][FromX], RandSFAirports[rand][FromY], RandSFAirports[rand][FromZ], 15.0, 0, 0, playerid, 10000.0);
        format(string, sizeof(string), "Radio: Hello, Captain {009DFF}%s{FFFFFF}. You will be traveling from {009DFF}%s{FFFFFF}.", PlayerName(playerid), RandSFAirports[rand][Info]);
        SendClientMessage(playerid, COLOR_WHITE, string);
        Flying[playerid] = 1;
    }
    return 1;
}
The command works perfectly its just when a player enters the last checkpoint, it just wont disappear. Here's the code for it.
pawn Код:
new rand = random(sizeof(RandAirports));
    if(checkpointid == airportcheckpoint[playerid])
    {
        switch(Flying[playerid])
        {
            case 1:
            {
                DestroyDynamicCP(airportcheckpoint[playerid]);
                airportcheckpoint[playerid] = CreateDynamicCP(RandAirports[rand][ToX], RandAirports[rand][ToY], RandAirports[rand][ToZ], 15.0, 0, 0, playerid, 10000.0);
                SendClientMessage(playerid, COLOR_WHITE, "Radio: Please pick up your {009DFF}speed {FFFFFF}and get ready for {009DFF}take off{FFFFFF}.");
                Flying[playerid] = 2;
            }
            case 2:
            {
                SendClientMessage(playerid, COLOR_WHITE, "Radio: Well done, you have {009DFF}completed {FFFFFF}the {009DFF}travel{FFFFFF}.");
                PlayerInfo[playerid][pLevel] += 3;
                PlayerInfo[playerid][pMoney] += random(2555)+1000;
                SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                SaveAccount(playerid);
                Flying[playerid] = 0;
                DestroyDynamicCP(airportcheckpoint);
            }
        }
    }
It'd be much appreciated if you could help me. Thanks.
Reply
#2

you are creating the airportcheckpoint in the command for both airports, LS and SF.. that looks good
what doesnt look good, is that in the EnterCheckpoint you are...
case 1: destroying airportcheckpoint[playerid],
and in
case 2: destroying airportcheckpoint
...without the [playerid]. i bet its the [playerid], either missing, or too much, idk which airport CP gets succesfully destroyed....
airportcheckpoint = CreateDynamicCP[playeird](blablabla); shoudl work i guess hehe
Reply
#3

Yeah, I just noticed that. It seems to be working for me just hope it works for everyone else rofl. Glad you like the command!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)