Forum

> > CS2D > Scripts > Item dissapearing
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Item dissapearing

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Item dissapearing

En-Kay
User Off Offline

Zitieren
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.

alt Re: Item dissapearing

Infinite Rain
Reviewer Off Offline

Zitieren
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)

alt Re: Item dissapearing

EngiN33R
Moderator Off Offline

Zitieren
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.

alt Re: Item dissapearing

En-Kay
User Off Offline

Zitieren
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!
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht