• 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!

Sprawdzanie itemów na danej kratce

Seminari

Banned User
Joined
Dec 13, 2009
Messages
1,496
Reaction score
34
Location
Poland
Jest jakaś funkcja, która sprawdza czy jest na jakiejś kratce jakiś item w ilości większej niż ileś?
Analogiczna funkcja do getPlayerItemCount, tylko, żeby sprawdzała z tile, potrzebne mi to jest do ostatniej części questu helmet of the ancients..

narazie zrobiłem
Code:
if getPlayerItemCount(cid, helmet_1) >= 1 and getPlayerItemCount(cid, helmet_2) >= 1 and getPlayerItemCount(cid, helmet_3) >= 1 and 
		getPlayerItemCount(cid, helmet_4) >= 1 and getPlayerItemCount(cid, helmet_5) >= 1 and getPlayerItemCount(cid, helmet_6) >= 1 and 
		getPlayerItemCount(cid, helmet_7) >= 1 then
			doPlayerRemoveItem(cid, helmet_1, 1)
			doPlayerRemoveItem(cid, helmet_2, 1)
			doPlayerRemoveItem(cid, helmet_3, 1)
			doPlayerRemoveItem(cid, helmet_4, 1)
			doPlayerRemoveItem(cid, helmet_5, 1)
			doPlayerRemoveItem(cid, helmet_6, 1)
			doPlayerRemoveItem(cid, helmet_7, 1)
			doPlayerAddItem(cid, helmet_of_the_ancients, 1)
			doSendMagicEffect(v.TP_GOOD, v.efekt)
		end

A wolałbym zrobić jak na rl tibii ;/
 
Nie rozumiem?
Załóżmy chce sprawdzić czy na kratce X są itemid 2335 2336 2337 2338 2339 2340 2341, to proszę napisz mi skrypt na to, bo nie zbyt ogarniam, bo przecież każdy kolejny item to nowy stackpos, a nie zamierzam walić tyle warunków
 
hmm sorry nie doczytalem,
w 1 zdaniu zadales pytanie o sprawdzanie stackable items.
jesli chodzi o rozne itemy na jednym tile to uzyj funkcji 'for'

getThingFromPos({x=111, y=11, z=8}).itemid wyrzuca itemid przedmiotu w tym miejsci. Kombinuj i wklej co wykombinowales :)

-- edit
takie cos napisalem na lever, mozesz przerobic na moveevents
LUA:
local c = {
	items = {2335, 2336, 2337, 2338, 2339, 2340, 2341},
	pos = {x=1111, y=1111, z=8}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	if item.uid == 1111 then
		local itemy = {}
		for _, item in ipairs(c.items) do
			for i = 0, 20 do
				c.pos.stackpos = i
				local tmp = getThingFromPos(c.pos)
				if tmp.itemid == item then
					table.insert(itemy, tmp)
				end
			end
		end
		if table.maxn(itemy) == 7 then
			for _, v in ipairs(itemy) do
				if doRemoveItem(v.uid, 1) == RETURNVALUE_NOTPOSSIBLE then
					return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "nie moze zabrac wszystkich itemow.")
				end
			end
			doCreateItem(2343, 1, c.pos)
			doSendMagicEffect(c.pos, CONST_ME_FIREAREA)
		else
			return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "nie ma wszystkich itemow.")
		end

	else
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Sorry, not possible.")
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
Próbowałem narazie z talkactionem czy zadziała, lecz funkcja wyświetla tylko itemid kratki, a nie czy itemid jakiś znajduje się na tej kratce.
Może źle użyłem funkcji, tutaj skrypt:

Code:
function onSay(cid, words, param)
	local pozycja = {x = 3022, y =2949, z = 6, stackpos = 1}
	local GETO = getTileInfo
	local itemek = 2470
	local kratka = 11859
	
	if getTileItemById(pozycja, kratka).itemid == itemek then
		doPlayerSendCancel(cid, "Lezy tam item ")
	elseif getTileItemById(pozycja, kratka).itemid ~= itemek then
		doPlayerSendCancel(cid, "NIE ma tam item, jest: " .. getTileItemById(pozycja, kratka).itemid .. "")
	else
		doPlayerSendCancel(cid, "Cos sie skrypt zjebal")
	end
	--[[
	if GETO(pozycja).itemid == itemek then
		doPlayerSendCancel(cid, "Lezy tam item ")
	elseif GETO(pozycja).itemid ~= itemek then
		doPlayerSendCancel(cid, "NIE ma tam item, jest: " .. getTileInfo(pozycja).itemid .. "")
	else
		doPlayerSendCancel(cid, "Cos sie skrypt zjebal")
	end
	]]--
	return true
