Jump to content

dxDrawImage Problem


OnlineCheater

Recommended Posts

hey all,

I'm creating a picture in a function with dxDrawImage like for example:

-- FIRST SCRIPT name: "res"

-- both following functions are in the same client file

function dl() 
    dxDrawText("OK" blablablabla) 
    dxDrawImage(x, y, sx, sy blablabla) -- HERE 
end 
  

>> just added this bunch of code to pastebin http://pastebin.com/b2JGErNi

function Main(arg1, arg2) 
    addEventHandler("onClientRender", root, letsCreatePicture) 
    -- other stuff here 
end 

-- SECOND SCRIPT name: "res2"

-- server.lua 
local stuff = [[ 
local function transfer() 
     exports["res"]:Main(arg1, arg2) -- using first script's func 
     -- other stuff here 
end 
--more functions and codes 
]] 
addEvent("onClientAccept",true) 
addEventHandler("onClientAccept",root, 
function() 
    triggerLatentClientEvent(source,"onServerSend",100000,false,source,transfer) 
end) 

-- client.lua

triggerServerEvent("onClientAccept",getLocalPlayer()) 

RESULT:

I can only see my "OK" and not the image, the problem is not related to arguments, the whole syntax is fine and there's no error in debugscript... So can somebody tell me a way to draw that picture with this order ...

Also I've checked everything related to triggers and dxdrawimage on wiki... Still everything seem to be good

Thanks in advance!

Edited by Guest
Link to comment
If you can see the text but not the image, then the problem is most likely the arguments after all.

How and where are you defining x, y, sx and sy? Are you sure the filepath to the image is correct? Is the image in the meta.xml?

Trust me, I checked thousand of times what have I done, the function Main is exported, picture is in the meta, arguments are safe... I think it's a MTA bug, it can't handle onClientRender with this way.. too complicated for it to generate a picture?

Link to comment

Maybe your image is out of screen.

Well its not a mta bug. I've tested that.

Maybe you can find your mistake with my tested code (Picture is not included!)

Resource "res2":

meta.xml

<meta> 
    <script src = "c.lua" type = "client" /> 
    <file src = "pew.png" /> 
     
    <export function="Main" type = "client" /> 
</meta> 

c.lua

function renderPew() 
    dxDrawImage(500, 500, 200, 200, "pew.png") 
end 
--addEventHandler("onClientRender", root, renderPew) 
  
function Main(arg) 
    addEventHandler("onClientRender", root, renderPew) 
end 

---------------------------------

Resource "res":

meta.xml

<meta> 
    <script src = "c.lua" type = "client" /> 
</meta> 

c.lua

addCommandHandler("dude",  
    function() 
        exports["res2"]:Main() 
        outputChatBox('exports["res2"]:Main()') 
    end 
) 

Link to comment

Good job PewX but you inverted res and res2 on your quote, the code is ok but still there's no triggerLatentClientEvent in res2...

-- SECOND SCRIPT name: "res2"

-- server.lua 
local stuff = [[ 
local function transfer() 
     exports["res"]:Main(arg1, arg2) 
end ]] 
addEvent("onClientAccept",true) 
addEventHandler("onClientAccept",root, 
function() 
    triggerLatentClientEvent(source,"onServerSend",100000,false,source,transfer) 
end) 

-- client.lua

triggerServerEvent("onClientAccept",getLocalPlayer()) 

Link to comment

Ahahaha, ye.. now I know where your problem is. I failed to see your comment "server.lua" lel

But at first..

Good job PewX but you inverted res and res2 on your quote, the code is ok but still there's no triggerLatentClientEvent in res2...

Because it was just a test. I don't care about that.

You want to call (export) a clientsided exported function with a serversided script. This won't work lel. You have to use triggerClientEvent instead of exports.

Link to comment
You want to call (export) a clientsided exported function with a serversided script. This won't work lel. You have to use triggerClientEvent instead of exports.

Ye, once it's in the server side [[ ]], it transfers to the client side (in the res2).

Remember that dxDrawText works fine and it's a client function too...

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