guiStaticImageSetMovable
الوظيفة تحرك الصور مثل اللوحات العادية
function guiSetStaticImageMovable(Element,state)
if Element and state then
if getElementType ( Element ) == "gui-staticimage" and state == true or state == false then
setElementData(Element,'Movable',state)
end
end
end
addEventHandler( "onClientGUIMouseDown", getRootElement( ),
function ( btn, x, y )
if btn ~= "left" then return end
if not getElementData(source,'Movable') then return end
clickedElement = source;
local elementPos = { guiGetPosition( source, false ) };
offsetPos = { x - elementPos[ 1 ], y - elementPos[ 2 ] };
end
);
addEventHandler( "onClientGUIMouseUp", getRootElement( ),
function ( btn, x, y )
if btn ~= "left" then return end
clickedElement = nil;
end
);
addEventHandler( "onClientCursorMove", getRootElement( ),
function ( _, _, x, y )
if not clickedElement then return end
guiSetPosition( clickedElement, x - offsetPos[ 1 ], y - offsetPos[ 2 ], false );
end
);
مثال للطريقة
movable = guiCreateStaticImage(353, 318, 250, 188, ":guieditor/images/examples/mtalogo.png", false)
guiSetStaticImageMovable(movable,true) -- تتحرك
static = guiCreateStaticImage(819, 318, 250, 188, ":guieditor/images/examples/mtalogo.png", false)
guiSetStaticImageMovable(static,false) -- لا تتحرك