end

Druga część jest zakomentowana, bo sprawdzałem też funkcją getTileInfo ;/
Próbowałem dawać pozycję ze stackposem i bez niego i taki sam efekt;/




Chyba jednak bez powtarzania pokolei sprawdzania stackposa nie da rady ;/
 
Użycie dla cicho ciemnych:
LUA:
//getTileItemById(pos, itemId[, subType = -1])
 
@Ralcoral
Super wkleiłeś mi funkcje, a jak próbowałem umieścić w itemid zamiast kratki itemid umieścić np. golden legi i warunek == TRUE lub FALSE to jakoś nie działało


@ andypsylon
// edit
@ andypsylon
Twój skrypt źle działa, można np. ułożyć 3 takie same części + 4 inne, a powinno być, że każda część inna
tzn
np.
kładziesz
2335 2336 2337 2338 2338 2338 2338 <--- nie powinno być 3x 2338, ale skrypt liczy to, a nie powinien ;/



//edit 2

Przerobiłem skrypt i teraz działa prawidłowo (robi HOTA gdy jest 7 różnych części HOTA, oraz usuwa tylko tych 7, jeśli np. jest jeszcze 3x Right Horn, to nie usuwa ich, ale jeśli np. jest tak, że jest np. 6x left horn + 1x helmet ornamet to returnuje, że nie mamy wszystkich części :)


Tutaj skrypt:

Code:
function onSay(cid, words, param)
local c = {
	items = {2335, 2336, 2337, 2338, 2339, 2340, 2341},
	pos = {x=3022,y=2949,z=6}
}
 
	local itemy = {}
	local itemySPIS = {}
		for _, item in ipairs(c.items) do
			for i = 0, 20 do
				c.pos.stackpos = i
				local tmp = getThingFromPos(c.pos)
				if tmp.itemid == item then
					if not(table.find(itemySPIS, tmp.itemid)) then
					table.insert(itemy, tmp.uid)
					table.insert(itemySPIS, tmp.itemid)
					end
				end
			end
		end
		for i = 1, #itemy do
		print(itemy[i])
		end
		if table.maxn(itemy) >= 7 then
			for _, v in ipairs(itemy) do
				if doRemoveItem(v, 1) == RETURNVALUE_NOTPOSSIBLE then
					return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "nie moze zabrac wszystkich itemow.")
				end
			end
			doCreateItem(2343, 1, c.pos)
			doSendMagicEffect(c.pos, CONST_ME_FIREAREA)
		elseif table.maxn(itemy) < 7 then
			return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Nie masz wszystkich czesci HOTA")
		else
			return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "nie ma wszystkich itemow.")
		end
	return true
	end

Zmodyfikowałem trochę wkładanie do tabeli itemy by wkładało uid pobranych ze stackposa i dodałem tabele itemsySPIS gdzie wkładają sie itemid
Jeśli skrypt zobaczy, że już w spisie itemsów było takie id, to nowego już nie doda, jeśli zobaczy, że nie ma takiego id, to doda do tabeli itemy jego uid, a do tabeli itemsySPIS itemid, skrypt działa :)


Ale nadal martwi mnie to sprawdzanie stackposów
Code:
for i = 0, 20 do
				c.pos.stackpos = i
By zastąpić to jakąś funkcją ;/
 
Last edited:
@diah heh, dzieki
@all poprawilem troche i zrobilem na movements. skrypt jest na ifa i wystarczy dodac nowa liste itemow na koncu 'c' i nagrode na koncu 'rew'
nie za bardzo chcialo mi sie testowac ;)
LUA:
local c = {
	{2335, 2336, 2337, 2338, 2339, 2340, 2341},
	{2342, 2147}
}
local rew = {4342, 4343}

function onAddItem(moveItem, tileItem, position, cid)

	for r, v in ipairs(c) do
		if isInArray(c[v], moveItem.itemid) then
			local itemy = {}
			for i = 1, #v do
				local tmp = getTileItemById(position, v[i])
				if tmp.itemid == v[i] then
					table.insert(itemy, tmp)
				end
			end
			if table.maxn(itemy) == #v then
				for _, q in ipairs(itemy) do
					if doRemoveItem(q.uid, 1) == RETURNVALUE_NOTPOSSIBLE then
						return false
					end
				end
				doCreateItem(rew[r], 1, position)
				doSendMagicEffect(position, CONST_ME_FIREAREA)
			end
			return true
		end
	end
	return false
end
 
Back
Top