Jump to content

آختصار كود طويل


Recommended Posts

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

ي شبآب انا بسوي طريقة آستبدال الزر الى صوره

واذا الاعب اشر على الصور تتغير الى صوره آخرى واذا ضغط عليها تتغير الى صوره ثآلثه

لكن انا عندي فوق 20 زر ف صعبه آجلس احط لكل زر كود لحاله

مآفي طريقه استبدال الصوره بوآسطة الاسم .؟

Img2.png يبدلها الى img1.png مثلاَ يتحقق اذا الاعب لمس الصوره

Link to comment
ممكن توضح اكثر ..

تبي تبدلهم لـ صور .. ويوم يدخل المؤشر للصور ذي تجي صورة ثانية ! ؟ .. GUI تقصد مثلأ عندكـ ازرار

يب + اذا ضغط عليهم تتبدل الى صوره ثآلثه

Link to comment

جرب كذا ولا تنسى تحط اسم ومسار الصورة .. :

local OrginalImage = "" --- الصورة الاصلية # 
local onEnter = "" --- عند دخول المؤشر # 
local onClick = "" --- عند الضغط على الصورة # 
  
addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
   for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
     local _x, _y = guiGetPosition ( guiElements, false ) 
     local _w,  _h = guiGetSize ( guiElements, false ) 
     replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ) 
     if ( replaceimage ) then 
         guiSetAlpha ( guiElements, 0 ) 
         addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
            guiStaticImageLoadImage ( replaceimage, onEnter ) 
        end, false ) 
        addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
            guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
        end, false ) 
        addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
            guiStaticImageLoadImage ( replaceimage, onClick ) 
         end, false ) 
      end 
   end 
end ) 
Link to comment

سويت كذا ولا زبط

    local OrginalImage = "imgorg.png" 
    local onEnter = "imgenter.png"  
    local onClick = "imgclick.png"  
      
    addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
       for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
         local _x, _y = guiGetPosition ( guiElements, false ) 
         local _w,  _h = guiGetSize ( guiElements, false ) 
         replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ) 
         if ( replaceimage ) then 
             guiSetAlpha ( guiElements, 0 ) 
             addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onEnter ) 
            end, false ) 
            addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
            end, false ) 
            addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onClick ) 
             end, false ) 
          end 
       end 
    end ) 
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
GUIEditor.window[1] = guiCreateWindow(389, 223, 569, 467, "T Panel", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetAlpha(GUIEditor.window[1], 1.00) 
 guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1C78F2") 
GUIEditor.button[1] = guiCreateButton(197, 395, 188, 46, "T Now", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetVisible(GUIEditor.window[1],false)         
    end 
) 
bindKey("F5","down",function() 
if guiGetVisible(GUIEditor.window[1]) == true then 
guiSetVisible(GUIEditor.window[1],false) 
showCursor(false) 
else 
guiSetVisible(GUIEditor.window[1],true) 
showCursor(true) 
end end) 

Link to comment
سويت كذا ولا زبط
  
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {}, 
    label = {} 
} 
    local OrginalImage = "imgorg.png" 
    local onEnter = "imgenter.png"  
    local onClick = "imgclick.png"  
      
    addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
       for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
         local _x, _y = guiGetPosition ( guiElements, false ) 
         local _w,  _h = guiGetSize ( guiElements, false ) 
         replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ) 
         if ( replaceimage ) then 
             guiSetAlpha ( guiElements, 0 ) 
             addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onEnter ) 
            end, false ) 
            addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
            end, false ) 
            addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onClick ) 
             end, false ) 
          end 
       end 
    end ) 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
GUIEditor.window[1] = guiCreateWindow(389, 223, 569, 467, "T Panel", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetAlpha(GUIEditor.window[1], 1.00) 
 guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1C78F2") 
GUIEditor.button[1] = guiCreateButton(197, 395, 188, 46, "T Now", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetVisible(GUIEditor.window[1],false)         
    end 
) 
bindKey("F5","down",function() 
if guiGetVisible(GUIEditor.window[1]) == true then 
guiSetVisible(GUIEditor.window[1],false) 
showCursor(false) 
else 
guiSetVisible(GUIEditor.window[1],true) 
showCursor(true) 
end end) 

جرب

Link to comment
سويت كذا ولا زبط
  
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {}, 
    label = {} 
} 
    local OrginalImage = "imgorg.png" 
    local onEnter = "imgenter.png"  
    local onClick = "imgclick.png"  
      
    addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
       for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
         local _x, _y = guiGetPosition ( guiElements, false ) 
         local _w,  _h = guiGetSize ( guiElements, false ) 
         replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ) 
         if ( replaceimage ) then 
             guiSetAlpha ( guiElements, 0 ) 
             addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onEnter ) 
            end, false ) 
            addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
            end, false ) 
            addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onClick ) 
             end, false ) 
          end 
       end 
    end ) 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
