Jump to content

Problem with dxDrawImage


Overkillz

Recommended Posts

Hey guys, I will like to make a "Toggle 3 different images"

status = 1 
function DaFvck() 
    if status==1 then 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala.png",0,0,0,tocolor(255,255,255,255)) 
        outputChatBox("lala1 Test", 255, 255, 255, true) 
        status = 2 
    elseif status==2 then 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala2.png",0,0,0,tocolor(255,255,255,255)) 
        outputChatBox("lala2 test", 255, 255, 255, true) 
        status = 3 
    else 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala3.png",0,0,0,tocolor(255,255,255,255)) 
        outputChatBox('lala3 Test', 255, 255, 255, true) 
        status = 1 
    end 
end 
addCommandHandler("logo", DaFvck) 

It works, but it dissapear in less than a second

I write ./logo and it show the new image and in the same moment hide it.

I hope u can help me.

Thanks

Link to comment

Use

addEventHandler -- With onClientRender 

Edit:

Try this.

function DaFvck() 
    if not status then 
        status = 1 
    end 
    if status == 1 then 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala.png",0,0,0,tocolor(255,255,255,255)) 
    elseif status == 2 then 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala2.png",0,0,0,tocolor(255,255,255,255)) 
    else 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala3.png",0,0,0,tocolor(255,255,255,255)) 
    end 
end 
addEventHandler("onClientRender", root, DaFvck) 
  
addCommandHandler("logo", function(cmd, amount) 
    if not amount then 
        outputChatBox("Use /logo ", 255, 20, 0) 
        return 
    end 
    amount = tonumber(amount) 
    if type(amount) ~= "number" then 
        outputChatBox("Amount type must be number!", 255, 20, 0) 
        return 
    end 
    if amount < 1 or amount > 3 then 
        outputChatBox("Amount must be between 1 and 3!", 255, 20, 0) 
        return 
    end 
    if status == amount then 
        outputChatBox("Your status is already "..amount.."!", 255, 20, 0) 
        return 
    end 
    status = amount 
    outputChatBox("Your new status is "..amount..".", 255, 168, 0) 
end) 

Edited by Guest
Link to comment
Use
addEventHandler -- With onClientRender 

Now it is changing every milisecond to the next image

f6ec2a00af.jpg

status = 1 
function DaFvck() 
    if status==1 then 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala.png",0,0,0,tocolor(255,255,255,255)) 
        outputChatBox("lala1 Test", 255, 255, 255, true) 
        status = 2 
    elseif status==2 then 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala2.png",0,0,0,tocolor(255,255,255,255)) 
        outputChatBox("lala2 test", 255, 255, 255, true) 
        status = 3 
    else 
        dxDrawImage(posx,posy*0.97,height,height, "img/lala3.png",0,0,0,tocolor(255,255,255,255)) 
        outputChatBox('lala3 Test', 255, 255, 255, true) 
        status = 1 
    end 
end 
addEventHandler ( "onClientRender", root, DaFvck) 
addCommandHandler("logo", DaFvck) 

PS: I changed the outputChatBox

Link to comment

Use this to change the status:

setTimer(function() 
    if (status > 2) then 
        status = 1 
    else 
        status = status + 1 
    end 
end, time-in-milliseconds, 0) 

This will change your image every second you fill in. 'onClientRender' will be executed on every FRAME, that's why it changes way too fast. (Don't forget to remove "status = ..." out of the function)

Link to comment
Use this to change the status:
setTimer(function() 
    if (status > 2) then 
        status = 1 
    else 
        status = status + 1 
    end 
end, time-in-milliseconds, 0) 

This will change your image every second you fill in. 'onClientRender' will be executed on every FRAME, that's why it changes way too fast. (Don't forget to remove "status = ..." out of the function)

But I won't change my image every second.

I want that the guys can change the image using /command

and the image don't change, just if they want, can use /command

That is the reason why I want to do 3 images toggeable.

Link to comment
function test(tCommand, tValue) 
    if (tonumber(tValue) ~= nil) and (tonumber(tValue) > 0) and (tonumber(tValue) <= 3) then 
        status = tonumber(tValue) 
    end 
end 
  
addCommandHandler("logo", test) 

If you read wiki you would have know this.

Then i should use variables

for example

local status = 1 (dxdrawimage....etc)

local status = 2 (dxdrawimage....etc)

local status = 3 (dxdrawimage....etc)

And after the code that u wrote ?

Sorry for my a lot of questions, I started with script few time ago ;(

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