Jump to content

onClientRender Use


Brad96

Recommended Posts

yes ,is necesary use the onClientRender with dxDraw functions ? because ...

    -- Draw zone name text. 
    dxDrawText ( playerZoneName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" )  
end 
  
function HandleTheRendering ( ) 
    addEventHandler ( "onClientRender", root, createText )  -- here work 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 

but

  
    dxDrawText ( playerZoneName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) 
end 
 -- here  dont work 
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) 
  
  

Link to comment

DX Drawings only draw for one frame. So if you try to draw it at the start of the script, or on resource start - it will only draw once and you'll barely be able to notice it.

onClientRender triggers whatever function it is attached to every frame, so whatever's in that function will be run 30-60 times a second.

Link to comment

try this my example

local sx,sy = guiGetScreenSize() 
local px,py = 1280,720 -- screen in HD 
local x,y =  (sx/px), (sy/py) 
  
function HUD () 
dxDrawText(playerZoneName, x*990, y*153, x*40, y*40, tocolor(255,255,255,255), 1,"pricedown",false,false,false,true) 
end 
addEventHandler("onClientRender", root, HUD) 

Link to comment

To update a text you can do something like this:

I made this example for you , didn't tested it , but it should work well :)

     theText = 'Status: Outside ColShape'     
            RadarArea(-336.51535, 1016.52850,380,200,255,255,255,150) 
            Area = ColShape.Rectangle(-336.51535, 1016.52850,380,200) 
             
             
            addEventHandler('onClientElementColShapeHit',resourceRoot, 
              function (matchingDimension) 
                if source.type == 'player' and source == localPlayer and matchingDimension then 
                theText = 'Status: in ColShape' 
            end 
        end) 
                              
             addEventHandler('onClientElementColShapeLeave',resourceRoot, 
               function (matchingDimension) 
                if source.type == 'player' and source == localPlayer and matchingDimension then 
                theText = 'Status: Outside ColShape'  
              end 
          end) 
                     
            
           function Render () 
                dxDrawText ( theText,44,screenHeight-43 screenWidth,screenHeight,tocolor(255,255,255,255),1,"pricedown") 
           end 
           addEventHandler('onClientRender',root,Render) 

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