Jump to content

تصحيح كود


Stranger

Recommended Posts

السلام عليكم يا شباب الحين عندي مشكه في ذا الكود

انه اذا اخترت سياره اللون ما يشوفه الا انا بس

ابي ال

setVehicleColor 

لكل من يختار سياره يجي اللون الي حاطه انا

هو يجي لكل الناس بس ما يشوفه غيرهم

ابيه عام

  
local vehicles = {} 
                        
addEventHandler("Vehiclee", root, 
    function(model, state) 
        if(state == "Cars")then 
            if(isElement(vehicles client ]))then 
                destroyElement(vehicles[ client ]) 
                vehicles[ client ] = nil 
            vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
            end 
            warpPedIntoVehicle(client, vehicles[ client ]) 
        elseif(state == "[Manster]")then 
            if(isElement(vehicles[ client ]))then 
                destroyElement(vehicles[ client ]) 
                vehicles[ client ] = nil 
            end 
            x,y,z = getElementPosition(client) 
            vehicles[ client ] = createVehicle(model,x,y-1,z) 
            warpPedIntoVehicle(client, vehicles[ client ]) 
                        setVehicleColor(vehicles[ client ], 255, 0, 0 ) 
                        setVehiclePaintjob(vehicles[ client ], 0) 
                        end 
             end  
  end  
) 

Link to comment
مافهمت ايش تقصد بسالفه اللون

بس عموماً عندك اند زايد و ناقصك هذا

addEvent 

ادري انا حاط الكود ناقص

+

اللون يوم تختار سياره من اللوحه وتنزلها تشوف اللون احمر مثلا

بس غيرك يشوفه لون ثاني

كل ما تنزل سياره تشوفها لونها احمر انا ابيها كذا

بس ما يشوفها غيرك واحد ثاني يشوفها لون ثاني مثلا اخضر اصفر كذا يعني كل مره يشوف لون ثاني بس الي نزلها يشوف احمر بس

Link to comment

غريبة

ممكن تكون استخدمت الكود حق اللون بالكلينت

جرب استخدم هذا الكود

مره بالكلينت و مره بالسيرفر و شوف هل اللون نفسه ولا مختلف

getVehicleColor 

Link to comment
غريبة

ممكن تكون استخدمت الكود حق اللون بالكلينت

جرب استخدم هذا الكود

مره بالكلينت و مره بالسيرفر و شوف هل اللون نفسه ولا مختلف

getVehicleColor 

لا موب كلينت

مسويه سيرفر

Link to comment

جرب كذا يمكن يضبط .. ^_^

  
local vehicles = {} 
  
addEventHandler("Vehiclee", root, 
    function(model, state) 
        if( state == "Cars" )then 
        if( isElement(vehicles [ client ]) )then 
            destroyElement(vehicles[ client ]) 
            vehicles[ client ] = nil 
        end 
        vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
        warpPedIntoVehicle(client, vehicles[ client ]) 
        elseif( state == "[Manster]" )then 
        if( isElement(vehicles[ client ]) )then 
        destroyElement( vehicles[ client ] ) 
        vehicles[ client ] = nil 
        end 
        x,y,z = getElementPosition( client ) 
        vehicles[ client ] = createVehicle(model,x,y-1,z) 
        warpPedIntoVehicle(client, vehicles[ client ]) 
        setVehicleColor(vehicles[ client ], 255, 0, 0 ) 
      end 
  end 
) 
  

Link to comment

جرب كذا يمكن يضبط ..

^_^
  
local vehicles = {} 
  
addEventHandler("Vehiclee", root, 
    function(model, state) 
        if( state == "Cars" )then 
        if( isElement(vehicles [ client ]) )then 
            destroyElement(vehicles[ client ]) 
            vehicles[ client ] = nil 
        end 
        vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
        warpPedIntoVehicle(client, vehicles[ client ]) 
        elseif( state == "[Manster]" )then 
        if( isElement(vehicles[ client ]) )then 
        destroyElement( vehicles[ client ] ) 
        vehicles[ client ] = nil 
        end 
        x,y,z = getElementPosition( client ) 
        vehicles[ client ] = createVehicle(model,x,y-1,z) 
        warpPedIntoVehicle(client, vehicles[ client ]) 
        setVehicleColor(vehicles[ client ], 255, 0, 0 ) 
      end 
  end 
) 
  

انت الحين وش عدلت ما عدلت شي صح .. بس نقصت الاند

Link to comment
غريبة

ممكن تكون استخدمت الكود حق اللون بالكلينت

جرب استخدم هذا الكود

مره بالكلينت و مره بالسيرفر و شوف هل اللون نفسه ولا مختلف

getVehicleColor 

Link to comment

جرب كذا يمكن يضبط ..

^_^
  
local vehicles = {} 
  
addEventHandler("Vehiclee", root, 
    function(model, state) 
        if( state == "Cars" )then 
        if( isElement(vehicles [ client ]) )then 
            destroyElement(vehicles[ client ]) 
            vehicles[ client ] = nil 
        end 
        vehicles[ client ] = createVehicle(model, getElementPosition(client)) 
        warpPedIntoVehicle(client, vehicles[ client ]) 
        elseif( state == "[Manster]" )then 
        if( isElement(vehicles[ client ]) )then 
        destroyElement( vehicles[ client ] ) 
        vehicles[ client ] = nil 
        end 
        x,y,z = getElementPosition( client ) 
        vehicles[ client ] = createVehicle(model,x,y-1,z) 
        warpPedIntoVehicle(client, vehicles[ client ]) 
        setVehicleColor(vehicles[ client ], 255, 0, 0 ) 
      end 
  end 
) 
  

مشكووور لبى قلبك

Link to comment

طيب عندي طلب ثاني:$ ,, !!

    local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
      
    local marker = createMarker( 218.6, 1920.1, 17.6-1, 'cylinder', 0, 0, 0, 0, 0  ); 
    local marker2 = createMarker( 209.6, 1920.1, 17.6-1, 'cylinder', 0, 0, 0, 0, 0 ); 
      
    addEventHandler ( 'onClientRender', root, 
        function ( ) 
            local x, y, z = getCameraMatrix(); 
            local x1, y1, z1 = getElementPosition ( marker ); 
            local x2, y2, z2 = getElementPosition ( marker2 ); 
            local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
            local distance_2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
            if distance_1 <= gMaxDistance then 
                local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ); 
                if x1_ and y1_ then 
                    -- 
                    local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) ); 
                    local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff ); 
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                    scale = math.evalCurve( gMaxScaleCurve, scale ); 
                    local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                    dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                end 
            elseif distance_2 <= gMaxDistance then 
                local x2_, y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ); 
                if x2_ and y2_ then 
                    local scale = 1 / ( gScale * ( distance_2 / gMaxDistance ) ); 
                    local alpha = ( ( distance_2 - gAlphaDistance ) / gAlphaDiff ); 
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                    scale = math.evalCurve( gMaxScaleCurve, scale ); 
                    local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                    dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                end  
            end 
        end 
    ); 

وش الخطأ فيه

Link to comment
اذا ما عدلت كود بلاوي ,

فأن الخطأ في الماركرات حجمها 0 ما راح تظهر اظن ,

Alpha = 0 ما بيظهر اظن,

يب الكود مو حقي مدري حق بلاوي ولا لا لقيت الكود بدون صاحب !!

+

يب انا حاطها 0 عشان يطلع الكلام بس

