Jump to content

وإيش فايدتها .. وليش موجودة أصلا ؟ getRootElement() & Sourceماهي الـ


xNight

Recommended Posts

السلام عليكم

عندي كثير أفكار

أحب أتعامل مع السكربتات بالـ " لوجيك "ـ

مثلا كود الألوان إلي موجود في 

MTA wiki

function onJoin()
         setPedArmor(source, 100)
         outputChatBox("Welcome To The Server", source, 255, 0, 0)
end
addEventHandler("onPlayerJoin", root, onJoin)

Sourceالـ

إيش تعني ؟ ماهي داخلة مخي

في مثال أخر موجود في

MTA wiki

function colouredChat ( message, theType )
	if theType == 0 then --if its normal chat (not /me or teamchat) then
		cancelEvent() --prevent MTA from outputting chat
		message = string.gsub(message, "#%x%x%x%x%x%x", "") --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour
		local chatterName = getPlayerName ( source ) --get his name
		--output a message with the name as his nametag colour, and the rest in white.
		outputChatBox ( chatterName..":#FFFFFF "..message, getRootElement(), r, g, b, true )
	end
end
addEventHandler("onPlayerChat", getRootElement(), colouredChat)

 في إثنين 

getRootElement

نفس السؤال  ... إيش فايدتها ؟ 

أتمنى أحد يفسرلي بكل وضوح

وشكرا

Link to comment
On 1/6/2018 at 06:38, xNight said:

السلام عليكم

عندي كثير أفكار

أحب أتعامل مع السكربتات بالـ " لوجيك "ـ

مثلا كود الألوان إلي موجود في 

MTA wiki


function onJoin()
         setPedArmor(source, 100)
         outputChatBox("Welcome To The Server", source, 255, 0, 0)
end
addEventHandler("onPlayerJoin", root, onJoin)

Sourceالـ

إيش تعني ؟ ماهي داخلة مخي

في مثال أخر موجود في

MTA wiki


function colouredChat ( message, theType )
	if theType == 0 then --if its normal chat (not /me or teamchat) then
		cancelEvent() --prevent MTA from outputting chat
		message = string.gsub(message, "#%x%x%x%x%x%x", "") --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour
		local chatterName = getPlayerName ( source ) --get his name
		--output a message with the name as his nametag colour, and the rest in white.
		outputChatBox ( chatterName..":#FFFFFF "..message, getRootElement(), r, g, b, true )
	end
end
addEventHandler("onPlayerChat", getRootElement(), colouredChat)

 في إثنين 

getRootElement

نفس السؤال  ... إيش فايدتها ؟ 

أتمنى أحد يفسرلي بكل وضوح

وشكرا

وعليكم السلام .
Source = هي المصدر للحدث 
ويختلف المصدر من حدث لآخر

فكمثال /:
المثال الاول : انت حطيت الحدث حق لما اللاعب يدخل 
أي ان المصدر بيكون اللاعب الي دخل ()
وبتقدر تعرف من هو المصدر من عبر الويكي ~>
 

getRootElement() = جميع الألمنتات او الكائنات في السيرفر
هذا لو تبي تجيب كل شيء في اللعبة من نوع الألمنت
بدون أستخدام اللوب (:
كمثال :
 

for _, player in ipairs ( getElementsByType ( 'player' ) ) do
	setElementHealth ( player, 100 )
end

تقدر تختصره بـ :
 

setElementHealth ( getRootElement ( ), 100 )

بس للمعلومية الكود الاول بيعطي لكل لاعب 100 صحة
والثاني بيعطي كل لاعب & مركبة & الخ 
100 صحة
 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...