Jump to content

DX help


Voltex'GNR

Recommended Posts

Here is my code

  
local screenW, screenH = guiGetScreenSize() 
  
addEventHandler("onClientRender", root, 
    function() 
 dxDrawText("Updates", screenW  0.7891, screenH  0.7598, screenW  0.9187, screenH  0.8076, tocolor(255, 27, 27, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) 
    end 
) 
  

When I use this, this error comes

IDK why

')' expected near '0.7891

In this line

  
dxDrawText("Updates", screenW  0.7891, screenH  0.7598, screenW  0.9187, screenH  0.8076, tocolor(255, 27, 27, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) 
  

Link to comment

local col3 = createColSphere ( 1787.3724365234, 1608.2197265625, 6.734375, 1000 )

function onPlayerJoin(thePlayer)

isElementWithinColShape ( thePlayer, col3 )

end

addEvent("onColShapeHit")

addEventHandler ( "onColShapeHit", col3, onPlayerJoin )

I want trigger onColShape hit

this dxDraw

dxDrawText("Updates", screenW*0.7891, screenH*0.7598, screenW*0.9187, screenH*0.8076, tocolor(255, 27, 27, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)

get showen, I tried but I failed any one help me?

Link to comment

Like this ?

local col3 = createColSphere ( 1787.3724365234, 1608.2197265625, 6.734375, 1000 ) 
function onPlayerJoin(thePlayer) 
    if isElementWithinColShape ( thePlayer, col3 ) then 
        addEventHandler("onClientRender", getRootElement(), dxDraw) 
    end 
end 
addEvent("onColShapeHit") 
addEventHandler ( "onColShapeHit", col3, onPlayerJoin ) 
  
function dxDraw() 
    dxDrawText("Updates", screenW*0.7891, screenH*0.7598, screenW*0.9187, screenH*0.8076, tocolor(255, 27, 27, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) 
end 

Link to comment

Here's when a player join the server

All is client, do you want this on server side ?

local screenW, screenH = guiGetScreenSize() 
  
function onPlayerJoin() 
    local col3 = createColSphere ( 1787.3724365234, 1608.2197265625, 6.734375, 1000 ) 
    setTimer(function () 
      if isElementWithinColShape ( getLocalPlayer(), col3 ) then 
        addEventHandler("onClientRender", getRootElement(), dxDraw) 
      end 
    end, 50, 1) 
end 
addEvent("onClientResourceStart") 
addEventHandler ( "onClientResourceStart", getRootElement(), onPlayerJoin ) 
  
function dxDraw() 
    dxDrawText("Updates", screenW*0.7891, screenH*0.7598, screenW*0.9187, screenH*0.8076, tocolor(255, 27, 27, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) 
end 

Edited by Guest
Link to comment

I think I got you

-- Server Side:

function resourceStart() 
    local col3 = createColSphere ( 0, 0, 5, 3 ) 
    for _, player in ipairs(getElementsByType("player")) do 
        if isElementWithinColShape(player, col3) then 
            setTimer(function (thePlayer) 
                triggerClientEvent("colshape:toggleDXRender", thePlayer) 
            end, 50, 1, player) 
        end 
    end 
    addEventHandler("onColShapeHit", col3, colShapeHit) 
    addEventHandler("onColShapeLeave", col3, colShapeLeave) 
end 
addEventHandler("onResourceStart", getRootElement(), resourceStart) 
  
function colShapeHit(element, dimension) 
    if getElementType(element) == "player" and dimension then 
        triggerClientEvent("colshape:toggleDXRender", element) 
    end 
end 
  
function colShapeLeave(element, dimension) 
    if getElementType(element) == "player" and dimension then 
        triggerClientEvent("colshape:toggleDXRender", element) 
    end 
end 

-- Client Side

local screenW, screenH = guiGetScreenSize() 
  
function toggleDXRender() 
    dxRenderState = not dxRenderState 
    if dxRenderState then 
        addEventHandler("onClientRender", getRootElement(), dxDraw) 
        dxRemoveDrawTimer = setTimer(function () 
            removeEventHandler("onClientRender", getRootElement(), dxDraw) 
        end, 1000*60, 1) 
    else 
        removeEventHandler("onClientRender", getRootElement(), dxDraw) 
    end 
end 
addEvent("colshape:toggleDXRender", true) 
addEventHandler("colshape:toggleDXRender", getRootElement(), toggleDXRender) 
  
function dxDraw() 
    dxDrawText("Updates", screenW*0.7891, screenH*0.7598, screenW*0.9187, screenH*0.8076, tocolor(255, 27, 27, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false) 
end 

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