GetProjectileTarget: Difference between revisions
Jump to navigation
Jump to search
m (Fixed various errors in example) |
No edit summary |
||
Line 14: | Line 14: | ||
Returns the element which is the projectile's target if the projectile is valid and a HS Rocket Projectile, ''false'' otherwise. | Returns the element which is the projectile's target if the projectile is valid and a HS Rocket Projectile, ''false'' otherwise. | ||
==Example== | |||
This example allows a player to send projectiles at other players | This example allows a player to send projectiles at other players | ||
<syntaxhighlight lang="lua">function projectileCreating(command,targetPlayer) | <syntaxhighlight lang="lua">function projectileCreating(command,targetPlayer) | ||
local x,y,z = getElementPosition(getLocalPlayer()) -- Get the position of the player | local x,y,z = getElementPosition(getLocalPlayer()) -- Get the position of the player |
Revision as of 13:08, 29 April 2011
This function returns the target of the specified projectile.
Syntax
element getProjectileTarget ( projectile theProjectile )
Required Arguments
- theProjectile: The projectile element which target you want to retrieve.
Returns
Returns the element which is the projectile's target if the projectile is valid and a HS Rocket Projectile, false otherwise.
Example
This example allows a player to send projectiles at other players
function projectileCreating(command,targetPlayer) local x,y,z = getElementPosition(getLocalPlayer()) -- Get the position of the player local target = getPlayerFromName(targetPlayer) or nil -- Get the target, or set it to nil if no target specified local theProjectile = createProjectile(thePlayer,20,x,y,z+50,1.0,target) if (target) then outputChatBox("Created projectile's target: "..getPlayerName(getProjectileTarget(theProjectile))) else outputChatBox("Created projectile with no target") end end addCommandHandler("rocket",projectileCreating) -- Bind the 'rocket' command to projectileCreating function