SphereCommunity
Count All Item Region - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Count All Item Region (/Thread-Count-All-Item-Region)



Count All Item Region - xtronchox - 06-21-2020 10:02 PM

I am doing my own house management script, and I am stuck on fees, I would like to add the fee to be paid depending on the items in the house.

I have tried everything with foritem but I can not count only the items of the house owned. Someone gives me a hand?

PHP Code:
foritem <src.region>
ref1=0
if <region.type>==i_multi_house_patio_marble
ref1
=<ref1>+1
endif
ENDFOR
src.message The number of item is <eval(<ref1>)> 

I made this little code to test but nothing. I can not count only the multi item where I am


thanks!!


RE: Count All Item Region - Coruja - 06-23-2020 12:30 PM

The logic is correct, but you're just making some confusion when writting it on script

Code:
IF (<REGION.TYPE> == t_multi)
  LOCAL.Total=0
  FORITEMS 25  //search area = 25 tiles nearby
    IF (<REGION.UID> == <SRC.REGION.UID>)  //make sure the item is inside the same multi
      LOCAL.Total ++
    ENDIF
  ENDFOR
  SRC.MESSAGE The number of item is <dLOCAL.Total>
ENDIF