IsElementInWater: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 30: Line 30:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
Function which is triggered when the Player dies in the Water.


<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
Line 39: Line 41:
       local ped_X, ped_Y, ped_Z = getElementPosition()
       local ped_X, ped_Y, ped_Z = getElementPosition()
       if ped_Z then
       if ped_Z then
             outputChatBox(math.random(1, #deathMessage))
             outputChatBox(math.random(1, #deathMessage), 194, 84, 68)
             outputChatBox("#FF0000"..getPlayerName(playa).."#FFFFFF you died "..ped_Z.." feet´s under the Water", 255, 255, 255, true)
             outputChatBox("#FF0000"..getPlayerName(playa).."#FFFFFF you died "..ped_Z.." feet´s under the Water", 255, 255, 255, true)
       end
       end

Revision as of 19:12, 7 June 2010

This function checks whether an element is submerged in water.

Syntax

Click to collapse [-]
Server and client
bool isElementInWater ( element theElement )

Required Arguments

  • theElement: The element to check.

Returns

Returns true if the passed element is in water, false if it isn't, or if the element is invalid.

Example

Creates a command that checks if the player is in water or not.

Click to collapse [-]
Server

function waterCheck(thePlayer)
    if isElementInWater(thePlayer) then
        outputChatBox("Wet.", thePlayer)
    else
        outputChatBox("Dry.", thePlayer)
    end
end

addCommandHandler("check", waterCheck)

Function which is triggered when the Player dies in the Water.

Click to collapse [-]
Client
local deathMessage = { "Man over Board", "Wooops he failed into the water ?", "Wow im getting wet Honey", "He died in tha deep water" }

function p_Water(playa)
   if isElementInWater(thePlayer) then
       local ped_X, ped_Y, ped_Z = getElementPosition()
       if ped_Z then
            outputChatBox(math.random(1, #deathMessage), 194, 84, 68)
            outputChatBox("#FF0000"..getPlayerName(playa).."#FFFFFF you died "..ped_Z.." feet´s under the Water", 255, 255, 255, true)
       end
   end
end

addEventHandler("onClientPlayerWasted", getRootElement(), p_Water)

See Also