• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Vial of Oil - problem

Status
Not open for further replies.

Govern

Member
Joined
May 6, 2011
Messages
182
Reaction score
5
Location
Warsaw
Witam,

Standardowy problem z vial of oil..
Sprawa wygląda tak:

- Gdy dodaje go do NPC to nie mogę go kupić.
- God-em mogę go wyczarować 2006,11

Code:
15:50 You see a vial of oil.
It weighs 1.80 oz.
ItemID: [2006].
Position: [X: 32347] [Y: 32224] [Z: 7].

- Znalazłem na forum skrypt dzięki któremu "niby" można go kupić, lecz jest on widoczny na trade, gdy wezmę look będzie napisane, że jest to vial of oil, lecz po zakupie jest to vial of beer.

Próbowałem już na różne sposoby, dodatkowo gdy zamiast vial of oil dam vial of blood to mogę kupić i po zakupie też wszystko się zgadza, błąd tyczy się tylko OIL.

Z góry dzięki za pomoc.
 
Łap ;)

Code:
local focuses = {}

local function isFocused(cid)

	for i, v in pairs(focuses) do

		if(v == cid) then

			return true

		end

	end

	return false

end

 

local function addFocus(cid)

	if(not isFocused(cid)) then

		table.insert(focuses, cid)

	end

end

local function removeFocus(cid)

	for i, v in pairs(focuses) do

		if(v == cid) then

			table.remove(focuses, i)

			break

		end

	end

end

local function lookAtFocus()

	for i, v in pairs(focuses) do

		if(isPlayer(v)) then

			doNpcSetCreatureFocus(v)

			return

		end

	end

	doNpcSetCreatureFocus(0)

end

 

local itemWindow = {

	{id=2006, subType=11, buy=20, name="Vial of Oil"}



}

 

local items = {}

for _, item in ipairs(itemWindow) do

	items[item.id] = {buyPrice = item.buy, sellPrice = item.sell, subType = item.subType, realName = item.name}

end

 

local function getPlayerMoney(cid)

	return ((getPlayerItemCount(cid, 2160) * 10000) +

	(getPlayerItemCount(cid, 2152) * 100) +

	getPlayerItemCount(cid, 2148))

end

 

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)

	if(items[item] == nil) then

		selfSay("Ehm.. sorry... this shouldn't be there, I'm not selling it.", cid)

		return

	end

 

	if(getPlayerMoney(cid) >= amount * items[item].buyPrice) then

		local itemz, i = doNpcSellItem(cid, item, amount, subType, ignoreCap, inBackpacks)

		if(i < amount) then

			if(i == 0) then

				selfSay("Sorry, but you don't have space to take it.", cid)

			else

				selfSay("I've sold some for you, but it seems you can't carry more than this. I won't take more money than necessary.", cid)

				doPlayerRemoveMoney(cid, i * items[item].buyPrice)

			end

		else

			selfSay("Thanks for the money!", cid)

			doPlayerRemoveMoney(cid, amount * items[item].buyPrice)

		end

	else

		selfSay("Stfu noob, you don't have money.", cid)

	end

end

 

local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)

	if(items[item] == nil) then

		selfSay("Ehm.. sorry... this shouldn't be there, I'm not buying it.", cid)

	end

 

	if(subType < 1) then

		subType = -1

	end

	if(doPlayerRemoveItem(cid, item, amount, subType)) then

		doPlayerAddMoney(cid, items[item].sellPrice * amount)

		selfSay("Here you are.", cid)

	else

		selfSay("No item, no deal.", cid)

	end

end

 

function onCreatureAppear(cid)

end

 

function onCreatureDisappear(cid)

	if(isFocused(cid)) then

		selfSay("Hmph!")

		removeFocus(cid)

		if(isPlayer(cid)) then --Be sure he's online

			closeShopWindow(cid)

		end

	end

end

 

function onCreatureSay(cid, type, msg)

	if((msg == "hi") and not (isFocused(cid))) then

		selfSay("Welcome, ".. getCreatureName(cid) ..".", cid, true)

		selfSay("Do you want to see my {wares}?", cid)

		addFocus(cid)

	elseif((isFocused(cid)) and (msg == "wares" or msg == "trade")) then

		selfSay("Pretty nice, right?", cid)

		openShopWindow(cid, itemWindow, onBuy, onSell)

	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then

		selfSay("Goodbye!", cid, true)

		closeShopWindow(cid)

		removeFocus(cid)

	end

end

 

function onPlayerCloseChannel(cid)

	if(isFocused(cid)) then

		selfSay("Hmph!")

		closeShopWindow(cid)

		removeFocus(cid)

	end

end

 

function onPlayerEndTrade(cid)

	selfSay("It was a pleasure doing business with you.", cid)

end

 

function onThink()

	for i, focus in pairs(focuses) do

		if(not isCreature(focus)) then

			removeFocus(focus)

		else

			local distance = getDistanceTo(focus) or -1

			if((distance > 4) or (distance == -1)) then

				selfSay("Hmph!")

				closeShopWindow(focus)

				removeFocus(focus)

			end

		end

	end

	lookAtFocus()

end
 
Jaki to jest typ otsa? tfs? i czy używasz jiddos npc systemu.
 
TFS rev 3884, tylko ten skrypcik jest dość zadziwiający ;P
 
Bo jest jakiś błąd i nie działa funkcja kupowania na trade, itemów z subtype większym niż 9 lub 10.

Niewiem jak to naprawić (chyba w libach npc), ale możesz np. dać, żeby po napisaniu do npc buy vial of oil dawało funkcją doplayeradditem(cid, 2006, 11,1)
 
Status
Not open for further replies.
Back
Top