Forum

> > CS2D > Scripts > How to detect item amount in a tile?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to detect item amount in a tile?

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt How to detect item amount in a tile?

ReVoltage
User Off Offline

Zitieren
Hello us ,
I want to make a drop system, but i want to prevent too much item in a tile and make a player disconnected from server when pick it up.
I want to know, is it possible to detect amount of item in a tile? If it possible, please tell me how
Thx before.

Sorry if i had bad english.

alt Re: How to detect item amount in a tile?

Apache uwu
User Off Offline

Zitieren
Looping through the item list should suffice. cs2d lua cmd item.

There could be more than one item at a tile though, so you should account for that in your script:

Example of concept:

1
2
3
4
5
6
local itemlist=item(0,"table")
for _,id in ipairs(itemlist) do
    if item(id,"x")==TILE_X and item(id,"y")==TILEY then
        //item(id,"type") exists on TILE_X,TILE_Y
    end
end

alt Re: How to detect item amount in a tile?

ReVoltage
User Off Offline

Zitieren
@user Apache uwu: :Thank you very much, i will try to use the code
And i have 1 more question(I post it here, i dont want to make another thread)
Can i damage a NPC with a custom value (damageobject) WITHOUT objectdamage addhook? im trying using Hit addhook but its not work

alt Re: How to detect item amount in a tile?

Avo
User Off Offline

Zitieren
You can use object(0, "table") and use for loop to find certain NPC.

http://www.cs2d.com/help.php?luacat=object&luacmd=object hat geschrieben
1
2
3
4
local objectlist=object(0,"table")
for _,id in pairs(objectlist) do
   print(id)
end

alt Re: How to detect item amount in a tile?

ReVoltage
User Off Offline

Zitieren
I mean, like when you hit an NPC then damage the NPC with custom value. I trying use objectdamage and using parse damageobject (with return 1) but its cause LUA error (C stack overflow) in console every i hit the NPC

EDIT: I have a way to do this, but idk if it work or not. I still need help if this way not work.

EDIT2: Its work, my way work, thx all for help.
1× editiert, zuletzt 05.07.13 14:21:20
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht