Jump to content

fetchRemote [ ماتظهر الصورة ]


Recommended Posts

--client
addEventHandler("onClientGUIClick",resourceRoot,function (	)
	if ( source == show ) then
	triggerServerEvent("showimg",localPlayer)
		end
	end)
--server

addEvent( "showimg", true )
addEventHandler( "showimg", resourceRoot,
    function ( response )
fetchRemote("http://a.top4top.net/p_52221hhc1.jpg")
	if response ~= "ERROR" then
	triggerClientEvent("onClientGotImage", root, response )
		
		end
    
end)

--client
addEvent( "onClientGotImage", true )
addEventHandler( "onClientGotImage", resourceRoot,
    function( pixels )
        if myTexture then
            destroyElement( myTexture )
        end
        myTexture = dxCreateTexture( pixels )
    end
)

addEventHandler("onClientRender", root,
    function()
        if myTexture then
            local w,h = dxGetMaterialSize( myTexture )
            dxDrawImage( 200, 100, w, h, myTexture )
        end
    end
)
		

 

Link to comment

addEvent( "showimg", true )
addEventHandler( "showimg", resourceRoot,
    function (  )
		fetchRemote("http://a.top4top.net/p_52221hhc1.jpg", myCallback, "", false, source )
	end
)

function myCallback( responseData, errno, playerToReceive )
    if errno == 0 then
        triggerClientEvent( playerToReceive, "onClientGotImage", resourceRoot, responseData )
    end
end

 

  • Thanks 1
Link to comment
4 minutes ago, iMr.WiFi..! said:

addEvent( "showimg", true )
addEventHandler( "showimg", resourceRoot,
    function (  )
		fetchRemote("http://a.top4top.net/p_52221hhc1.jpg", myCallback, "", false, source )
	end
)

function myCallback( responseData, errno, playerToReceive )
    if errno == 0 then
        triggerClientEvent( playerToReceive, "onClientGotImage", resourceRoot, responseData )
    end
end

 

السطر الثاني استبدل resourceRoot ب root

Link to comment
8 minutes ago, iMr.WiFi..! said:

مافرقت لان احنا ما نستعمل السورس في الحالة ذي : (

انت جرب وبتعرف السبب :)

___

جرب المثال هذا وبتشوفه مابيشتغل لكن اذا استبدلت resourceRoot ب root بيشتغل :

-- #Client
addEventHandler ( 'onClientResourceStart', resourceRoot, function ( )
    triggerServerEvent ( 'k_OUT', localPlayer )
end )

-- #Server
addEvent ( 'k_OUT', true )
addEventHandler ( 'k_OUT', resourceRoot, function ( )
    outputChatBox ( 'Done', source )
end )

@iMr.WiFi..!

Edited by #,+( _xiRoc[K]; >
  • Thanks 1
Link to comment
22 minutes ago, #,+( _xiRoc[K]; > said:

gui فقط

لكن تقدر تاخذ الطريقة وتسويها لل dx

function centerWindow (center_window)
    local sx, sy = dxGetScreenSize()
    local windowW, windowH = dxGetSize(center_window, false)
    local x, y = (screenW - windowW) /2,(screenH - windowH) /2
    return dxSetPosition(center_window, x, y, false)
end

Like this huh?

Link to comment
11 minutes ago, Talis said:

function centerWindow (center_window)
    local sx, sy = dxGetScreenSize()
    local windowW, windowH = dxGetSize(center_window, false)
    local x, y = (screenW - windowW) /2,(screenH - windowH) /2
    return dxSetPosition(center_window, x, y, false)
end

Like this huh?

زي كذا, ولكن بشرط ان الفنكشنات dxGetSize, dxSetPosition

يكونون فنكشنات مفيدين, لأنه مافي فنكشن زي كذا

اذا تبي مثال بعطيك مثال كيف تسوي كذا

Link to comment

سويت لك الفنكشن عالسريع ادري في اشياء ناقصة لكن جرب :

local itemsTable = { };

function dxCreateWindow ( x, y, w, h, title, color, post )
    assert ( type ( x .. y .. w .. h ) == 'number', 'Bad Argument @dxCreateWindow, position error' )
    local title, color, post, elm = ( title and type ( title ) == 'string' ) or '', color or tocolor ( 255, 255, 255, 255 ), post or false, createElement ( 'newDX-WIN' )
    itemsTable [ elm ] = {
        x = x,
        y = y,
        w = w,
        h = h,
        color = color,
        post = post,
        title = title,
        visible = false
    }
    return elm
end

addEventHandler ( 'onClientElementDestroy', resourceRoot, function ( )
    if ( itemsTable [ source ] ) then itemsTable [ source ] = nil end return true
end )

function dxSetVisible ( d, b ) if ( itemsTable [ d ] ) then local b = b or itemsTable [ d ].visible itemsTable [ d ].visible = b return true end end
function dxGetVisible ( d ) return itemsTable [ d ].visible or false end
function dxSetPosition ( d, x, y ) if ( itemsTable [ d ] ) then itemsTable [ d ].x = x itemsTable [ d ].y = y return true end end
function dxGetPosition ( d ) return itemsTable [ d ].x, itemsTable [ d ].x end
function dxSetSize ( d, w, h ) if ( itemsTable [ d ] ) then itemsTable [ d ].w = w itemsTable [ d ].h = h return true end end
function dxGetSize ( d ) return itemsTable [ d ].w, itemsTable [ d ].h end
function centerWindow (center_window)
    local sx, sy = guiGetScreenSize()
    local windowW, windowH = dxGetSize(center_window)
    local x, y = (screenW - windowW) /2,(screenH - windowH) /2
    return dxSetPosition(center_window, x, y)
end

addEventHandler ( 'onClientRender', root, function ( )
    for k, v in ipairs ( getElementsByType 'newDX-WIN' ) do
        if ( itemsTable [ v ].visible ) then
            dxDrawRectangle ( itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].w, itemsTable [ v ].h, itemsTable [ v ].color, itemsTable [ v ].post )
            dxDrawText ( itemsTable [ v ].title, itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].x + itemsTable [ v ].w, itemsTable [ v ].y + 15, tocolor ( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center' )
        end
    end
end )

addEventHandler ( 'onClientResourceStart', root, function ( )
    wnd = dxCreateWindow ( 0, 0, 500, 500, 'Hello', tocolor ( 255, 0, 0, 255 ), false )
    centerWindow ( wnd )
    dxSetVisible ( wnd, true )
end )

 

Edited by #,+( _xiRoc[K]; >
Link to comment
7 minutes ago, #,+( _xiRoc[K]; > said:

سويت لك الفنكشن عالسريع ادري في اشياء ناقصة لكن جرب :


local itemsTable = { };

function dxCreateWindow ( x, y, w, h, title, color, post )
    assert ( type ( x .. y .. w .. h ) == 'number', 'Bad Argument @dxCreateWindow, position error' )
    local title, color, post, elm = ( title and type ( title ) == 'string' ) or '', color or tocolor ( 255, 255, 255, 255 ), post or false, createElement ( 'newDX-WIN' )
    itemsTable [ elm ] = {
        x = x,
        y = y,
        w = w,
        h = h,
        color = color,
        post = post,
        title = title,
        visible = false
    }
    return elm
end

addEventHandler ( 'onClientElementDestroy', resourceRoot, function ( )
    return itemsTable [ elm ] and itemsTable [ elm ] = nil
end )

function dxSetVisible ( d, b ) if ( itemsTable [ d ] ) then local b = b or itemsTable [ d ].visible itemsTable [ d ].visible = b return true end end
function dxGetVisible ( d ) return itemsTable [ d ].visible or false end
function dxSetPosition ( d, x, y ) if ( itemsTable [ d ] ) then itemsTable [ d ].x = x itemsTable [ d ].y = y return true end end
function dxGetPosition ( d ) return itemsTable [ d ].x, itemsTable [ d ].x end
function dxSetSize ( d, w, h ) if ( itemsTable [ d ] ) then itemsTable [ d ].w = w itemsTable [ d ].h = h return true end end
function dxGetSize ( d ) return itemsTable [ d ].w, itemsTable [ d ].h end
function centerWindow (center_window)
    local sx, sy = guiGetScreenSize()
    local windowW, windowH = dxGetSize(center_window)
    local x, y = (screenW - windowW) /2,(screenH - windowH) /2
    return dxSetPosition(center_window, x, y)
end

addEventHandler ( 'onClientRender', root, function ( )
    for k, v in ipairs ( getElementsByType 'newDX-WIN' ) do
        if ( itemsTable [ v ].visible ) then
            dxDrawRectangle ( itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].w, itemsTable [ v ].h, itemsTable [ v ].color, itemsTable [ v ].post )
            dxDrawText ( itemsTable [ v ].title, itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].x + itemsTable [ v ].w, itemsTable [ v ].y + 15, tocolor ( 255, 255, 255, 255 ), 1, 'default-bold', 'center', 'center' )
        end
    end
end )

addEventHandler ( 'onClientResourceStart', root, function ( )
    wnd = dxCreateWindow ( 0, 0, 500, 500, 'Hello', tocolor ( 255, 0, 0, 255 ), false )
    centerWindow ( wnd )
    dxSetVisible ( wnd, true )
end )

 

line 20 ( elm is nil )

  • Thanks 1
Link to comment
2 minutes ago, Talis said:

فيه خطأ في الدي بق ناقص ايند في سطر 20

مافي ايند ناقص يمكن انت نسخت الكود القديم

انا عدلته فوق

المهم انا عدلته اكثر وضفت اضافات وصلحت بعض الأخطاء

جرب :

local itemsTable = { };

function dxCreateWindow ( x, y, w, h, title, color, textColor, post )
    assert ( type ( x .. y .. w .. h ) ~= 'number', 'Bad Argument @dxCreateWindow, position error' )
    local title, color, post, textColor, elm = ( title and type ( title ) == 'string' ) and title or '', color or tocolor ( 255, 255, 255, 255 ), post or false, textColor or tocolor ( 255, 255, 255, 255 ), createElement ( 'newDX-WIN' )
    itemsTable [ elm ] = {
        x = x,
        y = y,
        w = w,
        h = h,
        color = color,
        post = post,
        title = title,
        textColor = textColor,
        visible = false
    }
    return elm
end

addEventHandler ( 'onClientElementDestroy', resourceRoot, function ( )
    if ( itemsTable [ source ] ) then itemsTable [ source ] = nil end return true
end )

function dxSetVisible ( d, b ) if ( itemsTable [ d ] ) then local b = b or itemsTable [ d ].visible itemsTable [ d ].visible = b return true end end
function dxGetVisible ( d ) return itemsTable [ d ].visible or false end
function dxSetPosition ( d, x, y ) if ( itemsTable [ d ] ) then itemsTable [ d ].x = x itemsTable [ d ].y = y return true end end
function dxGetPosition ( d ) return itemsTable [ d ].x, itemsTable [ d ].y end
function dxSetSize ( d, w, h ) if ( itemsTable [ d ] ) then itemsTable [ d ].w = w itemsTable [ d ].h = h return true end end
function dxGetSize ( d ) return itemsTable [ d ].w, itemsTable [ d ].h end
function centerWindow (center_window)
    local sx, sy = guiGetScreenSize()
    local windowW, windowH = dxGetSize(center_window)
    local x, y = (sx - windowW) /2,(sy - windowH) /2
    return dxSetPosition(center_window, x, y)
end

addEventHandler ( 'onClientRender', root, function ( )
    for k, v in ipairs ( getElementsByType 'newDX-WIN' ) do
        if ( itemsTable [ v ].visible ) then
            dxDrawRectangle ( itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].w, itemsTable [ v ].h, itemsTable [ v ].color, itemsTable [ v ].post )
            dxDrawRectangle ( itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].w, 20, tocolor ( 0, 0, 0, 255 ), itemsTable [ v ].post )
            dxDrawText ( itemsTable [ v ].title, itemsTable [ v ].x, itemsTable [ v ].y, itemsTable [ v ].x + itemsTable [ v ].w, itemsTable [ v ].y + 20, itemsTable [ v ].textColor, 1, 'default-bold', 'center', 'center' )
        end
    end
end )

addEventHandler ( 'onClientResourceStart', root, function ( )
    wnd = dxCreateWindow ( 0, 0, 500, 500, 'Hello', tocolor ( 255, 0, 0, 255 ), tocolor ( 255, 255, 255, 255 ), false )
    centerWindow ( wnd )
    dxSetVisible ( wnd, true )
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...