Jump to content

ابي مساعده في كود


Recommended Posts

ماني مجربه - جربه

local screenWidth, screenHeight = guiGetScreenSize() 
local x,y,z = getElementPosition(localPlayer) 
addEventHandler("onClientRender",getRootElement(),function() 
    local screenX, screenY = getScreenFromWorldPosition(x,y,z) 
    local xx,yy,zz = getCameraMatrix() 
    local distance = getDistanceBetweenPoints2D(xx,yy,z,y) 
    local scale = 1000 / screenWidth 
    local width = 80 / scale 
    dxDrawImage(screenX - width / 2, screenY - screenHeight / 10, width, 80, "imageName.png") 
end) 

Link to comment
addEventHandler("onClientRender",getRootElement(),function() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    local x,y,z = getElementPosition(localPlayer) 
    local screenX, screenY = getScreenFromWorldPosition(x,y,z) 
    local xx,yy,zz = getCameraMatrix() 
    local distance = getDistanceBetweenPoints2D(xx,yy,z,y) 
    local scale = 1000 / screenWidth 
    local width = 80 / scale 
    dxDrawImage(screenX - width / 2, screenY - screenHeight / 10, width, 80, "imageName.png") 
end) 

Link to comment

جرب ذا

addEventHandler("onClientRender",root, 
    function () 
        local cx,cy,cz = getCameraMatrix() 
        for i,player in ipairs(getElementsByType("player")) do 
            if ( player == localPlayer ) then return end 
            local px,py,pz = getElementPosition(player) 
            local bx,by,bz = getPedBonePosition(player,6) 
            local dis = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz) 
            local x,y = getScreenFromWorldPosition(bx,by,bz + 0.2) 
            if x and dis < 30 and isLineOfSightClear(cx,cy,cz,px,py,pz,true,false,false,true,false,false,false,localPlayer) then 
                dxDrawImage(x,y,x/2,y/2,"img.png") 
            end 
        end 
    end 
) 

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

Link to comment

اول شيء انت مستخدم في بعدين

getDistanceBetweenPoints2D( xx, yy, z, y ) 

و بعدين ترتيبك للارقمنت غلط

getDistanceBetweenPoints2D ( x1, y1, x2, y2 ) 
    -- x1: The X position of the first point 
   -- y1: The Y position of the first point 
   -- x2: The X position of the second point 
  -- y2: The Y position of the second point  

Link to comment

جرب ذآ احسن

local gScreenSize = { guiGetScreenSize( ) }; 
local gOffest = 0.4; 
local gIconWidth = 0.35 * gScreenSize[ 1 ]; 
local gHconHalfWidth = gIconWidth / 2; 
  
addEventHandler ( 'onClientRender', root, 
    function( ) 
        for _, players in ipairs( getElementsByType( 'player' ) ) do 
            while true do 
                if not isElementOnScreen( players ) then  
                    break 
                end 
                local headX, headY, headZ = getPedBonePosition( players, 8 ); 
                headZ = headZ + gOffest; 
                local absX, absY = getScreenFromWorldPosition ( headX, headY, headZ ); 
                if not absX or not absY then 
                    break 
                end 
                local camX, camY, camZ = getCameraMatrix( ); 
                if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, players ) then 
                    break 
                end 
                dxDrawImages( absX, absY, 'img.png', tocolor( 255, 255, 255, 255 ), getDistanceBetweenPoints3D( camX, camY, camZ, headX, headY, headZ ) ); 
                break 
            end 
        end 
    end 
) 
  
function dxDrawImages ( posX, posY, iconPath, color, distance ) 
    distance = 1 / distance; 
    dxDrawImage ( posX - gHconHalfWidth * distance, posY - gHconHalfWidth * distance, gIconWidth * distance, gIconWidth * distance, iconPath, 0, 0, 0, color, false ); 
end 

Link to comment
  
  
addEventHandler ( 'onClientGUIClick', getRootElement(), 
 function(button, state, absoluteX, absoluteY) 
 if ( source ==  B1 ) then  
        for _, players in ipairs( getElementsByType( 'player' ) ) do 
            while true do 
                if not isElementOnScreen( players ) then 
                    break 
                end 
                local headX, headY, headZ = getPedBonePosition( players, 8 ); 
                headZ = headZ + gOffest; 
                local absX, absY = getScreenFromWorldPosition ( headX, headY, headZ ); 
                if not absX or not absY then 
                    break 
                end 
                local camX, camY, camZ = getCameraMatrix( ); 
                if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, players ) then 
                    break 
                end 
                dxDrawImages( absX, absY, 'img/1.png', tocolor( 255, 255, 255, 255 ), getDistanceBetweenPoints3D( camX, camY, camZ, headX, headY, headZ ) ); 
                break 
            end 
        end 
        end 
        end 
        ) 
  

Link to comment
local gScreenSize = { guiGetScreenSize( ) }; 
local gOffest = 0.4; 
local gIconWidth = 0.35 * gScreenSize[ 1 ]; 
local gHconHalfWidth = gIconWidth / 2; 
  
function renderTheHeadImg( ) 
    for _, players in ipairs( getElementsByType( 'player' ) ) do 
        while true do 
            if not isElementOnScreen( players ) then 
                break 
            end 
            local headX, headY, headZ = getPedBonePosition( players, 8 ); 
            headZ = headZ + gOffest; 
            local absX, absY = getScreenFromWorldPosition ( headX, headY, headZ ); 
            if not absX or not absY then 
                break 
            end 
            local camX, camY, camZ = getCameraMatrix( ); 
            if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, players ) then 
                break 
            end 
            dxDrawImages( absX, absY, 'img/1.png', tocolor( 255, 255, 255, 255 ), getDistanceBetweenPoints3D( camX, camY, camZ, headX, headY, headZ ) ); 
            break 
        end 
    end 
end 
  
function dxDrawImages ( posX, posY, iconPath, color, distance ) 
    distance = 1 / distance; 
    dxDrawImage ( posX - gHconHalfWidth * distance, posY - gHconHalfWidth * distance, gIconWidth * distance, gIconWidth * distance, iconPath, 0, 0, 0, color, false ); 
end 
  
addEventHandler ( 'onClientGUIClick', guiRoot, 
    function( button, state, absoluteX, absoluteY ) 
        if ( source ==  B1 ) then 
            addEventHandler( 'onClientRender', root, renderTheHeadImg ); 
        end 
    end 
) 

اذا تبي تلغيهآ استخدم

removeEventHandler( 'onClientRender', root, renderTheHeadImg ); 

Link to comment

سويت تعديل بسيط اذا يبي يظهرها و يوخرها من نفس الزر

local gScreenSize = { guiGetScreenSize( ) }; 
local gOffest = 0.4; 
local gIconWidth = 0.35 * gScreenSize[ 1 ]; 
local gHconHalfWidth = gIconWidth / 2; 
  
function renderTheHeadImg( ) 
    for _, players in ipairs( getElementsByType( 'player' ) ) do 
        while true do 
            if not isElementOnScreen( players ) then 
                break 
            end 
            local headX, headY, headZ = getPedBonePosition( players, 8 ); 
            headZ = headZ + gOffest; 
            local absX, absY = getScreenFromWorldPosition ( headX, headY, headZ ); 
            if not absX or not absY then 
                break 
            end 
            local camX, camY, camZ = getCameraMatrix( ); 
            if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, players ) then 
                break 
            end 
            dxDrawImages( absX, absY, 'img/1.png', tocolor( 255, 255, 255, 255 ), getDistanceBetweenPoints3D( camX, camY, camZ, headX, headY, headZ ) ); 
            break 
        end 
    end 
end 
  
function dxDrawImages ( posX, posY, iconPath, color, distance ) 
    distance = 1 / distance; 
    dxDrawImage ( posX - gHconHalfWidth * distance, posY - gHconHalfWidth * distance, gIconWidth * distance, gIconWidth * distance, iconPath, 0, 0, 0, color, false ); 
end 
  
isShow = false 
addEventHandler ( 'onClientGUIClick', guiRoot, 
    function( button, state, absoluteX, absoluteY ) 
        if ( source ==  B1 ) then 
            if isShow then 
                removeEventHandler( 'onClientRender', root, renderTheHeadImg ); 
                isShow = false 
            else 
                addEventHandler( 'onClientRender', root, renderTheHeadImg ); 
                isShow = true 
            end 
        end 
    end 
) 

Link to comment
سويت تعديل بسيط اذا يبي يظهرها و يوخرها من نفس الزر
local gScreenSize = { guiGetScreenSize( ) }; 
local gOffest = 0.4; 
local gIconWidth = 0.35 * gScreenSize[ 1 ]; 
local gHconHalfWidth = gIconWidth / 2; 
  
function renderTheHeadImg( ) 
    for _, players in ipairs( getElementsByType( 'player' ) ) do 
        while true do 
            if not isElementOnScreen( players ) then 
                break 
            end 
            local headX, headY, headZ = getPedBonePosition( players, 8 ); 
            headZ = headZ + gOffest; 
            local absX, absY = getScreenFromWorldPosition ( headX, headY, headZ ); 
            if not absX or not absY then 
                break 
            end 
            local camX, camY, camZ = getCameraMatrix( ); 
            if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, players ) then 
                break 
            end 
            dxDrawImages( absX, absY, 'img/1.png', tocolor( 255, 255, 255, 255 ), getDistanceBetweenPoints3D( camX, camY, camZ, headX, headY, headZ ) ); 
            break 
        end 
    end 
end 
  
function dxDrawImages ( posX, posY, iconPath, color, distance ) 
    distance = 1 / distance; 
    dxDrawImage ( posX - gHconHalfWidth * distance, posY - gHconHalfWidth * distance, gIconWidth * distance, gIconWidth * distance, iconPath, 0, 0, 0, color, false ); 
end 
  
isShow = false 
addEventHandler ( 'onClientGUIClick', guiRoot, 
    function( button, state, absoluteX, absoluteY ) 
        if ( source ==  B1 ) then 
            if isShow then 
                removeEventHandler( 'onClientRender', root, renderTheHeadImg ); 
                isShow = false 
            else 
                addEventHandler( 'onClientRender', root, renderTheHeadImg ); 
                isShow = 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...