GUIEditor.window[1] = guiCreateWindow(389, 223, 569, 467, "T Panel", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetAlpha(GUIEditor.window[1], 1.00) 
 guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1C78F2") 
GUIEditor.button[1] = guiCreateButton(197, 395, 188, 46, "T Now", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetVisible(GUIEditor.window[1],false)         
    end 
) 
bindKey("F5","down",function() 
if guiGetVisible(GUIEditor.window[1]) == true then 
guiSetVisible(GUIEditor.window[1],false) 
showCursor(false) 
else 
guiSetVisible(GUIEditor.window[1],true) 
showCursor(true) 
end end) 

جرب

نفس الشي

Link to comment

جرب

local OrginalImage = "" --- الصورة الاصلية # 
local onEnter = "" --- عند دخول المؤشر # 
local onClick = "" --- عند الضغط على الصورة # 
  
addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
   for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
     local _x, _y = guiGetPosition ( guiElements, false ) 
     local _w,  _h = guiGetSize ( guiElements, false ) 
     replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ,GUIEditor.window[1] ) 
     if ( replaceimage ) then 
         guiSetAlpha ( guiElements, 0 ) 
         addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
            guiStaticImageLoadImage ( replaceimage, onEnter ) 
        end, false ) 
        addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
            guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
        end, false ) 
        addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
            guiStaticImageLoadImage ( replaceimage, onClick ) 
         end, false ) 
      end 
   end 
end ) 

Link to comment
خل الكود حق زاحف بالنهاية

زبط , بس الصور ماتجي باللوحه تجي برا

استخدم كود حسن اللي يخلي كل شي مقاساته تجي على مقاس الشاشة

او سوي صور وريح راسك

المشكله آن الصوره ماتجي بالنافذه مره وحده ! مو ع المقاس

مدري آذا يلزم تغغرات بالكود , مثل اسم النافذه

Link to comment
تأكد من انك حاطط الصورة داخل اللوحة

يعني لما تسويها بالجي يو اي اديتور

لما تبي تحط الصورة

اضغط كلك يمين داخل اللوحة بعدين حط صورة

انا مآسويت صوره أصلاَ , مسوي زر , الكود يبدل الزر الى صوره

Link to comment

تفضل

شغال %100

  
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
GUIEditor.window[1] = guiCreateWindow(389, 223, 569, 467, "T Panel", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetAlpha(GUIEditor.window[1], 1.00) 
 guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1C78F2") 
GUIEditor.button[1] = guiCreateButton(197, 395, 188, 46, "T Now", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetVisible(GUIEditor.window[1],false)        
    end 
) 
  
  
  
    local OrginalImage = "imgorg.png" 
    local onEnter = "imgenter.png" 
    local onClick = "imgclick.png" 
     
    addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
       for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
         local _x, _y = guiGetPosition ( guiElements, false ) 
         local _w,  _h = guiGetSize ( guiElements, false ) 
         replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ,GUIEditor.window[1]) 
         if ( replaceimage ) then 
             guiSetAlpha ( guiElements, 0 ) 
             addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onEnter ) 
            end, false ) 
            addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
            end, false ) 
            addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onClick ) 
             end, false ) 
          end 
       end 
    end ) 
  
  
bindKey("F5","down",function() 
if guiGetVisible(GUIEditor.window[1]) == true then 
guiSetVisible(GUIEditor.window[1],false) 
showCursor(false) 
else 
guiSetVisible(GUIEditor.window[1],true) 
showCursor(true) 
end 
end) 

Edited by Guest
Link to comment
تفضل

شغال %100

  
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    button = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
GUIEditor.window[1] = guiCreateWindow(389, 223, 569, 467, "T Panel", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetAlpha(GUIEditor.window[1], 1.00) 
 guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF1C78F2") 
GUIEditor.button[1] = guiCreateButton(197, 395, 188, 46, "T Now", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetVisible(GUIEditor.window[1],false)        
    end 
) 
  
  
  
    local OrginalImage = "imgorg.png" 
    local onEnter = "imgenter.png" 
    local onClick = "imgclick.png" 
     
    addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
       for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
         local _x, _y = guiGetPosition ( guiElements, false ) 
         local _w,  _h = guiGetSize ( guiElements, false ) 
         replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ,GUIEditor.window[1]) 
         if ( replaceimage ) then 
             guiSetAlpha ( guiElements, 0 ) 
             addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onEnter ) 
            end, false ) 
            addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
            end, false ) 
            addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onClick ) 
             end, false ) 
          end 
       end 
    end ) 
  
  
bindKey("F5","down",function() 
if guiGetVisible(GUIEditor.window[1]) == true then 
guiSetVisible(GUIEditor.window[1],false) 
showCursor(false) 
else 
guiSetVisible(GUIEditor.window[1],true) 
showCursor(true) 
end 
end) 

مشششكور آشتغل , آششكر كل من شارك بالموضوع <3

#edit

آخوي ي ليت تقول وش سويت وآشتتغل , عشان استععمله على مودات اخرى

Edited by Guest
Link to comment

انا عدتلك على الكود يلي اعطاك اياه زاحف

  
    local OrginalImage = "imgorg.png" 
    local onEnter = "imgenter.png" 
    local onClick = "imgclick.png" 
    
    addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
       for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
         local _x, _y = guiGetPosition ( guiElements, false ) 
         local _w,  _h = guiGetSize ( guiElements, false ) 
         replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ,GUIEditor.window[1]) 
         if ( replaceimage ) then 
             guiSetAlpha ( guiElements, 0 ) 
             addEventHandler( "onClientMouseEnter", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onEnter ) 
            end, false ) 
            addEventHandler( "onClientMouseLeave", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, OrginalImage ) 
            end, false ) 
            addEventHandler( "onClientGUIClick", replaceimage, function (   ) 
                guiStaticImageLoadImage ( replaceimage, onClick ) 
             end, false ) 
          end 
       end 
    end ) 

شوف هاي

كانت هيك

replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false) 

سيوتها هيك

replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false ,GUIEditor.window[1]) 

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