GetProjectileTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 15: Line 15:


==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">function projectileCreating(thePlayer,command,targetPlayer)
-- TODO
    local x,y,z = getElementPosition(thePlayer) -- 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)
    outputChatBox("Created projectile's target: "..getProjectileTarget(theProjectile),thePlayer)
end
addCommandHandler("rocket",projectileCreating) -- Bind the 'rocket' command to projectileCreating function
</syntaxhighlight>
</syntaxhighlight>



Revision as of 10:35, 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

function projectileCreating(thePlayer,command,targetPlayer)
    local x,y,z = getElementPosition(thePlayer) -- 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)
    outputChatBox("Created projectile's target: "..getProjectileTarget(theProjectile),thePlayer)
end
addCommandHandler("rocket",projectileCreating) -- Bind the 'rocket' command to projectileCreating function

See also