AR/setElementHealth

From Multi Theft Auto: Wiki
Revision as of 17:46, 9 February 2016 by Jaber (talk | contribs) (Created page with "{{Server client function}} __NOTOC__ هذه الوظيفة تعطي الالمنت او الشيئ دم . ==Syntax== <syntaxhighlight lang="lua"> bool setElementHealth ( element theElement,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

هذه الوظيفة تعطي الالمنت او الشيئ دم .

Syntax

bool setElementHealth ( element theElement, float newHealth )

OOP Syntax Help! I don't understand this!

Method: element:setHealth(...)
Variable: .health


Required Arguments

  • theElement: الالمنت او الشيئ الذي تريد اعطائه دم ويكون: شخص,سيارة,ابجكت.
  • newHealth: كمية الدم التي تريد اعطائها للالمنت او الشيئ .


Example

Click to collapse [-]
Server
function hpSlap ( sourcePlayer, command, targetPlayerName )
    --ان كان الاعب يملك خاصية السلاب
    if not hasObjectPermissionTo(sourcePlayer, "command.slap", false) then
        outputChatBox ( "You cannot use this command.", sourcePlayer )--كلام بالشات
        return false
    end
    --يجلب الاعب من اسمه
    local targetPlayer = getPlayerFromName ( targetPlayerName )
   
    if targetPlayer then
        --يقول بأنقاص 20 دم
        setElementHealth ( targetPlayer, getElementHealth(targetPlayer) - 20 )
    else
        
        outputChatBox ( "There is no player named " .. targetPlayerName .. "!", sourcePlayer )
    end
end
--عند كتابة "hpslap"
addCommandHandler ( "hpslap", hpSlap )

See Also