Commands/Lua

Reference for console commands, Lua hooks and Lua commands in CS2D.

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Lua Hook itemfadeout

Categories

Parameters

  • iid: item id
  • type: item type
  • xpos: item x position (tiles)
  • ypos: item y position (tiles)

Info

When the droptimer of a dropped item reaches the value of mp_weaponfadeout (only in game modes which support item fade out).
In other words: When a dropped item is about to disappear with a fade out effect.

Weapon and item type IDs:
items

Note: This hook is only called before actually fading out an item. It is not called when item fade out is disabled or the game mode does not support item fade out.

Note: When returning 1 the droptimer value of the item will be set to 10000 to indicate that the item won't be faded out. The hook is not executed again for items with a droptimer of 10000.

Attention: When NOT returning 1 the item will be faded out DIRECTLY AFTER executing the hook. The item data won't be accessible any longer AFTER running the hook script!


Sample 1: Create explosion at item fadeout position
addhook("itemfadeout","itemfadeout")
function itemfadeout(iid, t, tileX, tileY)
   local x = tileX * 32 + 16
   local y = tileY * 32 + 16
   local size = 64
   local damage = 50
   local srcPlayer = 0
   parse("explosion "..x.." "..y.." "..size.." "..damage.." "..srcPlayer)
end


Sample 2: Entirely disable all item fadeouts
addhook("itemfadeout","noitemfadeout")
function noitemfadeout(iid, t, tileX, tileY)
   return 1
end

Return Values

  • 0: proceed normally (fade out the weapon)
  • 1: don't fade out the weapon (droptimer will be set to 10000)

Lua Command Lua Commands