사이트 로그인
2017.06.08 13:26
require ("NewScript\\function");
local menu =
[[
<trade>
<head>
<title>환전상인</title>
<image name=z94 value=160>
<text>
환전을 도와드리겠습니다!
</text>
</head>
<command send='close'>닫기</command>
<body>
[사용법]
금화 1개 판다
금화 1개 산다
은화 1개 판다
은화 1개 산다
금전 1개 판다
금전 1개 산다
최대 판매,구입은 10000개 입니다.
(주의 엽전개수가 8천만이넘어가면
아이템이 사라지니판매할때 개수를
잘보고 판매하세요.)
★절대로 복구해드리지 않습니다★
</body>
</trade>
]]
function OnLeftClick(NpcP, PlayP, aStr)
Player.ShowWindowByStr(PlayP, NpcP, menu, 0);
end;
function OnGetResult(NpcP, PlayP, aStr)
if aStr == "close" then
return;
end;
end;
function OnHear(SelfP, SayP, aStr)
local say_list = SplitString(aStr,' ');
--판매리스트
local SellList = {'은화:100','금화:10000','금전:10000000'};
--구입리스트
local BuyList = {'은화:100','금화:10000','금전:10000000'};
--최대구입가능리스트
local MaxCount = 10000;
--구입또는판매 개수
local Count = tonumber(string.sub(say_list[2],0,string.len(say_list[2])-2));
if say_list[1] == '금전' then MaxCount = 10; end;
if (say_list[3] == '판다') and (MaxCount == 10) and (Player.GetItemExistence(SayP,'엽전:100000000')) then
Npc.Say(SelfP,'엽전의 개수가 너무많아서 판매가 불가능합니다.',0);
return;
end;
if Player.GetItemExistence(SayP,'엽전:100000000') then
Npc.Say(SelfP,'엽전의 개수가 너무많아서 판매가 불가능합니다.',0);
return;
end;
if say_list[3] == '판다' then
local check = false;
local money = 0;
--판매리스트에 있는것인지확인.
for i = 1,table.getn(SellList) do
if SplitString(SellList[i],':')[1] == say_list[1] then check = true; money = tonumber(SplitString(SellList[i],':')[2]) end;
end;
if Count > MaxCount then
Npc.Say(SelfP,'최대개수는 '..tostring(MaxCount)..'개 입니다.',0);
return;
end;
if check == false then
Npc.Say(SelfP,'판매목록에 없으므로 판매할수 없습니다.',0);
return;
end;
if not Player.GetItemExistence(SayP,say_list[1]..':'..tostring(Count)) then
Npc.Say(SelfP,say_list[1]..' '..tostring(Count)..'개가 필요합니다.',0);
return;
end;
money = money * Count;
print(SayP,SayP,'getsenderitem '..say_list[1]..':'..tostring(Count));
Player.Putmagicitem(SayP, '엽전:'..tostring(money), '자동보상노인', 3);
Npc.Say(SelfP, say_list[1]..' '..tostring(Count)..'개를 판매하셨습니다.', 0);
return;
end;
if say_list[3] == '산다' then
local check = false;
local money = 0;
--판매리스트에 있는것인지확인.
for i = 1,table.getn(BuyList) do
if SplitString(BuyList[i],':')[1] == say_list[1] then check = true; money = tonumber(SplitString(BuyList[i],':')[2]) end;
end;
if Count > MaxCount then
Npc.Say(SelfP,'최대개수는 '..tostring(MaxCount)..'개 입니다.',0);
return;
end;
if check == false then
Npc.Say(SelfP,'구입목록에 없으므로 구입할수 없습니다.',0);
return;
end;
money = money * Count;
if not Player.GetItemExistence(SayP,'엽전:'..tostring(money)) then
Npc.Say(SelfP,'엽전 '..tostring(Count)..'개가 필요합니다.',0);
return;
end;
print(SayP,SayP,'getsenderitem '..'엽전:'..tostring(money));
Player.Putmagicitem(SayP, say_list[1]..':'..tostring(Count), '자동보상노인', 3);
Npc.Say(SelfP, say_list[1]..' '..tostring(Count)..'개를 구입하셨습니다.', 0);
return;
end;
end;