Siema, kiedyś to było mi przydatne na serverze 8.6 jakieś 2 lata temu? niewiem, dawno może rok temu ;p
Jest po polsku więc na resources raczej nie przejdzie, a tutaj się noobom przyda.
To jest przykład Helmetera, ale możecie dorobić co chcecie do tablicy ;p
Są koszty minimalne i maksymalne by ludzie nie trollowali i wiedzieli ile mniejwięcej co chodzi (skapnąć się między min, a max ;p)
Hey, tworzymy npc i do lua wklejamy to:
Jest po polsku więc na resources raczej nie przejdzie, a tutaj się noobom przyda.
To jest przykład Helmetera, ale możecie dorobić co chcecie do tablicy ;p
Są koszty minimalne i maksymalne by ludzie nie trollowali i wiedzieli ile mniejwięcej co chodzi (skapnąć się między min, a max ;p)
Hey, tworzymy npc i do lua wklejamy to:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function doGADAJ_ALOT(cid,delay,messages)
for i = 1,#messages do
addEvent(doCreatureSay,delay * i, getNpcCid(), messages[i], TALKTYPE_PRIVATE_NP, false, cid)
end
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local stat = 5
--> funkcje wyswietlania ofert sprzedazy / kupna
local function oferty_swoje(cid)
local lista = db.getResult("SELECT `id`, `type`, `item_count`, `item_name`, `cost_ea` FROM `market` WHERE `player_name`='".. getPlayerName(cid) .. "' AND `status`='oczekujacy'")
if(lista:getID() ~= -1) then
local v = ''
repeat
i_c = lista:getDataString("item_count")
i_n = lista:getDataString("item_name")
c_ea = lista:getDataInt("cost_ea")
o_type = lista:getDataString("type")
o_id = lista:getDataString("id")
if c_ea >= 1000000 then
cost = c_ea/1000000
jednostka = "kk"
elseif c_ea >= 1000 then
cost = c_ea/1000
jednostka = "k"
else
cost = c_ea
jednostka = "gp"
end
v = v .. "[".. o_id .. "] " .. i_c .. "x " .. i_n .. " (" .. cost .." " .. jednostka ..") [" .. o_type .. "] \n"
until not lista:next()
lista:free()
txts = "count, item, cost, category \n"
ttt = txts .. v
else
ttt = "brak"
end
doShowTextDialog(cid, 2529, ttt)
end
local function oferty_sprzedazy(cid)
local lista = db.getResult("SELECT `id`, `item_count`, `item_name`, `cost_ea`, `player_name` FROM `market` WHERE `type`='sprzedam' AND `status`='oczekujacy'")
if(lista:getID() ~= -1) then
local v = ''
repeat
i_c = lista:getDataString("item_count")
i_n = lista:getDataString("item_name")
c_ea = lista:getDataInt("cost_ea")
player_name = lista:getDataString("player_name")
o_id = lista:getDataString("id")
if c_ea >= 1000000 then
cost = c_ea/1000000
jednostka = "kk"
elseif c_ea >= 1000 then
cost = c_ea/1000
jednostka = "k"
else
cost = c_ea
jednostka = "gp"
end
v = v .. "[".. o_id .. "] " .. i_c .. "x " .. i_n .. " (" .. cost .." " .. jednostka ..") (" .. player_name .. ") \n"
until not lista:next()
lista:free()
txts = "count, item, cost, player_name \n"
ttt = txts .. v
else
ttt = "brak"
end
doShowTextDialog(cid, 2529, ttt)
end
local function oferty_kupna(cid)
local lista = db.getResult("SELECT `id`, `item_count`, `item_name`, `cost_ea`, `player_name` FROM `market` WHERE `type`='kupie' AND `status`='oczekujacy'")
if(lista:getID() ~= -1) then
local v = ''
repeat
i_c = lista:getDataString("item_count")
i_n = lista:getDataString("item_name")
c_ea = lista:getDataInt("cost_ea")
player_name = lista:getDataString("player_name")
o_id = lista:getDataString("id")
if c_ea >= 1000000 then
cost = c_ea/1000000
jednostka = "kk"
elseif c_ea >= 1000 then
cost = c_ea/1000
jednostka = "k"
else
cost = c_ea
jednostka = "gp"
end
v = v .. "[".. o_id .. "] " .. i_c .. "x " .. i_n .. " (" .. cost .." " .. jednostka ..") (" .. player_name .. ") \n"
until not lista:next()
lista:free()
txts = "count, item, cost, player_name \n"
ttt = txts .. v
else
ttt = "brak"
end
doShowTextDialog(cid, 2529, ttt)
end
local function kupowanie(cid, msg, stat)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local stat = 5
local itemek = db.getResult("SELECT `item_count`, `player_id`, `item_id`, `item_name`, `cost_ea`, `player_name` FROM `market` WHERE `id`='" .. tonumber(msg) .. "' AND `type`='sprzedam' AND `status`='oczekujacy'")
if(itemek:getID() ~= -1) then
local v = ''
i_id = itemek:getDataString("item_id")
i_c = itemek:getDataString("item_count")
i_n = itemek:getDataString("item_name")
c_ea = itemek:getDataInt("cost_ea")
player_name = itemek:getDataString("player_name")
player_id = itemek:getDataString("player_id")
if c_ea >= 1000000 then
cost = c_ea/1000000
jednostka = "kk"
elseif c_ea >= 1000 then
cost = c_ea/1000
jednostka = "k"
else
cost = c_ea
jednostka = "gp"
end
v = v .. "[".. tonumber(msg).. "] " .. i_c .. "x " .. i_n .. " (" .. cost .." " .. jednostka ..") (" .. player_name .. ") "
itemek:free()
if getPlayerMoney(cid) >= c_ea * i_c then
doPlayerRemoveMoney(cid, c_ea * i_c)
doPlayerAddItem(cid, i_id, i_c)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sfinalizowales oferte: " .. v .. "")
db.query("UPDATE `market` SET `status` = 'sfinalizowany' WHERE `id` = " .. tonumber(msg) .. ";")
db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. c_ea .. " WHERE `id` = " .. player_id .. ";")
db.query("UPDATE `players` SET `sprzedawal` = `sprzedawal` + 1 WHERE `id` = " .. player_id .. ";")
db.query("UPDATE `players` SET `oferty_sprzedazy` = `oferty_sprzedazy` - 1 WHERE `id` = " .. player_id .. ";")
db.query("UPDATE `players` SET `oferty_dziennie` = `oferty_dziennie` - 1 WHERE `id` = " .. player_id .. ";")
talkState[talkUser] = 0
elseif getPlayerMoney(cid) < c_ea then
doGADAJ_ALOT(cid, 200, {"Nie masz wymaganej kwoty " .. cost .." " .. jednostka .."."})
end
else
doGADAJ_ALOT(cid, 200, {"W ofercei sprzedazy nie ma takiego ID"})
end
end
local function sprzedawanie(cid, msg, stat)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local stat = 5
local itemek = db.getResult("SELECT `item_count`, `player_id`, `item_id`, `item_name`, `cost_ea`, `player_name` FROM `market` WHERE `id`='" .. tonumber(msg) .. "' AND `type`='kupie' AND `status`='oczekujacy'")
if(itemek:getID() ~= -1) then
local v = ''
i_id = itemek:getDataInt("item_id")
i_c = itemek:getDataInt("item_count")
i_n = itemek:getDataString("item_name")
c_ea = itemek:getDataInt("cost_ea")
player_name = itemek:getDataString("player_name")
player_id = itemek:getDataString("player_id")
if c_ea >= 1000000 then
cost = c_ea/1000000
jednostka = "kk"
elseif c_ea >= 1000 then
cost = c_ea/1000
jednostka = "k"
else
cost = c_ea
jednostka = "gp"
end
itemek:free()
local name_of_database = "Sepira v4"
if getPlayerItemCount(cid, i_id) >= i_c then
doPlayerRemoveItem(cid, i_id, i_c)
doPlayerAddMoney(cid, c_ea * i_c)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sfinalizowales oferte i otrzymales: " .. c_ea * i_c .. " gold coins.")
db.query("UPDATE `market` SET `status` = 'sfinalizowany' WHERE `id` = " .. tonumber(msg) .. ";")
db.query("INSERT INTO `" .. name_of_database .."`.`sprzedane_items`(`item_count` ,`item_id` ,`item_name`,`cost_ea`, `player_name`, `dostarczono`, `player_id` )VALUES ('" .. i_c .. "', '" .. i_id .. "', '" .. i_n .. "', '" .. c_ea .. "', '" .. player_name .. "', 'nie', '" .. player_id .. "');")
db.query("UPDATE `players` SET `kupowal` = `kupowal` + 1 WHERE `id` = " .. player_id .. ";")
db.query("UPDATE `players` SET `oferty_kupna` = `oferty_kupna` - 1 WHERE `id` = " .. player_id .. ";")
db.query("UPDATE `players` SET `oferty_dziennie` = `oferty_dziennie` - 1 WHERE `id` = " .. player_id .. ";")
talkState[talkUser] = 0
elseif getPlayerItemCount(cid, i_id) < i_c then
doGADAJ_ALOT(cid, 200, {"Nie masz wymaganej liczby " .. i_c .. "x " .. i_n .."."})
end
else
doGADAJ_ALOT(cid, 200, {"W ofercei sprzedazy nie ma takiego ID"})
end
end
local function pobierz_pieniadze(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local stat = 5
local balance = db.getResult("SELECT `auction_balance` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
if(balance:getDataInt("auction_balance") < 1) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
balance:free()
return true
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. balance:getDataInt("auction_balance") .. " gps from auction system!")
doPlayerAddMoney(cid, balance:getDataInt("auction_balance"))
db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
balance:free()
end
local function pobierz_itemy(cid, msg, stat)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local stat = 5
local itemek = db.getResult("SELECT `id`, `item_count`, `item_id`, `item_name`, `cost_ea`, `player_name` FROM `sprzedane_items` WHERE `player_id`='" .. getPlayerGUID(cid) .. "' AND `dostarczono`='nie'")
if(itemek:getID() ~= -1) then
local v = ''
repeat
id = itemek:getDataInt("id")
i_id = itemek:getDataString("item_id")
i_c = itemek:getDataString("item_count")
i_n = itemek:getDataString("item_name")
c_ea = itemek:getDataInt("cost_ea")
player_name = itemek:getDataString("player_name")
if c_ea >= 1000000 then
cost = c_ea/1000000
jednostka = "kk"
elseif c_ea >= 1000 then
cost = c_ea/1000
jednostka = "k"
else
cost = c_ea
jednostka = "gp"
end
v = v .. "" .. i_c .. "x " .. i_n .. " \n"
doPlayerAddItem(cid, i_id, i_c)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Otrzymales: " .. i_c .. "x " .. i_n .. ".")
db.query("UPDATE `sprzedane_items` SET `dostarczono` = 'tak' WHERE `player_id` = '" .. getPlayerGUID(cid) .. "' AND `id` ='" .. id .. "';")
until not itemek:next()
itemek:free()
txts = "Odebrales nastepujace itemy: \n"
ttt = txts .. v
doShowTextDialog(cid, 2529, ttt)
else
doGADAJ_ALOT(cid, 200, {"Nie masz zadnych items w auction system"})
end
end
local function dodanie_oferty_kupna(cid)
db.query("UPDATE `players` SET `oferty_kupna` = `oferty_kupna` + 1 WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
local function dodanie_oferty_sprzedazy(cid)
db.query("UPDATE `players` SET `oferty_sprzedazy` = `oferty_sprzedazy` + 1 WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
local function dodanie_oferty_dziennie(cid)
db.query("UPDATE `players` SET `oferty_dziennie` = `oferty_dziennie` + 1 WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
--[[
CREATE TABLE IF NOT EXISTS `market` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`category` varchar(255) NOT NULL,
`item_count` varchar(255) NOT NULL,
`item_id` varchar(255) NOT NULL,
`item_name` varchar(255) NOT NULL,
`cost_ea` varchar(255) NOT NULL,
`player_name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`player_id` int(11),
PRIMARY KEY (`id`)
)ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
ALTER TABLE `players` ADD `auction_balance` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `sprzedawal` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `kupowal` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `oferty_kupna` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `oferty_sprzedazy` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `oferty_dziennie` INT( 11 ) NOT NULL DEFAULT '0';
CREATE TABLE IF NOT EXISTS `sprzedane_items` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`item_count` varchar(255) NOT NULL,
`item_id` varchar(255) NOT NULL,
`item_name` varchar(255) NOT NULL,
`cost_ea` varchar(255) NOT NULL,
`player_name` varchar(255) NOT NULL,
`dostarczono` varchar(255) NOT NULL,
`player_id` int(11),
PRIMARY KEY (`id`)
)ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
]]--
local helmets = {
["Amazon Helmet"] = {talk_kupic = 13, talk_sprzedac = 76313, cena_min = 20000, cena_max = 650000},
["Ancient Tiara"] = {talk_kupic = 14, talk_sprzedac = 76314, cena_min = 200000, cena_max = 3000000},
["Batwing Hat"] = {talk_kupic = 15, talk_sprzedac = 76315, cena_min = 6000, cena_max = 25000},
["Bonelord Helmet"] = {talk_kupic = 16, talk_sprzedac = 76316, cena_min = 6000, cena_max = 100000},
["Ceremonial Mask"] = {talk_kupic = 17, talk_sprzedac = 76317, cena_min = 245000, cena_max = 6000000},
["Charmer's Tiara"] = {talk_kupic = 18, talk_sprzedac = 76318, cena_min = 600, cena_max = 8000},
["Cobra Crown"] = {talk_kupic = 19, talk_sprzedac = 76319, cena_min = 45000, cena_max = 2150000},
["Crown Helmet"] = {talk_kupic = 20, talk_sprzedac = 76320, cena_min = 1000, cena_max = 10000},
["Crusader Helmet"] = {talk_kupic = 21, talk_sprzedac = 76321, cena_min = 3000, cena_max = 10000},
["Demon Helmet"] = {talk_kupic = 22, talk_sprzedac = 76322, cena_min = 35000, cena_max = 160000},
["Dragon Scale Helmet"] = {talk_kupic = 23, talk_sprzedac = 76323, cena_min = 500000, cena_max = 10000000},
["Dwarven Helmet"] = {talk_kupic = 24, talk_sprzedac = 76324, cena_min = 50000, cena_max = 500000},
["Elite Draken Helmet"] = {talk_kupic = 25, talk_sprzedac = 76325, cena_min = 145000, cena_max = 2000000},
["Ferumbras' Hat"] = {talk_kupic = 26, talk_sprzedac = 76326, cena_min = 500000, cena_max = 25000000},
["Glacier Mask"] = {talk_kupic = 27, talk_sprzedac = 76327, cena_min = 2000, cena_max = 10000},
["Fur Cap"] = {talk_kupic = 28, talk_sprzedac = 76328, cena_min = 50000, cena_max = 700000},
["Golden Helmet"] = {talk_kupic = 29, talk_sprzedac = 76329, cena_min = 250000, cena_max = 7000000},
["Hat of the Mad"] = {talk_kupic = 30, talk_sprzedac = 76330, cena_min = 4000, cena_max = 10000},
["Helmet of the Ancients"] = {talk_kupic = 31, talk_sprzedac = 76331, cena_min = 10000, cena_max = 200000},
["Helmet of the Deep"] = {talk_kupic = 32, talk_sprzedac = 76332, cena_min = 5000, cena_max = 20000},
["Horned Helmet"] = {talk_kupic = 33, talk_sprzedac = 76333, cena_min = 450000, cena_max = 14000000},
["Jade Hat"] = {talk_kupic = 34, talk_sprzedac = 76334, cena_min = 5000, cena_max = 20000},
["Jester Hat"] = {talk_kupic = 35, talk_sprzedac = 76335, cena_min = 3000, cena_max = 40000},
["Lightning Headband"] = {talk_kupic = 36, talk_sprzedac = 76336, cena_min = 2000, cena_max = 10000},
["Magician Hat"] = {talk_kupic = 37, talk_sprzedac = 76337, cena_min = 100000, cena_max = 2000000},
["Magma Monocle"] = {talk_kupic = 38, talk_sprzedac = 76338, cena_min = 2000, cena_max = 10000},
["Royal Helmet"] = {talk_kupic = 40, talk_sprzedac = 76339, cena_min = 25000, cena_max = 50000},
["Santa Hat"] = {talk_kupic = 41, talk_sprzedac = 76341, cena_min = 25000, cena_max = 200000},
["Sedge Hat"] = {talk_kupic = 42, talk_sprzedac = 76342, cena_min = 2000, cena_max = 15000},
["Skull Helmet"] = {talk_kupic = 43, talk_sprzedac = 76343, cena_min = 30000, cena_max = 80000},
["Tribal Mask"] = {talk_kupic = 44, talk_sprzedac = 76344, cena_min = 100, cena_max = 10000},
["Warrior Helmet"] = {talk_kupic = 45, talk_sprzedac = 76345, cena_min = 4000, cena_max = 10000},
["Winged Helmet"] = {talk_kupic = 46, talk_sprzedac = 76346, cena_min = 1000000, cena_max = 100000000},
["Witch Hat"] = {talk_kupic = 47, talk_sprzedac = 76347, cena_min = 2000, cena_max = 100000},
["Yalahari Mask"] = {talk_kupic = 48, talk_sprzedac = 76348, cena_min = 40000, cena_max = 150000},
["Zaoan Helmet"] = {talk_kupic = 49, talk_sprzedac = 76349, cena_min = 35000, cena_max = 150000},
["Demon Armor"] = {talk_kupic = 50, talk_sprzedac = 76350, cena_min = 150000, cena_max = 2000000},
["Yalahari Leg Piece"] = {talk_kupic = 51, talk_sprzedac = 76351, cena_min = 45000, cena_max = 200000},
}
local c = {
max_oferty_dziennie = 23,
name_of_database = getConfigInfo('sqlDatabase'),
category = "helmets",
}
local storages = {
join = 77300,
--oferta_dzienna = 77601,
}
local msgss = ''
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local GET = getPlayerStorageValue
local SET = setPlayerStorageValue
local function lista_mozliwosci(cid)
local tralal = ""
for k, v in pairs(helmets) do
if v.cena_max >= 1000000 then
cost_max = v.cena_max/1000000
jednostka = "kk"
cost_min = v.cena_min/1000000
elseif v.cena_max >= 1000 then
cost_max = v.cena_max/1000
jednostka = "k"
cost_min = v.cena_min/1000
else
cost_max = v.cena_max
jednostka = "gp"
cost_min = v.cena_min
end
tralal = tralal .. k .. " [" .. cost_min .. " " .. jednostka .. " - " .. cost_max .. " " .. jednostka .. "]\n"
end
doShowTextDialog(cid, 2529, tralal)
end
if msgcontains(msg, 'market') then
doGADAJ_ALOT(cid, 200, {'Witaj w markecie, {zloz} oferte lub {sprawdz} dostepne oferty. Mozesz tez sprawdzic {swoje} oferty, a takze {odebrac} zakonczone przetargi.'})
end
if msgcontains(msg, 'sprawdz') then
doGADAJ_ALOT(cid, 200, {'Jakie oferty chcesz sprawdzic; {sprzedazy} czy {kupna}?.'})
talkState[talkUser] = 1
end
if msgcontains(msg, 'zloz') then
local umca = db.getResult("SELECT `oferty_dziennie` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
local rolex = ""
if(umca:getDataInt("oferty_dziennie") < 0) then
db.query("UPDATE `players` SET `oferty_dziennie` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
rolex = rolex .. "To bedzie twoja pierwsza oferta. "
elseif (umca:getDataInt("oferty_dziennie") >= c.max_oferty_dziennie) then
rolex = rolex .. "Wykorzystales juz maximum ofert (".. umca:getDataInt("oferty_dziennie").. "/".. c.max_oferty_dziennie .. ""
elseif (umca:getDataInt("oferty_dziennie") < c.max_oferty_dziennie) then
rolex = rolex .. "Masz ofert: (".. umca:getDataInt("oferty_dziennie").. "/".. c.max_oferty_dziennie .. ")"
doGADAJ_ALOT(cid, 200, {'Jakie oferty chcesz sprawdzic; {sprzedazy} czy {kupna}?.'})
talkState[talkUser] = 2
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "" .. rolex .. "")
umca:free()
end
if msgcontains(msg, 'swoje') then
oferty_swoje(cid)
doGADAJ_ALOT(cid, 200, {'To sa Twoje oferty'})
end
if msgcontains(msg, 'odebrac') then
doGADAJ_ALOT(cid, 200, {'Chcesz odebrac {pieniadze} czy {itemy}?.'})
talkState[talkUser] = 22221
end
if msgcontains(msg, 'pieniadze') then
if talkState[talkUser] == 22221 then
pobierz_pieniadze(cid)
end
end
if msgcontains(msg, 'itemy') then
if talkState[talkUser] == 22221 then
pobierz_itemy(cid)
end
end
--[[
1x Demon Helmet, 45k, testowny
]]--
if msgcontains(msg, 'sprzedazy') then
if talkState[talkUser] == 1 then
oferty_sprzedazy(cid)
talkState[talkUser] = 16000
doGADAJ_ALOT(cid, 200, {'Takie sa oferty sprzedazy. By zakupic jedna z nich napisz {kupie}.'})
elseif talkState[talkUser] == 2 then
lista_mozliwosci(cid)
talkState[talkUser] = 3200
doGADAJ_ALOT(cid, 200, {'Prosze podaj nazwe przedmiotu, ktory chcesz sprzedac.'})
end
end
if msgcontains(msg, 'kupna') then
if talkState[talkUser] == 1 then
oferty_kupna(cid)
talkState[talkUser] = 16300
doGADAJ_ALOT(cid, 200, {'Takie sa oferty kupna. By sprzedac jedna z nich napisz {sprzedam}.'})
elseif talkState[talkUser] == 2 then
lista_mozliwosci(cid)
talkState[talkUser] = 200
doGADAJ_ALOT(cid, 200, {'Prosze podaj nazwe przedmiotu, ktory chcesz zakupic.'})
end
end
---> faktyczne tranzakcje; czyli kupowanie i sprzedawanie
if msgcontains(msg, 'kupie') then
if talkState[talkUser] == 16000 then
oferty_sprzedazy(cid)
talkState[talkUser] = 18300
return doGADAJ_ALOT(cid, 200, {'Wybierz jakis item, sprawdz id jakie ma oferta i napisz mi id.'})
end
end
if talkState[talkUser] == 18300 then
if (tonumber(msg) > 0) then
kupowanie(cid, msg, stat)
end
end
if msgcontains(msg, 'sprzedam') then
if talkState[talkUser] == 16300 then
oferty_kupna(cid)
talkState[talkUser] = 43700
return doGADAJ_ALOT(cid, 200, {'Wybierz jakis item, sprawdz id jakie ma oferta i napisz mi id.'})
end
end
if talkState[talkUser] == 43700 then
if (tonumber(msg) > 0) then
sprzedawanie(cid, msg, stat)
end
end
---> skladanie oferty kupna/sprzedazy
for k, v in pairs(helmets) do
if msgcontains(msg, k) then
if talkState[talkUser] == 200 then
talkState[talkUser] = v.talk_kupic
return doGADAJ_ALOT(cid, 200, {'Za ile chcesz kupic ' .. k ..' - minimum to: ' .. v.cena_min .. ' a max: ' .. v.cena_max .. '?'})
elseif talkState[talkUser] == 3200 then
talkState[talkUser] = v.talk_sprzedac
return doGADAJ_ALOT(cid, 200, {'Za ile chcesz sprzedac ' .. k ..' - minimum to: ' .. v.cena_min .. ' a max: ' .. v.cena_max .. '?'})
end
end
end
for k, v in pairs(helmets) do
if (talkState[talkUser] == v.talk_sprzedac or talkState[talkUser] == v.talk_kupic) then
if (tonumber(msg) > 0) then
if talkState[talkUser] == v.talk_kupic then
if tonumber(msg) < v.cena_min then
doGADAJ_ALOT(cid, 200, {'ZA MALO! Minimum to: ' .. v.cena_min .. ' a max: ' .. v.cena_max .. '!'})
elseif tonumber(msg) > v.cena_max then
doGADAJ_ALOT(cid, 200, {'ZA DUZO! Minimum to: ' .. v.cena_min .. ' a max: ' .. v.cena_max .. '!'})
else
if getPlayerMoney(cid) >= tonumber(msg) then
doPlayerRemoveMoney(cid, tonumber(msg))
doGADAJ_ALOT(cid, 200, {'Dodaje oferte: ' .. k .. ' za ' .. tonumber(msg) .. ' gold coins'})
db.query("INSERT INTO `" .. c.name_of_database .."`.`market`(`category`, `item_count` ,`item_id` ,`item_name`,`cost_ea`, `player_name`,`type`, `status`, `player_id` )VALUES ('" .. c.category .. "', '1', '" .. getItemIdByName(k) .. "', '" .. k .. "', '" .. tonumber(msg) .. "', '" .. getPlayerName(cid) .. "', 'kupie', 'oczekujacy', '" .. getPlayerGUID(cid) .. "');")
talkState[talkUser] = 0
oferty_kupna(cid)
doGADAJ_ALOT(cid, 200, {'Dodano Twoja oferte do ofert kupna.'})
dodanie_oferty_kupna(cid)
dodanie_oferty_dziennie(cid)
elseif
getPlayerMoney(cid) < tonumber(msg) then
doGADAJ_ALOT(cid, 200, {'Nie masz tyle pieniedzy'})
end
end
elseif talkState[talkUser] == v.talk_sprzedac then
if tonumber(msg) < v.cena_min then
doGADAJ_ALOT(cid, 200, {'ZA MALO! Minimum to: ' .. v.cena_min .. ' a max: ' .. v.cena_max .. '!'})
elseif tonumber(msg) > v.cena_max then
doGADAJ_ALOT(cid, 200, {'ZA DUZO! Minimum to: ' .. v.cena_min .. ' a max: ' .. v.cena_max .. '!'})
else
if getPlayerItemCount(cid, getItemIdByName(k)) >= 1 then
doPlayerRemoveItem(cid, getItemIdByName(k), 1)
doGADAJ_ALOT(cid, 200, {'Dodaje oferte: ' .. k .. ' za ' .. tonumber(msg) .. ' gold coins'})
db.query("INSERT INTO `" .. c.name_of_database .."`.`market`(`category`, `item_count` ,`item_id` ,`item_name`,`cost_ea`, `player_name`,`type`, `status`, `player_id` )VALUES ('" .. c.category .. "', '1', '" .. getItemIdByName(k) .. "', '" .. k .. "', '" .. tonumber(msg) .. "', '" .. getPlayerName(cid) .. "', 'sprzedam', 'oczekujacy', '" .. getPlayerGUID(cid) .. "');")
talkState[talkUser] = 0
oferty_sprzedazy(cid)
doGADAJ_ALOT(cid, 200, {'Dodano Twoja oferte do ofert sprzedazy.'})
dodanie_oferty_sprzedazy(cid)
dodanie_oferty_dziennie(cid)
elseif
getPlayerMoney(cid) < tonumber(msg) then
doGADAJ_ALOT(cid, 200, {'Nie posiadasz ' .. k ..'!'})
end
end
end
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())