Forum

> > CS2D > Scripts > How to recognize IID for certain action issue
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to recognize IID for certain action issue

22 replies
Page
To the start Previous 1 2 Next To the start

old How to recognize IID for certain action issue

Mora
User Off Offline

Quote
Hello usnrealky softfarts.
I need a help with IID and actions when i use to these.

For example i spawned two P228 pistols:
The first ones IID would be P228-Cold
The second one IID would be P228-Hot
So, how can i recognize what kind of weapon is it by IID? And how can i use special things for each other P228?

Like if i firing with P228-Cold i spawn blue coloursmoke, then
i drop it and and spawn another P228, which is P228-Hot and firing with it cause red coloursmoke.

I remember in ...rp... flares had different functions when picked up them/ used them.
Can you, please, help me with?
EDIT:
Ayy, somebody?
Thanks.
edited 3×, last 26.11.17 12:27:36 pm

old Re: How to recognize IID for certain action issue

Masea
Super User Off Offline

Quote
@user Gaios: He actually asks how to get different situations by picking up items that have same item IDs(we use for cs2d lua cmd itemtype) at the same time.

Like there are 2 Glocks on the ground. When I pick the first one, I got healed but when I pick the second one, I got slapped.
edited 1×, last 26.11.17 02:47:38 pm

old Re: How to recognize IID for certain action issue

VADemon
User Off Offline

Quote
Code >

cs2d lua hook collect cs2d lua hook drop

iid (ItemID) is unique across a map. The iid is preserved when player picks up/drops the weapon. But you can't know with cs2d lua hook attack hook which ItemID the weapon has. Because cs2d lua cmd playerweapons returns a table with Weapon IDs, not the unique ItemIDs.

So all you need to do is to save the value of ItemID for the Weapon when player picks it up. So the next time this player fires with that weapon you know which exact ItemID he is carrying.

old Re: How to recognize IID for certain action issue

Mora
User Off Offline

Quote
Ohh c-mon guys. I already know how to do that.
Mora_rus has written
I meant if items being removed by game, when their floor time is expired

I meant fade out.
@user Joni And Friends: instead of spawnitem i use drop, when i have no problems with dropping? I need to SPAWN these items with spawnitem, otherwise i wont get them from anywhere. Drop hook is obvious to use when you ALREADY have such items and no problems with it.

no words about "equip". As user VADemon (and i knew it) said we dont have iid of weapons while carry. But equip doesnt provide any data etc.

//the whole problem is to spawn item. When cs2d free iids the new ones is added. So i can't use #items to store the last item spawned, because if once another item is removed for example between 9-11 in total 20 mine iid wont be 21 but 10. Maybe i can somehow get "ipairs" of items?
edited 2×, last 27.11.17 10:36:31 am

old Re: How to recognize IID for certain action issue

Mora
User Off Offline

Quote
So it might be 2 but not 3 .-.
Well, guys.. You can't understand me.
i have NO problems with "drop" hook. I dont need to disallow FADE OUT because item ids is stored nicely and i can pick up them aswell and have no problems with it...
The main problem is that i CAN'T SPAWN item and make it special(NOT RELATED TO DROP HOOK, NOT RELATED TO WEAPON I'M CARRY!!).. because if i make, for example function for that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
CW={
	[1]={
		NAME="P228 - Hot",
		WID=4,
		DMG=20
	},
	[2]={
		NAME="P228 - Cold",
		WID=4,
		DMG=10
	}
}

function MORA_MOD.SPAWN_CW(x,y,type)
	if not x then return end
	if not y then return end
	if not type then return end
	parse("spawnitem "..CW[type].WID.." "..x.." "..y)
end
The only thing i need it to make this item be special.. but i can't
table.insert()
with iid i dont know.
I cant use
return 2
in drop hook because i need items to be removed after time.

old Re: How to recognize IID for certain action issue

Mora
User Off Offline

Quote
Hey guys is okay i dont care about spawn this item but how can i register this item being removed? The problem is that when this item is being removed by game i can't nil this value in table.

I have idea. On drop i'll
return 2
for this item and maybe using timer when dropped it and delete this timer when i pick this weapon again(collect), if i pick no item the timer will remove caught iid stored as value or smth.
I'm bad with timers, how can i do the function through timer and free it nicely? Can do you help me?
edited 1×, last 30.11.17 09:25:40 am

old Re: How to recognize IID for certain action issue

Devil-Thanh
GAME BANNED Off Offline

Quote
when you spawn a new item, you can use
1
#item
to get its iid, I'm so sure about that. When a player pickup a weapon, that weapon will be removed from item(,"table") and when you drop it, it will be inserted at the end of the table!

old Re: How to recognize IID for certain action issue

Mora
User Off Offline

Quote
@user Devil-Thanh: Nope, as i mentioned before, when for example 3-rd item of for example 20 items is being removed, and then i spawn another weapon it will be 3, but not #lastitem. I thought to do that but i firstly checked.

I need to free timers depending on their iid and spawn them in that way. So is the only way to do. But as i point before i'm bad at them.

old Re: How to recognize IID for certain action issue

Devil-Thanh
GAME BANNED Off Offline

Quote
@user Mora: You're wrong, firstly check this
1
2
3
4
5
6
7
addhook("say","say")
function say()
	local it = item(0,"table")
	for k,v in pairs(it) do
		msg("#"..k.." id: "..v.." "..item(v,"name"))
	end
end

try to spawn some items then remove it, add some again and see how the table work (the different is k and v)

the iid is different from its place in item(0,"table")

let me make it clear, there're 2 values here, one called IID (item ID) and one called IK(item key)

the IID can be used in cs2d lua cmd item , but the IK is the thing that can be used to get the IID in item(0,"table")

they're 2 different values, you can't use IID for thing such as:
1
2
local it = item(0,"table")
something = it[IID]

but you can use the IK(key) to search for the IID by that way. Now when an item is spawned, its IID will be added at the end of item(0,"table") and you can get its IID by this way:
1
2
local it = item(0,"table")
new_iid = it[#it]
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview