Jump to content

dxdrawimage For Any Image In Resource


Recommended Posts

Well I Get A Unexpected .. Which i understand why its there because i put the .. image .. there

ClientSide

-- Image Drawing  
  
function drawimage(image) 
    local screenWidth,screenHeight = guiGetScreenSize() 
    dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, ..image.. , 0, -120 ) 
end 
  
addEvent("drawImage", true) 
addEventHandler("drawImage" 
    function () 
        addEventHandler("onClientRender",root,drawimage) 
end 
) 
  
addEvent("removeImage",true) 
addEventHandler("removeImage",root, 
    function() 
        removeEventHandler("onClientRender",root,drawimage) 
    end 
) 

Server Side

-- Image Drawing CMDs 
  
addCommandHandler("drawimage", 
    function(player) 
        triggerClientEvent("drawImage",player) 
    end 
) 
  
addCommandHandler("removeimage", 
    function(player) 
        triggerClientEvent("removeImage",player) 
    end 
) 
  

Link to comment

Yes, is because you put the "..image.." there. That argument needs the filepath of your image, as string.

dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, "images/my_image.jpg", 0, -120 ) 

Or, you can set a variable to store the path, but you will not use ".." before or later of variable:

local image = "images/my_image.jpg" 
dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, image, 0, -120 ) 

And do not forget: you must set the pathfile (of the image) in Meta.xml.

Link to comment
Yes, is because you put the "..image.." there. That argument needs the filepath of your image, as string.
dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, "images/my_image.jpg", 0, -120 ) 

Or, you can set a variable to store the path, but you will not use ".." before or later of variable:

local image = "images/my_image.jpg" 
dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, image, 0, -120 ) 

And do not forget: you must set the pathfile (of the image) in Meta.xml.

Stan i mean like dxdrawimage for multiple images without making multiple functions like so i could do /drawimage troll.jpg or /drawimage nyancat.jpg Like that

Link to comment
triggering to client should be like this :
  
triggerClientEvent(player,"drawImage",player) 
  

in yours it will trigger for every player in server .

What Your Saying Is Nothing To Do With What Im Saying, The Script Works Fine Its JUst That I Dont Want To Make Tons Of Functions To Load Images So I Just Want To Load It All In One So i Can Type /drawimage troll.jpg or /drawimage nyancat.jpg

Link to comment
Guest Guest4401

Client:

-- Image Drawing 
local image 
  
function drawimage() 
    local screenWidth,screenHeight = guiGetScreenSize() 
    dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, image , 0, -120 ) 
end 
  
addEvent("drawImage", true) 
addEventHandler("drawImage",root, 
    function (img) 
        image = img 
        addEventHandler("onClientRender",root,drawimage) 
    end 
) 
  
addEvent("removeImage",true) 
addEventHandler("removeImage",root, 
    function() 
        removeEventHandler("onClientRender",root,drawimage) 
    end 
) 

Server:

-- Image Drawing CMDs 
  
addCommandHandler("drawimage", 
    function(player,command,image) 
        triggerClientEvent("drawImage",player,image) 
    end 
) 
  
addCommandHandler("removeimage", 
    function(player) 
        triggerClientEvent("removeImage",player) 
    end 
) 

Type /drawimage imagelocation.png

Link to comment
Client:
-- Image Drawing 
local image 
  
function drawimage() 
    local screenWidth,screenHeight = guiGetScreenSize() 
    dxDrawImage ( screenWidth/2 - 50, 50, 500, 500, image , 0, -120 ) 
end 
  
addEvent("drawImage", true) 
addEventHandler("drawImage",root, 
    function (img) 
        image = img 
        addEventHandler("onClientRender",root,drawimage) 
    end 
) 
  
addEvent("removeImage",true) 
addEventHandler("removeImage",root, 
    function() 
        removeEventHandler("onClientRender",root,drawimage) 
    end 
) 

Server:

-- Image Drawing CMDs 
  
addCommandHandler("drawimage", 
    function(player,command,image) 
        triggerClientEvent("drawImage",player,image) 
    end 
) 
  
addCommandHandler("removeimage", 
    function(player) 
        triggerClientEvent("removeImage",player) 
    end 
) 

Type /drawimage imagelocation.png

What's the point having the command server-side? Why not simply make it client-side. Server doesn't need to know about the images being drawn. Unless you need to.

Link to comment
Guest Guest4401

I thought of the same, but I wasn't sure if he wanted to draw the image for every player or only for the one who types /drawimage.

Since his code seemed that he wants to display the image to everyone, I continued it.

Link to comment
I thought of the same, but I wasn't sure if he wanted to draw the image for every player or only for the one who types /drawimage.

Since his code seemed that he wants to display the image to everyone, I continued it.

i Did want it for everyone since only my admins know the command only they can do it

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