Jump to content

[Help]dxDrawText


bebo1king

Recommended Posts

Posted

Hello , i am trying to make so simple mod but i got some problems

local screenW,screenH = guiGetScreenSize () 
  
  
addEventHandler( "onClientPlayerStuntStart", getRootElement( ), 
    function ( stuntType ) 
        --outputChatBox( "You started stunt: " .. stuntType ); 
    end 
); 
  
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), 
    function ( stuntType, stuntTime, distance ) 
        dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
    end 
); 

the problem is the dxDrawText is showing so fast then it disappear

Skype :bebo.ahmad34

My channel on youtupe :

https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos

Posted
Because you should use
"onClientRender" 

Event for Dx functions!

i see it same

addEventHandler ( "onClientRender", getRootElement( ), 
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), 
    function ( stuntType, stuntTime, distance ) 
        dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
    end 
)); 

Skype :bebo.ahmad34

My channel on youtupe :

https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos

Posted
  
addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), 
function() 
addEventHandler("onClientRender",root,lol) 
end 
) 
    function lol( stuntType, stuntTime, distance ) 
        dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
    end 
  

2vjs7it.jpg
Posted (edited)
addEventHandler( "onClientPlayerStuntFinish", root,function lol( stuntType, stuntTime, distance ) 
        dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
end 
     
function() 
addEventHandler("onClientRender",root,lol) 
end 
) 

now the proplem is line1 '(' is expected near lol

this script proplems more than lines :D

Edited by Guest

Skype :bebo.ahmad34

My channel on youtupe :

https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos

Posted

You forgot the parenthesis at the end of your function. I'd highly recommend you check out the Debugging section of the Wiki.

I'd argue against writing your code like that, and instead write it like this;

function ExampleCode(stuntType, stuntTime, distance) 
-- Code here 
end 
addEventHandler("onClientPlayerStuntFinish", root, ExampleCode) 

Personally I think it's much easier to read your own code when structured this way instead. :)

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

ok now there is no error but we will back to the main point i was asking help for is that

the problem is the dxDrawText is showing so fast then it disappear

the full code right now

local screenW,screenH = guiGetScreenSize () 
  
function lol(stuntType, stuntTime, distance) 
  dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
end 
addEventHandler("onClientPlayerStuntFinish", root, lol) 
     
function nothing () 
addEventHandler("onClientRender",root,lol) 
end 

Skype :bebo.ahmad34

My channel on youtupe :

https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos

Posted

Because this code is never executed;

function nothing () 
addEventHandler("onClientRender",root,lol) 
end 

Try this;

local screenW,screenH = guiGetScreenSize () 
  
function lol(stuntType, stuntTime, distance) 
  dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
end 
    
function nothing() 
    addEventHandler("onClientRender", root, lol) 
end 
addEventHandler("onClientPlayerStuntFinish", root, nothing) 

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted
Because this code is never executed;
function nothing () 
addEventHandler("onClientRender",root,lol) 
end 

Try this;

local screenW,screenH = guiGetScreenSize () 
  
function lol(stuntType, stuntTime, distance) 
  dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
end 
    
function nothing() 
    addEventHandler("onClientRender", root, lol) 
end 
addEventHandler("onClientPlayerStuntFinish", root, nothing) 

here is the error of your code

lua:4: attempt to concatnate local 'stunt'type (a nil value)

Skype :bebo.ahmad34

My channel on youtupe :

https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos

Posted

That's an error in your code, not mine.

Do you even read the error?

lua:4: attempt to concatnate local 'stunt'type (a nil value)

This means the error occurred at Line 4 in your code. The variable stuntType is returning a nil value - which means it's empty or doesn't exist.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Try this:

local screenW, screenH = guiGetScreenSize(); 
  
addEventHandler("onClientPlayerStuntFinish", getRootElement(), function(sty, sti, dis) 
    stuntType = sty; 
    stuntTime = sti; 
    distance = dis; 
    addEventHandler("onClientRender", getRootElement(), drawStunt); 
    setTimer( 
        removeEventHandler("onClientRender", getRootElement(), drawStunt) 
        stuntType = nil; 
        stuntTime = nil; 
        distance = nil; 
    end, 1000, 1); 
end); 
  
function drawStunt() 
    dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); 
end 

Resources I made:

Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!

 

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