Jump to content

: ) طلب فنكشن.


Guest

Recommended Posts

السلام عليكم ورحمة الله تعآلى وبركاتهه ..

كيفكم عساكم بخير

الحين انا سويت شيء تمام

ابي الصوت يظهر للكل ,
كل الي لقيتها من 

playSound
playSound3D

كلها كلنت ,
ياريت الي يعرف لا يبخل .

 

Link to comment
triggerClientEvent -- استخدم ترايقر عشان تحول كل اللاعبين لكلنت وتشغلهم الصوت

triggerClientEvent( players, eventName, players, [optional]soundPath ) -- بهذي الصيغة

 

----- سيرفر -------


function playSound ( player, soundPath, loop )

	if isElement(player) and getElementType(player) == "player" then
	
		if type(soundPath) == "string" then
		
			triggerClientEvent(player, "onPlaySound", player, soundPath, loop)
			
		else
		
			return false
			
		end
		
	else
	
		return false
		
	end
	
end








function playSoundForPlayers(soundPath, loop)
	
	local players = getElementsByType("player")
	
	for _, player in ipairs ( players ) do
	
		playSound( player, soundPath, loop )
		
	end
	
end




----- كلنت -----




addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(source, soundPath, loop)
      
		else
      
      			playSound(source, soundPath)
      
      		end
		
	end
	
)

 

Edited by NX_CI
Link to comment
32 minutes ago, NX_CI said:

triggerClientEvent -- استخدم ترايقر عشان تحول كل اللاعبين لكلنت وتشغلهم الصوت

triggerClientEvent( players, eventName, players, [optional]soundPath ) -- بهذي الصيغة

 


----- سيرفر -------


function playSound ( player, soundPath, loop )

	if isElement(player) and getElementType(player) == "player" then
	
		if type(soundPath) == "string" then
		
			triggerClientEvent(player, "onPlaySound", player, soundPath, loop)
			
		else
		
			return false
			
		end
		
	else
	
		return false
		
	end
	
end








function playSoundForPlayers(soundPath, loop)
	
	local players = getElementsByType("player")
	
	for _, player in ipairs ( players ) do
	
		playSound( player, soundPath, loop )
		
	end
	
end




----- كلنت -----




addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(source, soundPath, loop)
      
		else
      
      			playSound(source, soundPath)
      
      		end
		
	end
	
)


 

الحين أبي لو اضغط زر ع طول , !_!.

تجي اغنية.

Link to comment

فهمت يعني تبي تضغط زر وتشغل لكل اللاعبين

 

sounds={}



function playSound ( player, soundPath, loop )

	if isElement(player) and getElementType(player) == "player" then
	
		if type(soundPath) == "string" then
		
			triggerClientEvent(player, "onPlaySound", player, soundPath, loop)
			
		else
		
			return false
			
		end
		
	else
	
		return false
		
	end
	
end








function playSoundForPlayers(soundPath)
	
	local players = getElementsByType("player")
	
	for _, player in ipairs ( players ) do
	
		playSound( player, soundPath )
		
	end
	
end




addEvent("triggerServer",true)

addEventHandler("triggerServer", root,

	function(soundPath)
	
		playSoundForPlayers(soundPath)
		
	end
	
)



----- كلنت -----




addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(source, soundPath, loop)
      
		else
      
      		playSound(source, soundPath)
      
      	end
		
	end
	
)







function onClickButton()

	if source == GUIEditor.button[1] then -- بدل اسم الزر للزر اللي عندك
	
		soundPath = "example.mp3" -- مسار الصوت يوم تضغط على الزر
		triggerServerEvent("triggerServer", localPlayer, soundPath)
		
	end
	
)


addEventHandler("onClientGUIClick", root, onClickButton)

 

Link to comment
1 hour ago, NX_CI said:

فهمت يعني تبي تضغط زر وتشغل لكل اللاعبين

 


sounds={}



function playSound ( player, soundPath, loop )

	if isElement(player) and getElementType(player) == "player" then
	
		if type(soundPath) == "string" then
		
			triggerClientEvent(player, "onPlaySound", player, soundPath, loop)
			
		else
		
			return false
			
		end
		
	else
	
		return false
		
	end
	
end








function playSoundForPlayers(soundPath)
	
	local players = getElementsByType("player")
	
	for _, player in ipairs ( players ) do
	
		playSound( player, soundPath )
		
	end
	
end




addEvent("triggerServer",true)

addEventHandler("triggerServer", root,

	function(soundPath)
	
		playSoundForPlayers(soundPath)
		
	end
	
)



----- كلنت -----




addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(source, soundPath, loop)
      
		else
      
      		playSound(source, soundPath)
      
      	end
		
	end
	
)







function onClickButton()

	if source == GUIEditor.button[1] then -- بدل اسم الزر للزر اللي عندك
	
		soundPath = "example.mp3" -- مسار الصوت يوم تضغط على الزر
		triggerServerEvent("triggerServer", localPlayer, soundPath)
		
	end
	
)


addEventHandler("onClientGUIClick", root, onClickButton)

 

سلمت يمناك يا بطل , ! 

Link to comment
1 minute ago, NX_CI said:

الله يسلمك , كويس انه اشتغل انا ماجربته

addEventHandler("onPlayerChat", root , 
function ()
if type == 0 then
cancelEvent()
end)

صحيح ؟ 

Link to comment
Just now, NX_CI said:

type == 0 Wrong !

type مش معرفة الـ


addEventHandler("onPlayerChat", root , 
function (_, type)
if type == 0 then
cancelEvent()
end)

 

, تسلم

+

WARNING: Test\Client.lua:44: Bad argument @ 'playSound' [Expected string at argument 1, got player]

 

ذا جاني بعد ما سويت كودك وسويت كلشيء .

2 minutes ago, NX_CI said:

type == 0 Wrong !

type مش معرفة الـ


addEventHandler("onPlayerChat", root , 
function (_, type)
if type == 0 then
cancelEvent()
end)


 

addEventHandler("onPlayerChat", root , 
function (_, type)
if type == 0 then
cancelEvent()
end)
--- ما ضبط , يجيني أكتب عادي !!


 

Link to comment

الخطأ في الكلنت

 

 

تحديدا هنا

 

استبدل ذي بالسابقة


addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(soundPath, loop)
      
		else
      
      		playSound(soundPath)
      
      	end
		
	end
	
)

 

8 minutes ago, *AnGeL said:

, تسلم

+

WARNING: Test\Client.lua:44: Bad argument @ 'playSound' [Expected string at argument 1, got player]

 

ذا جاني بعد ما سويت كودك وسويت كلشيء .


addEventHandler("onPlayerChat", root , 
function (_, type)
if type == 0 then
cancelEvent()
end)
--- ما ضبط , يجيني أكتب عادي !!


 

انت حاط كود الشات في السيرفر ولا كلنت ؟ و عندك خطأ فيه اند ناقصه

Link to comment
2 minutes ago, NX_CI said:

الخطأ في الكلنت

 

 

تحديدا هنا

 

استبدل ذي بالسابقة


addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(soundPath, loop)
      
		else
      
      		playSound(soundPath)
      
      	end
		
	end
	
)


 

تمام إشتغلت يعطيك العافية

أسوي كذا لو ابي اطفي الصوت ؟ 

addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			stopSound(soundPath, loop)
      
		else
      
      		stopSound(soundPath)
      
      	end
		
	end
	
)

 

2 minutes ago, NX_CI said:

الخطأ في الكلنت

 

 

تحديدا هنا

 

استبدل ذي بالسابقة


addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(soundPath, loop)
      
		else
      
      		playSound(soundPath)
      
      	end
		
	end
	
)


 

++ حقت الشات ما زبطت : ( 

addEventHandler("onPlayerChat", root , 
function (_, type)
if type == 0 then
cancelEvent()
end
end
)

 

Link to comment
3 minutes ago, NX_CI said:

الخطأ في الكلنت

 

 

تحديدا هنا

 

استبدل ذي بالسابقة


addEvent("onPlaySound", true)



addEventHandler("onPlaySound", root,

	function(soundPath, loop)
	
   		if loop ~= nil and type(loop) ~= "string" then
      
			playSound(soundPath, loop)
      
		else
      
      		playSound(soundPath)
      
      	end
		
	end
	
)

 

انت حاط كود الشات في السيرفر ولا كلنت ؟ و عندك خطأ فيه اند ناقصه

ضايفهم ومسوي الكود في السيرفر .....

وجربته في الكلنت برضو ما ضبط

 

Link to comment
2 minutes ago, NX_CI said:

اذا تبي تطفي الصوت قلك

stopSound( sound )

 

لازم تحط بدال 

sound 

الصوت نفسه اللي تبي تطفيه يعني استخدم المتغيرات

playSound حط متغير للـ

function stopSound ( player, soundPath, loop )

	if isElement(player) and getElementType(player) == "player" then
	
		if type(sound) == "string" then
		
			triggerClientEvent(player, "onStopSound", player, sound, loop)
			
		else
		
			return false
			
		end
		
	else
	
		return false
		
	end
	
end 
-- تجي كذآ ؟ 
, -- تعال خاص أحسن ..

 

Link to comment

انت جبت العيد لول xD

تعال خاص

16 minutes ago, NX_CI said:

الحدث للسيرفر حبيبي مو للكلنت

تأكد  من ملف الميتا انك حاطه سيرفر

 

جرب كذا

 



function cancelNormalChat( _, messageType )

	if type ( messageType ) == 0 then
	
		cancelEvent(true)
		
	end
	
end



addEventHandler("onPlayerChat", root, cancelNormalChat)

 

 

 

الخطأ هنا ان

if type (messageType) == 0 then

 

لازم تتعدل لـ

 

if messageType == 0 then

 

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...