Forum

> > CS2D > Scripts > Item dissapearing
Forums overviewCS2D overview Scripts overviewLog in to reply

English Item dissapearing

3 replies
To the start Previous 1 Next To the start

old Item dissapearing

En-Kay
User Off Offline

Quote
Hi.I have made a simple script which drops ammo when someone dies.This is it:


addhook("kill","deathdrop")
function deathdrop(id,victim)
     parse("spawnitem 61 "..player(victim,"tilex").." "..player(victim,"tiley"))
end

Now i need to make ammo dissapear after 30 seconds because it never dissapears unless it is collected.Please help.

old Re: Item dissapearing

Infinite Rain
Reviewer Off Offline

Quote
I don't know if it's possible but:
You need to make a table of each ammo dropped.
then afte9r 30 secs, remove it from table and make it dissapear (parse command)

old Re: Item dissapearing

EngiN33R
Moderator Off Offline

Quote
I thought CS2D's native fadeout made ammo boxes disappear, too?..

No matter. The tricky part about this is that you remove items by their IDs, and we can't really know the ID of an item we spawned, so we'll have to improvise:
1
2
3
4
5
6
7
8
9
addhook("kill","deathdrop")
function deathdrop(id,victim)
     parse("spawnitem 61 "..player(victim,"tilex").." "..player(victim,"tiley"))
     for i=0,512 do --just in case
          if item(i,"type")==61 and item(i,"x")==player(victim,"tilex") and item(i,"y")==player(victim,"tiley") then --making sure it's the same ammo box that we want to get rid of, and not some other weapon or item
               timer(30000,"parse","removeitem "..i)
          end
     end
end

Also, for reading pleasure, please encase your code in
[code]
[/code] tags.

old Re: Item dissapearing

En-Kay
User Off Offline

Quote
Thank you for your help.I know this is stupid script,but I use it with classes.lua which has a hook that stops player from droping on death.I made this script to make something similar from team fortress classic in which players drop backpack,so i made it.And it works.Thanks again!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview