#kAsR Posted June 18, 2017 Posted June 18, 2017 سلام عليكم شباب انا جربت اسوي شيء بس ماظبط معاي ومافية اخطاء بالدي بوق local Functions = { [1] = { Button = join , Function = joinJob }, [2] = { Button = ex , Function = closeWindow }, [3] = { Button = leave , Function = leaveJob }, [4] = { Button = ex_1 , Function = closeWindow1 }, } addEventHandler("onClientGUIClick",resourceRoot,function() for index = 1 , #Functions do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "Function" ] () end end end )
^iiEcoo'x_) Posted June 18, 2017 Posted June 18, 2017 local Functions = { [1] = { Button = join , Function = joinJob }; [2] = { Button = ex , Function = closeWindow }; [3] = { Button = leave , Function = leaveJob }; [4] = { Button = ex_1 , Function = closeWindow1 }; } جرب سويه كذا ض
#Soking Posted June 18, 2017 Posted June 18, 2017 وش دا سطر 12 Functions [ index ] [ "Function" ] () ؟
Master_MTA Posted June 18, 2017 Posted June 18, 2017 50 minutes ago, #kAsR said: سلام عليكم شباب انا جربت اسوي شيء بس ماظبط معاي ومافية اخطاء بالدي بوق local Functions = { [1] = { Button = join , Function = joinJob }, [2] = { Button = ex , Function = closeWindow }, [3] = { Button = leave , Function = leaveJob }, [4] = { Button = ex_1 , Function = closeWindow1 }, } addEventHandler("onClientGUIClick",resourceRoot,function() for index = 1 , #Functions do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "Function" ] () end end end ) انت معرف الفنكشنات ذي اصلا؟
iMr.WiFi..! Posted June 18, 2017 Posted June 18, 2017 (edited) function Button1 ( ) outputChatBox ("1") end function Button2 ( ) outputChatBox ("2") end function Button3 ( ) outputChatBox ("3") end function Button4 ( ) outputChatBox ("4") end Buttons = { } Buttons[1] = guiCreateButton(50,50,20,20,"1",false) Buttons[2] = guiCreateButton(50,70,20,20,"2",false) Buttons[3] = guiCreateButton(50,80,20,20,"3",false) Buttons[4] = guiCreateButton(50,95,20,20,"4",false) Functions = { [1] = { Function = Button1 }, [2] = { Function = Button2 }, [3] = { Function = Button3 }, [4] = { Function = Button4 } } addEventHandler ( "onClientGUIClick",root, function ( ) for i = 1,#Functions do if source == Buttons[i] then Functions[i].Function( ) end end end ) ^ هذا مثال بسيط سويته لك جربه Edited June 18, 2017 by iMr.WiFi..!
Master_MTA Posted June 18, 2017 Posted June 18, 2017 (edited) 6 minutes ago, #kAsR said: ايه معرفها Functions = { [1] = { Button = join , myfun = joinJob }, [2] = { Button = ex , myfun = closeWindow }, [3] = { Button = leave , myfun = leaveJob }, [4] = { Button = ex_1 , myfun = closeWindow1 }, } addEventHandler("onClientGUIClick",resourceRoot,function() for index,v in pairs(Functions) do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "myfun" ] () break end end end ) جرب Edited June 18, 2017 by Master_MTA
Master_MTA Posted June 18, 2017 Posted June 18, 2017 1 minute ago, #kAsR said: كودك شغال بس ليه الكود حقي مو شغال ؟ ? اي كود يقلبي وضح حق وايفاي ولا من
#kAsR Posted June 18, 2017 Author Posted June 18, 2017 (edited) @Master_MTA نفس الشيء ماظبط كود واي فاي ظبط بس الكود حقك نفس مشكلتي Edited June 18, 2017 by #kAsR
Master_MTA Posted June 18, 2017 Posted June 18, 2017 Just now, #kAsR said: @Master_MTA نفس الشيء ماظبط Functions = { { join , joinJob }, { ex , closeWindow }, { leave , leaveJob }, { ex_1 , closeWindow1 }, } addEventHandler("onClientGUIClick",resourceRoot,function() for index,v in ipairs(Functions) do if ( source == Functions [ index ] [1 ] ) then Functions [ index ] [ 2 ] () break end end end ) جرب
^iiEcoo'x_) Posted June 18, 2017 Posted June 18, 2017 2 minutes ago, #kAsR said: @Master_MTA نفس الشيء ماظبط كود واي فاي ظبط بس الكود حقك نفس مشكلتي إتأكد من أرقيومنات الفنكشن الي حاطهن حق joinjob و closeWindows
#Soking Posted June 18, 2017 Posted June 18, 2017 Just now, #kAsR said: نفس الشيء ياماستر ماظبط ممكن افهم فكرتك الاول ؟
#kAsR Posted June 18, 2017 Author Posted June 18, 2017 فكرتي اني مسوي جدول فيه اسماء الازرار وكمان فيه اسم الوظيفة يعني لو ظغط زر بالجدول تتفعل الوظيفة حقت الزر
iMr.WiFi..! Posted June 18, 2017 Posted June 18, 2017 (edited) join = guiCreateButton(50,50,20,20,"1",false) ex = guiCreateButton(50,80,20,20,"2",false) leave = guiCreateButton(50,90,20,20,"3",false) ex_1 = guiCreateButton(50,105,20,20,"4",false) function joinJob ( ) outputChatBox ("join") end function closeWindow ( ) outputChatBox ("ex") end function leaveJob ( ) outputChatBox ("leave") end function closeWindow1 ( ) outputChatBox ("ex_1") end local Functions = { { Button = join , Function = joinJob }, { Button = ex , Function = closeWindow }, { Button = leave , Function = leaveJob }, { Button = ex_1 , Function = closeWindow1 } } addEventHandler("onClientGUIClick",resourceRoot, function() for i,v in ipairs (Functions) do if ( source == v[ "Button" ] ) then v[ "Function" ] ( ) end end end ) ^ جرب ذا + هذا مثال فقط عشان تفهم الفكرة Edited June 18, 2017 by iMr.WiFi..!
Master_MTA Posted June 18, 2017 Posted June 18, 2017 3 minutes ago, #kAsR said: فكرتي اني مسوي جدول فيه اسماء الازرار وكمان فيه اسم الوظيفة يعني لو ظغط زر بالجدول تتفعل الوظيفة حقت الزر حبيب قلبي مستحيل ما تظبط ترا الطريقتين اللي عطيتك صحيحتين راجع الفنكشنات اللي مسويها انت
iMr.WiFi..! Posted June 18, 2017 Posted June 18, 2017 Just now, #kAsR said: جربها انت وشوف ^ حقي اشتغل ؟
#kAsR Posted June 18, 2017 Author Posted June 18, 2017 @iMr.WiFi..! لأ لو سويت كوماند بأف 8 وحطيت الوظيفة يجي بس لو اظغط الزر مايجي والدي بق مايقول شيء
iMr.WiFi..! Posted June 18, 2017 Posted June 18, 2017 Just now, #kAsR said: @iMr.WiFi..! لأ لو سويت كوماند بأف 8 وحطيت الوظيفة يجي بس لو اظغط الزر مايجي والدي بق مايقول شيء مافهمتك وضح اكثر .. بجرب الكود حقي
^iiEcoo'x_) Posted June 18, 2017 Posted June 18, 2017 كودك زابط بس المشكلة منك شوف المثال ذا ع نفس كودك ! هذا خطأ ؟ function closeWindow1 ( wnd ) guiSetVisible ( wnd , false ) end local Functions = { [1] = { Button = join , Function = joinJob }, [2] = { Button = ex , Function = closeWindow }, [3] = { Button = leave , Function = leaveJob }, [4] = { Button = ex_1 , Function = closeWindow1 } } addEventHandler("onClientGUIClick",resourceRoot,function() for index = 1 , #Functions do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "Function" ] () end end end ) أما الصحيح فهذا function closeWindow1 ( wnd ) guiSetVisible ( wnd , false ) end local Functions = { [1] = { Button = join , Function = joinJob }, [2] = { Button = ex , Function = closeWindow }, [3] = { Button = leave , Function = leaveJob }, [4] = { Button = ex_1 , Function = closeWindow1 } } addEventHandler("onClientGUIClick",resourceRoot,function() for index = 1 , #Functions do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "Function" ] ( wnd2 ) end end end ) 1
#kAsR Posted June 18, 2017 Author Posted June 18, 2017 @iMr.WiFi..! ماعليش مشكور كودك ظبط 2 minutes ago, #_iMr.[E]coo said: كودك زابط بس المشكلة منك شوف المثال ذا ع نفس كودك ! هذا خطأ ؟ function closeWindow1 ( wnd ) guiSetVisible ( wnd , false ) end local Functions = { [1] = { Button = join , Function = joinJob }, [2] = { Button = ex , Function = closeWindow }, [3] = { Button = leave , Function = leaveJob }, [4] = { Button = ex_1 , Function = closeWindow1 } } addEventHandler("onClientGUIClick",resourceRoot,function() for index = 1 , #Functions do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "Function" ] () end end end ) أما الصحيح فهذا function closeWindow1 ( wnd ) guiSetVisible ( wnd , false ) end local Functions = { [1] = { Button = join , Function = joinJob }, [2] = { Button = ex , Function = closeWindow }, [3] = { Button = leave , Function = leaveJob }, [4] = { Button = ex_1 , Function = closeWindow1 } } addEventHandler("onClientGUIClick",resourceRoot,function() for index = 1 , #Functions do if ( source == Functions [ index ] [ "Button" ] ) then Functions [ index ] [ "Function" ] ( wnd2 ) end end end ) كودي صحيح بس مادري ليش مو راضي يشتغل بالنسبة للكود حقك سطر 16 ليه wnd2 ?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now