26.09.2011, 20:29
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:
The command works perfectly its just when a player enters the last checkpoint, it just wont disappear. Here's the code for it.
It'd be much appreciated if you could help me. Thanks.
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;
}
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);
}
}
}