Немного оптимизации не повредит
PHP код:
new Text3D:Parachute, Plane[2];
#define PLANE_DIALOG 12345
PHP код:
if(!strcmp(cmdtext, "/samolet", true))
{
static dialog[150];
format(dialog, sizeof(dialog), "Создать самолёт [%s]\nЗапустить самолёт [%s]\nУдалить самолёт [%s]",
(!GetPVarInt(playerid, "PlaneCreated")) ? ("{FF0000}Не выполнено{ffffff}") : ("{00CD00}Выполнено{ffffff}"),
(!GetPVarInt(playerid, "PlaneMoved")) ? ("{FF0000}Не выполнено{ffffff}") : ("{00CD00}Выполнено{ffffff}"),
(!GetPVarInt(playerid, "PlaneRemove")) ? ("{FF0000}Не выполнено{ffffff}") : ("{00CD00}Выполнено{ffffff}"));
return ShowPlayerDialog(playerid,PLANE_DIALOG,DIALOG_STYLE_LIST,"{FF9900}Меню",string,"Выбрать","Отмена"), true;
}
public OnDialogResponse(playerid)
PHP код:
if(dialogid == PLANE_DIALOG)
{
if(!response) return true;
switch(listitem)
{
case 0:
{
if(GetPVarInt(playerid, "PlaneCreated")) return SendClientMessage(playerid, 0xff0000ff, "Ошибка: {ffffff}Самолёт уже создан!");
Parachute = Create3DTextLabel( "Ïàðàøþò! :)", 0x7FFF00FF, 2008.8929,-2532.5046,14.0, 40.0, 0);
Plane[0] = CreateObject(14553, 1980.20, -2506.91, 25.82, 0.00, 0.00, 220.00), Plane[1] = CreateObject(14548, 1983.20, -2510.50, 25.50, 0.00, 0.00, 220.00);
SetPVarInt(playerid, "PlaneCreated", 1);
for(new i = GetMaxPlayers() - 1; i != -1; i--)
{
if(!IsPlayerConnected(i)) continue;
SetPlayerCheckpoint(i, 2008.8929,-2532.5046,13.5469, 1.0), SetPVarInt(i, "GotParachute", 1);
SendClientMessage(i, 0xff0000ff,"{ff0000}Информация: {ffffff}Желающих полетать на парашюте прибыть в {ADD8E6}Аэропорт г.Лос-Сантос.");
}
}
case 1:
{
if(!GetPVarInt(playerid, "PlaneCreated")) return SendClientMessage(playerid, 0xff0000ff, "Ошибка: {ffffff}Самолёт не создан!");
if(GetPVarInt(playerid, "PlaneMoved")) return SendClientMessage(playerid, 0xff0000ff, "Ошибка: {ffffff}Самолёт уже запущен!");
SetPVarInt(playerid, "PlaneMoved", 1);
MoveObject(Plane[0], -10.251000404358, -264.27801147461, 2000.32, 40);
MoveObject(Plane[1], -7.251000404358, -267.86801147461, 2000.0, 40);
Delete3DTextLabel(Parachute);
for(new i = GetMaxPlayers() - 1; i != -1; i--) if(IsPlayerConnected(i)) DisablePlayerCheckpoint(i), DeletePVar(i, "GotParachute");
}
case 2:
{
if(!GetPVarInt(playerid, "PlaneCreated")) return SendClientMessage(playerid, 0xff0000ff, "Ошибка: {ffffff}Самолёт не создан!");
if(GetPVarInt(playerid, "PlaneRemove")) return SendClientMessage(playerid, 0xff0000ff, "Ошибка: {ffffff}Самолёт удалён!");
SetPVarInt(playerid, "PlaneRemove", 1);
DeletePVar(playerid, "PlaneCreated");
DeletePVar(playerid, "PlaneMoved");
Delete3DTextLabel(Parachute), DestroyObject(Plane[0]), DestroyObject(Plane[1]);
for(new i = GetMaxPlayers() - 1; i != -1; i--) if(IsPlayerConnected(i)) DisablePlayerCheckpoint(i), DeletePVar(i, "GotParachute");
}
}
}
public OnPlayerEnterCheckpoint(playerid)
PHP код:
if(GetPVarInt(playerid, "GotParachute"))
{
GivePlayerWeapon(playerid, 46, 1);
}