Перейти к содержанию

Обнуление переменной


Рекомендуемые сообщения

Еще раз здравствуйте все.

Вы наверное уже от меня устали

В общем например такой скрипт:

location,100,100,1 script Example::ex 90,{
if(.speak == 1) goto sorry;
set .speak,1;
set .name$,strcharinfo(0);
mes "[Example]";
mes "Part of this NPC is free, you can talk to him.";
next;
mes "[Example]";
mes "The first player is in conversation with the NPC.";
next;
mes "[Example]";
mes "The first player finishes a conversation with the NPC.";
set .speak,0;
close;

sorry:
mes "";
mes "Sorry. Currently, "+.name$+" is talking to the NPC..";
close;
}

Вроде бы все работает.

Но.

Если добавить меню.

location,100,100,1 script Example::ex 90,{
if(.speak == 1) goto sorry;
set .speak,1;
set .name$,strcharinfo(0);
mes "[Example]";
mes "Part of this NPC is free, you can talk to him.";
next;
mes "[Example]";
mes "The first player was invited to the menu.";
next;
switch(select("The first menu item:The second menu item:The third menu item") {
case 1:
mes "[Example]";
mes "The first player selected first menu item.";
set .speak,0;
close;
case 2:
mes "[Example]";
mes "The first player selected the second menu item.";
set .speak,0;
close;
case 3:
mes "[Example]";
mes "The first player has chosen the third element of the menu.";
set .speak,0;
close;
sorry:
mes "";
mes "Sorry. Currently, "+.name$+" is talking to the NPC..";
close;
}

Сам по себе образуется баг - когда НПС выдает меню и если не выбирать какой то элемент меню, а выйти из диалога, то переменная .спек не обнулится и никто не сможет больше с этим НПС поговорить. Может кто нибудь сможет придумать как обойти эту проблему?

Заранее Спасибо.

Ссылка на комментарий
Поделиться на другие сайты

location,100,100,1 script Example::ex 90,{
if(.speak == 1) goto sorry;
set .speak,1;
set .name$,strcharinfo(0);
mes "[Example]";
mes "Part of this NPC is free, you can talk to him.";
next;
mes "[Example]";
mes "The first player was invited to the menu.";
next;
set .speak,0;
switch(select("The first menu item:The second menu item:The third menu item") {
case 1:
mes "[Example]";
mes "The first player selected first menu item.";
set .speak,0;
close;
case 2:
mes "[Example]";
mes "The first player selected the second menu item.";
set .speak,0;
close;
case 3:
mes "[Example]";
mes "The first player has chosen the third element of the menu.";
set .speak,0;
close;
sorry:
mes "";
mes "Sorry. Currently, "+.name$+" is talking to the NPC..";
close;
}

Ссылка на комментарий
Поделиться на другие сайты

А разница в чем? :mellow:

prompt works almost the same as select, except that when a character clicks

the Cancel button, this function will return 255 instead.


switch(prompt("Да:Нет"))
{
case 1:
mes "Вы ответили положительно";
break;
case 2:
mes "Вы ответили отрицательно";
break;
case 255:
mes "Вы нажали кнопку 'Отмена'";
break;
}

Изменено пользователем Лилит
  • Upvote 1
Ссылка на комментарий
Поделиться на другие сайты

×
×
  • Создать...
Яндекс.Метрика