Jump to content

[HELP] few errors and warnings


Artenos

Recommended Posts

Hi guys I've been working on some holographic dxRectangles and basically what I'm trying to accomplish is to be able to create a holographic dxrectangle in front of a player whenever the function is triggered by using the command "/startholo", however I get a few errors and I was wondering if anyone could lend me a hand.

this are the warnings and the error I get:

WARNING: TGZHolo\TGH_Client.lua:7: Bad argument @ 'getElementPosition' [Expected element at argument 1, got string 'startholo'] 
  
WARNING: TGZHolo\TGH_Client.lua:8: Bad argument @ 'getPlayerRotation' [Expected element at argument 1, got string 'startholo'] 
  
ERROR: TGZHolo\TGZH_Client.lua:9: bad argument #1 to 'rad' (number expected, got boolean) 

here is the code:

local px, py = guiGetScreenSize() 
RTE_Demo = nil 
RTE_Holo = nil 
  
  
function RenderHolo( thePlayer, startedRes, command ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    local r = getPlayerRotation ( thePlayer ) 
    x = x - math.sin ( math.rad(r) ) * 20 
    y = y + math.cos ( math.rad(r) ) * 20 
    local holoscreen,RT_ID,RTE = exports.holo:createHoloScreen(x,y,z,20,0,90,1.35,2) --Create our holoscreen 
    setElementData(holoscreen,"interactive","aim") -- Make it interactive on user aim 
    if RTE then -- If we got the render Target of the screen then 
        RTE_Demo = RTE 
        RTE_Holo = holoscreen 
        addEventHandler ( "onHoloScrenRender", RTE_Holo,drawHoloDemo) -- Event handler for every render of the holo screen 
    end 
end 
  
  
function drawHoloDemo() 
    local width, height = dxGetMaterialSize(RTE_Demo) 
    dxSetRenderTarget(RTE_Demo,true) 
    -- 
    dxDrawRectangle(0, 0, px * 0.1179, py * 0.0807, tocolor(211, 211, 211, 66), false) 
    dxDrawRectangle(0, 0, px * 0.0198, py * 0.0807, tocolor(10, 190, 188, 255), false) 
    
    dxSetRenderTarget() 
end 
  
addCommandHandler ( "startholo", RenderHolo ) 

P.D: I'm not good at making titles :lol:

Link to comment
Hi guys I've been working on some holographic dxRectangles and basically what I'm trying to accomplish is to be able to create a holographic dxrectangle in front of a player whenever the function is triggered by using the command "/startholo", however I get a few errors and I was wondering if anyone could lend me a hand.

this are the warnings and the error I get:

WARNING: TGZHolo\TGH_Client.lua:7: Bad argument @ 'getElementPosition' [Expected element at argument 1, got string 'startholo'] 
  
WARNING: TGZHolo\TGH_Client.lua:8: Bad argument @ 'getPlayerRotation' [Expected element at argument 1, got string 'startholo'] 
  
ERROR: TGZHolo\TGZH_Client.lua:9: bad argument #1 to 'rad' (number expected, got boolean) 

here is the code:

local px, py = guiGetScreenSize() 
RTE_Demo = nil 
RTE_Holo = nil 
  
  
function RenderHolo( thePlayer, startedRes, command ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    local r = getPlayerRotation ( thePlayer ) 
    x = x - math.sin ( math.rad(r) ) * 20 
    y = y + math.cos ( math.rad(r) ) * 20 
    local holoscreen,RT_ID,RTE = exports.holo:createHoloScreen(x,y,z,20,0,90,1.35,2) --Create our holoscreen 
    setElementData(holoscreen,"interactive","aim") -- Make it interactive on user aim 
    if RTE then -- If we got the render Target of the screen then 
        RTE_Demo = RTE 
        RTE_Holo = holoscreen 
        addEventHandler ( "onHoloScrenRender", RTE_Holo,drawHoloDemo) -- Event handler for every render of the holo screen 
    end 
end 
  
  
function drawHoloDemo() 
    local width, height = dxGetMaterialSize(RTE_Demo) 
    dxSetRenderTarget(RTE_Demo,true) 
    -- 
    dxDrawRectangle(0, 0, px * 0.1179, py * 0.0807, tocolor(211, 211, 211, 66), false) 
    dxDrawRectangle(0, 0, px * 0.0198, py * 0.0807, tocolor(10, 190, 188, 255), false) 
    
    dxSetRenderTarget() 
end 
  
addCommandHandler ( "startholo", RenderHolo ) 

P.D: I'm not good at making titles :lol:

Use this code in that demo.lua, without exports. btw why u need to export.

local px, py = guiGetScreenSize() 
RTE_Demo = nil 
RTE_Holo = nil 
  
  
function RenderHolo( startedRes, command ) 
    local thePlayer = getLocalPlayer () 
    local x, y, z = getElementPosition ( thePlayer ) 
    local r = getPedRotation ( thePlayer ) 
    local holoscreen,RT_ID,RTE = createHoloScreen(x,y,z,20,0,90,1.35,2) --Create our holoscreen 
    setElementData(holoscreen,"interactive","aim") -- Make it interactive on user aim 
    if RTE then -- If we got the render Target of the screen then 
        RTE_Demo = RTE 
        RTE_Holo = holoscreen 
        addEventHandler ( "onHoloScrenRender", RTE_Holo,drawHoloDemo) -- Event handler for every render of the holo screen 
    end 
end 
  
  
function drawHoloDemo() 
    local width, height = dxGetMaterialSize(RTE_Demo) 
    dxSetRenderTarget(RTE_Demo,true) 
    -- 
    dxDrawRectangle(0, 0, px * 0.1179, py * 0.0807, tocolor(211, 211, 211, 66), false) 
    dxDrawRectangle(0, 0, px * 0.0198, py * 0.0807, tocolor(10, 190, 188, 255), false) 
    
    dxSetRenderTarget() 
end 
  
addCommandHandler ( "startholo", RenderHolo ) 

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