Jump to content

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


Recommended Posts

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

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 ) 

getElementParent حق الزر عن طريق وظيفة parentحق الصورة حسب الـ parentناقصك تحدد الـ

guiGetSize + guiGetPosition في وظيفة true يكون relativeيُفضل تخلي الـ +

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

  
    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

فـ نسيته Parent بالنسبة لـ .

@ Khalid.Mohammed : انسخ ذا الكود وبيضبط معاكـ بكل سكربت بدون اي تعديل !

local OrginalImage = "" --- الصورة الاصلية # 
local onEnter = "" --- عند دخول المؤشر # 
local onClick = "" --- عند الضغط على الصورة # 
  
addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
   for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
     local _x, _y = guiGetPosition ( guiElements, true ) 
     local _w,  _h = guiGetSize ( guiElements, true ) 
     replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false, getElementParent ( guiElements ) ) 
     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
فـ نسيته Parent بالنسبة لـ .

@ Khalid.Mohammed : انسخ ذا الكود وبيضبط معاكـ بكل سكربت بدون اي تعديل !

local OrginalImage = "" --- الصورة الاصلية # 
local onEnter = "" --- عند دخول المؤشر # 
local onClick = "" --- عند الضغط على الصورة # 
  
addEventHandler ( "onClientResourceStart", resourceRoot, function (    ) 
   for _,guiElements in ipairs ( getElementsByType ( "gui-button", resourceRoot ) ) do 
     local _x, _y = guiGetPosition ( guiElements, true ) 
     local _w,  _h = guiGetSize ( guiElements, true ) 
     replaceimage = guiCreateStaticImage( _x, _y, _w,  _h, OrginalImage, false, getElementParent ( guiElements ) ) 
     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

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