Info ff script:dropitemcmd

From Fortress Forever Wiki
Revision as of 10:44, 12 May 2009 by Crazycarl (talk | contribs) (New page: ==info_ff_script:dropitemcmd(owner_entity)== Whenever a player uses the drop items command (''c'' by default), any item(s) he is carrying will fire this function. Within the scope of this...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

info_ff_script:dropitemcmd(owner_entity)

Whenever a player uses the drop items command (c by default), any item(s) he is carrying will fire this function. Within the scope of this callback, the keyword entity refers to the entity that fired the callback.

Example

function baseflag:dropitemcmd( owner_entity )
	if allowdrop == false then return end

	-- throw the flag
	local flag = CastToInfoScript(entity)
	flag:Drop(FLAG_RETURN_TIME, FLAG_THROW_SPEED)
	
	-- remove flag icon from hud
	local player = CastToPlayer( owner_entity )
	RemoveHudItem( player, flag:GetName() )

	self.status = 2
	self.carriedby = ""
	self.droppedlocation = player:GetLocation()
	self:refreshStatusIcons(flag:GetName())
	LogLuaEvent(player:GetId(), 0, "flag_thrown","flag_name",flag:GetName(), "player_origin", (string.format("%0.2f",player:GetOrigin().x) .. ", " .. string.format("%0.2f",player:GetOrigin().y) .. ", " .. string.format("%0.1f",player:GetOrigin().z) ), "player_health", "" ..player:GetHealth());
	
	-- clear the objective icon
	UpdateObjectiveIcon( player, nil )
end