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

Zliczanie przedmiotów na ziemi

Aleh

Active Member
Joined
Jan 9, 2009
Messages
1,228
Reaction score
39
Location
Rzeszów
W jaki sposób moge zliczyć ile przedmiotów leży na danym pos.
Azi utworzył funkcje
LUA:
function getItemsCount(id, pos)
local count = 0
for i=0, 255 do
 pos.stackpos = i
 if(getThingFromPos(pos).itemid == id)then
  count+1
 end
end
return count
end
zliczy ile lezy przedmiotów. A co w tedy jak item będzie złączony np. jedzenie w jedno?
 
LUA:
function getItemsCount(id, pos)
	local count = 0
	for i = 0, 255 do
	
		pos.stackpos = i
		if(getThingFromPos(pos).itemid == id) then
			count + 1
		end
		
	end
	return count
end
Wytabowane ładniej wygląda, chociaż nie wiem czy do końca dobrze.
 
Last edited:
#up
zmienną definiujesz lokalnie przed funkcją ? gz.

#temat
trzeba policzyć "charges"...
PHP:
function getItemsCount(id, pos)
   local count = 0
	for i = 0, 255 do
		pos.stackpos = i
		local item = getThingFromPos(pos)
		if(item.itemid == id) then
			count = count + (isStackable(item.uid) and item.type or 1)
 		end
 
	end
	return count
end
 
Last edited:
powinno być count+1? hahha no nie rozbawiaj mnie. właśnie tak było, ale nie zlicza itemów stackowanych. -,-
 
a tak, zwracam honor, powinno być, ale ta +1 mnie rozproszyła i nie skumałem, bo +1 nie powinno być: D
 
Hehe, zle troche napisalem, ale i tak powinien byc jeszcze tam check czy item jest "stackable", bo inaczej item.type bedzie zwracal glupoty w przypadku itemow jak stary vial czy plama wody itd. :P
 
dobra, dodałem, dlatego wczesniej zrobiłem z getItemAttribute, za co też mnie zjebałeś... ;d
 
Back
Top