Edit #

    local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
      
    local marker = createMarker( 218.6, 1920.1, 17.6-1, 'cylinder', 0, 0, 0, 0, 0  ); 
    local marker2 = createMarker( 209.6, 1920.1, 17.6-1, 'cylinder', 0, 0, 0, 0, 0 ); 
      
    addEventHandler ( 'onClientRender', root, 
        function ( ) 
            local x, y, z = getCameraMatrix(); 
            local x1, y1, z1 = getElementPosition ( marker ); 
            local x2, y2, z2 = getElementPosition ( marker2 ); 
            local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
            local distance_2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
            if distance_1 <= gMaxDistance then 
                local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ); 
                if x1_ and y1_ then 
                    -- 
                    local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) ); 
                    local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff ); 
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                    scale = math.evalCurve( gMaxScaleCurve, scale ); 
                    local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                    dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                end 
            elseif distance_2 <= gMaxDistance then 
                local x2_, y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ); 
                if x2_ and y2_ then 
                    local scale = 1 / ( gScale * ( distance_2 / gMaxDistance ) ); 
                    local alpha = ( ( distance_2 - gAlphaDistance ) / gAlphaDiff ); 
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                    scale = math.evalCurve( gMaxScaleCurve, scale ); 
                    local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                    dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                end  
            end 
        end 
    ); 
  
    function math.evalCurve( curve, input ) 
        if input < curve[ 1 ][ 1 ] then 
            return curve[ 1 ][ 2 ]; 
        end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
            end 
        end 
        return curve[ #curve ][ 2 ]; 
    end 
      
    function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
    end 

كذا بيطلع الكلام في ماركر واحد بس

Edited by Guest
Link to comment
الماركر حجمه 0 خليه 2 او اكثر وهو اصلا ما بيكون ظاهر ,

0 = Alpha لأن

   local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
      
    local marker = createMarker( 215.6, 1920.1, 17.6-1, 'cylinder', 2, 255, 0, 0, 170  ); 
    local marker2 = createMarker( 209.6, 1920.1, 17.6-1, 'cylinder', 2, 255, 0, 0, 170 ); 
      
    addEventHandler ( 'onClientRender', root, 
        function ( ) 
            local x, y, z = getCameraMatrix(); 
            local x1, y1, z1 = getElementPosition ( marker ); 
            local x2, y2, z2 = getElementPosition ( marker2 ); 
            local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
            local distance_2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
            if distance_1 <= gMaxDistance then 
                local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ); 
                if x1_ and y1_ then 
                    local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) ); 
                    local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff ); 
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                    scale = math.evalCurve( gMaxScaleCurve, scale ); 
                    local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                    dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                end 
            elseif distance_2 <= gMaxDistance then 
                local x2_, y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ); 
                if x2_ and y2_ then 
                    local scale = 1 / ( gScale * ( distance_2 / gMaxDistance ) ); 
                    local alpha = ( ( distance_2 - gAlphaDistance ) / gAlphaDiff ); 
                    alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                    scale = math.evalCurve( gMaxScaleCurve, scale ); 
                    local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                    local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                    dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                end 
            end 
        end 
    ); 
  
    function math.evalCurve( curve, input ) 
        if input < curve[ 1 ][ 1 ] then 
            return curve[ 1 ][ 2 ]; 
        end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
            end 
        end 
        return curve[ #curve ][ 2 ]; 
    end 
      
    function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
    end 

نفس المشكله الكلام في ماركر واحد

Link to comment

جرب ,

local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
    local marker = createMarker( 215.6, 1920.1, 17.6-1, 'cylinder', 2, 255, 0, 0, 0); 
    local marker2 = createMarker( 209.6, 1920.1, 17.6-1, 'cylinder', 2, 255, 0, 0, 0 ); 
      
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x1, y1, z1 = getElementPosition ( marker ); 
        local x2, y2, z2 = getElementPosition ( marker2 ); 
        local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
        local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
        local Dis = distance,distance2 
        if Dis <= gMaxDistance then 
            local x1_,y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ) 
            local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 
            if x1_ and y1_ and x2_ and y2_ then 
                local scale = 1 / ( gScale * ( Dis / gMaxDistance ) ); 
                local alpha = ( ( Dis - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
            end 
        end 
    end 
); 
  
    function math.evalCurve( curve, input ) 
        if input < curve[ 1 ][ 1 ] then 
            return curve[ 1 ][ 2 ]; 
        end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
            end 
        end 
        return curve[ #curve ][ 2 ]; 
    end 
      
function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
end 
Link to comment
جرب ,

local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
    local marker = createMarker( 215.6, 1920.1, 17.6-1, 'cylinder', 2, 255, 0, 0, 0); 
    local marker2 = createMarker( 209.6, 1920.1, 17.6-1, 'cylinder', 2, 255, 0, 0, 0 ); 
      
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x1, y1, z1 = getElementPosition ( marker ); 
        local x2, y2, z2 = getElementPosition ( marker2 ); 
        local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
        local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
        local Dis = distance,distance2 
        if Dis <= gMaxDistance then 
            local x1_,y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ) 
            local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 
            if x1_ and y1_ and x2_ and y2_ then 
                local scale = 1 / ( gScale * ( Dis / gMaxDistance ) ); 
                local alpha = ( ( Dis - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
            end 
        end 
    end 
); 
  
    function math.evalCurve( curve, input ) 
        if input < curve[ 1 ][ 1 ] then 
            return curve[ 1 ][ 2 ]; 
        end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
            end 
        end 
        return curve[ #curve ][ 2 ]; 
    end 
      
function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
end 

مشكور لبى قلبك

طيب اذا ضفت ماركر ثاني اعدل في هذي ولا لا ؟

    function math.evalCurve( curve, input ) 
        if input < curve[ 1 ][ 1 ] then 
            return curve[ 1 ][ 2 ]; 
        end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
            end 
        end 
        return curve[ #curve ][ 2 ]; 
    end 
      
function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
end 

Link to comment

انا الي سويته,

local x1, y1, z1 = getElementPosition ( marker ); 
local x2, y2, z2 = getElementPosition ( marker2 ); 
local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 

وعشان ما اسوي اكثر من شرط , سويت كذا,

local Dis = distance,distance2 

وضفت ,

local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 

وسويت التحقق مع الشرط الاساسي,

if x1_ and y1_ and x2_ and y2_ then 

وتضيف dxDrawText,

dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
Link to comment

طيب انا سويت كذا

ماضبط

local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
    local marker = createMarker( 218.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0  ); 
    local marker2 = createMarker( 209.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0 ); 
    local marker3 = createMarker( 200.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0 ); 
      
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x1, y1, z1 = getElementPosition ( marker ); 
        local x2, y2, z2 = getElementPosition ( marker2 ); 
        local x3, y3, z3 = getElementPosition ( marker3 ); 
        local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
        local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
        local distance3 = getDistanceBetweenPoints3D( x, y, z, x3, y3, z3 ); 
        local Dis = distance,distance2,distance3 
        if Dis <= gMaxDistance then 
            local x1_,y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ) 
            local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 
            local x3_,y3_ = getScreenFromWorldPosition( x3, y3, z3 + 0.95, 0.06 ) 
            if x1_ and y1_ and x2_ and y2_ and x3_ and y3_ then 
                local scale = 1 / ( gScale * ( Dis / gMaxDistance ) ); 
                local alpha = ( ( Dis - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x3_, y3_, x3_, y3_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
            end 
        end 
    end 
); 
  
    function math.evalCurve( curve, input ) 
        if input < curve[ 1 ][ 1 ] then 
            return curve[ 1 ][ 2 ][ 3 ]; 
        end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ 1 ][ 2 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2 alpha ); 
            end 
        end 
        return curve[ #curve ][ 2 ]; 
    end 
      
function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
end 

Link to comment

local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
    local marker = createMarker( 218.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0  ); 
    local marker2 = createMarker( 209.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0 ); 
    local marker3 = createMarker( 200.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0 ); 
      
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x1, y1, z1 = getElementPosition ( marker ); 
        local x2, y2, z2 = getElementPosition ( marker2 ); 
        local x3, y3, z3 = getElementPosition ( marker3 ); 
        local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
        local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
        local distance3 = getDistanceBetweenPoints3D( x, y, z, x3, y3, z3 ); 
        local Dis = distance,distance2,distance3 
        if Dis <= gMaxDistance then 
            local x1_,y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ) 
            local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 
            local x3_,y3_ = getScreenFromWorldPosition( x3, y3, z3 + 0.95, 0.06 ) 
            if x1_ and y1_ and x2_ and y2_ and x3_ and y3_ then 
                local scale = 1 / ( gScale * ( Dis / gMaxDistance ) ); 
                local alpha = ( ( Dis - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x3_, y3_, x3_, y3_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
            end 
        end 
    end 
); 
  
function math.evalCurve( curve, input ) 
    if input < curve[ 1 ][ 1 ] then 
        return curve[ 1 ][ 2 ]; 
    end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
        end 
    end 
        return curve[ #curve ][ 2 ]; 
end 
      
function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
end 
Link to comment
local g_screenX, g_screenY = guiGetScreenSize(); 
    local gScale = 0.3; 
    local gAlphaDistance = 25; 
    local gMaxDistance = 50; -- Max Distance 
    local gTextAlpha = 120; 
    local gTextSize = 1; 
    local gAlphaDiff = gMaxDistance - gAlphaDistance; 
    gScale = 1 / gScale * 800 / g_screenY; 
    local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; 
    local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; 
    local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; 
    local marker = createMarker( 218.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0  ); 
    local marker2 = createMarker( 209.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0 ); 
    local marker3 = createMarker( 200.64996, 1920.15149, 16.6406, 'cylinder', 2, 0, 0, 0, 0 ); 
      
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x1, y1, z1 = getElementPosition ( marker ); 
        local x2, y2, z2 = getElementPosition ( marker2 ); 
        local x3, y3, z3 = getElementPosition ( marker3 ); 
        local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
        local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
        local distance3 = getDistanceBetweenPoints3D( x, y, z, x3, y3, z3 ); 
        local Dis = distance,distance2,distance3 
        if Dis <= gMaxDistance then 
            local x1_,y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ) 
            local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 
            local x3_,y3_ = getScreenFromWorldPosition( x3, y3, z3 + 0.95, 0.06 ) 
            if x1_ and y1_ and x2_ and y2_ and x3_ and y3_ then 
                local scale = 1 / ( gScale * ( Dis / gMaxDistance ) ); 
                local alpha = ( ( Dis - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
                dxDrawText( "Cars", x3_, y3_, x3_, y3_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); 
            end 
        end 
    end 
); 
  
function math.evalCurve( curve, input ) 
    if input < curve[ 1 ][ 1 ] then 
        return curve[ 1 ][ 2 ]; 
    end 
        for idx = 2, #curve do 
            if input < curve[ idx ][ 1 ] then 
                local x1 = curve[ idx - 1 ][ 1 ]; 
                local y1 = curve[ idx - 1 ][ 2 ]; 
                local x2 = curve[ idx ][ 1 ]; 
                local y2 = curve[ idx ][ 2 ]; 
                local alpha = ( input - x1 ) / ( x2 - x1 ); 
                return math.lerp( y1, y2, alpha ); 
        end 
    end 
        return curve[ #curve ][ 2 ]; 
end 
      
function math.lerp( from, to, alpha ) 
        return from + ( to-from ) * alpha; 
end 

مشكور لبى قلبك

ادري اني تعتبك بس فيه مشكله ثانيه

اذا قربت من الماركر الكلام يختفي + اذا بعدت وتلف يمين ولا يسار يطلع ويختفي !!!

Link to comment

مدري وش المشكله,

ولكن جرب كرر,

addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x1, y1, z1 = getElementPosition ( marker ); 
        local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); 
        if distance <= gMaxDistance then 
            local x1_,y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ) 
            if x1_ and y1_ then 
                local scale = 1 / ( gScale * ( distance / gMaxDistance ) ); 
                local alpha = ( ( distance - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true );               
            end 
        end 
    end 
); 
  
addEventHandler ( 'onClientRender', root, 
    function ( ) 
        local x, y, z = getCameraMatrix( ); 
        local x2, y2, z2 = getElementPosition ( marker2 ); 
        local distance2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); 
        if distance2 <= gMaxDistance then 
            local x2_,y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ) 
            if x2_ and y2_ then 
                local scale = 1 / ( gScale * ( distance2 / gMaxDistance ) ); 
                local alpha = ( ( distance2 - gAlphaDistance ) / gAlphaDiff ); 
                alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); 
                scale = math.evalCurve( gMaxScaleCurve, scale ); 
                local textscale = math.evalCurve( gTextScaleCurve, scale ); 
                local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); 
                dxDrawText( "Cars", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true );               
            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...