GetProjectileCreator: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Added OOP syntax)
 
(10 intermediate revisions by 6 users not shown)
Line 7: Line 7:
element getProjectileCreator ( projectile theProjectile )
element getProjectileCreator ( projectile theProjectile )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[projectile]]:getCreator|creator}}


==Required Arguments==
===Required Arguments===
*'''theProjectile:''' The [[projectiles| projectile]] element which creator you want to retrieve.
*'''theProjectile:''' The [[projectiles| projectile]] element which creator you want to retrieve.


Line 15: Line 16:


==Example==
==Example==
This example tells the player who's the projectile creator that killed them.
 
<section name="Client" class="client" show="true">
This example will output a message in the chatbox saying who created
the projectile.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function killed(killer,weapon,bodypart)
addEventHandler("onClientProjectileCreation", root, function(projectile)
  if (weapon == 16 or 17 or 18 or 39) then
    local creator = getProjectileCreator(projectile)
      outputChatBox("Who killed you: "getProjectileCreator(weapon)".",100,0,0)
    if (getElementType(creator) == "player") then
  end
        local pName = getPlayerName(creator)
end
local projectileID = getProjectileType(projectile)
addEventHandler("onClientPedWasted",getRootElement(),killed)
        outputChatBox(pName.." created a projectile! (ID: "..projectileID..")", 255, 200, 0, false)
    end
end)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See also==
==See also==
{{Client projectile functions}}
{{Client projectile functions}}
[[it:getProjectileCreator]]

Latest revision as of 17:40, 26 November 2014

This function returns the creator of the specified projectile.

Syntax

element getProjectileCreator ( projectile theProjectile )

OOP Syntax Help! I don't understand this!

Method: projectile:getCreator(...)
Variable: .creator


Required Arguments

  • theProjectile: The projectile element which creator you want to retrieve.

Returns

Returns the element which created the projectile if successful, false otherwise.

Example

Click to collapse [-]
Client

This example will output a message in the chatbox saying who created the projectile.

addEventHandler("onClientProjectileCreation", root, function(projectile)
    local creator = getProjectileCreator(projectile)
    if (getElementType(creator) == "player") then
        local pName = getPlayerName(creator)
	local projectileID = getProjectileType(projectile)
        outputChatBox(pName.." created a projectile! (ID: "..projectileID..")", 255, 200, 0, false)
    end
end)

See also