Jump to content

additional variables to addEventHandler


Elohim

Recommended Posts

Hello, i want to do an function that triggers other dx function, like this:

local sw,sh = guiGetScreenSize() 
function draw(splashpath,name,text) 
  if (splashpath) and (name) and (text) then 
dg =  dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") 
nm =  dxDrawText(name,sw*.3,sh*.85) 
spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) 
txt =  dxDrawText(text,sw*.29,sh*.90) 
else 
  outputDebugScript("Incorrect Syntaxis: drawDialogue(splashartpath,name,text)") 
end 
end 
--This triggers the function in top 
function drawDialogue(splashpath,name,text) 
  addEventHandler("onClientRender",getLocalPlayer(),draw) 
end 

i dont know how to add the arguments splashpath,name, and text into the eventHandler

Link to comment

I did this

local sw,sh = guiGetScreenSize() 
local spacer = dxGetFontHeight(1.2,"default") 
local nm = nm 
local spl = spl 
local txt = txt 
function draw(splashpath,name,text) 
  if (splashpath) and (name) and (text) then 
dg =  dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") 
nm =  dxDrawText(name,sw*.3,sh*.85) 
spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) 
txt =  dxDrawText(text,sw*.29,sh*.90+spacer) 
else 
  outputDebugScript("Incorrect Syntaxis: drawDialogue(splashartpath,name,text)") 
end 
end 
  
function drawDialogue(splashpath,name,text) 
  local nm = "bartender" 
  local spl = "bartender.png" 
  local txt = "test" 
  addEventHandler("onClientRender",getLocalPlayer(),draw) 
end 

didnt work, i think i did a mistake anywhere, or everywhere u.u

Link to comment

You might need to go through the basics again.

Those dx functions don't return anything useful.

local nm = nm 

That seems kinda wrong too.

And the rest.. remove the if else from the render function and put that in the other one for the start.

Link to comment
  
local sw,sh = guiGetScreenSize() 
local spacer = dxGetFontHeight(1.2,"default") 
function draw(splashpath,name,text) 
local dg =  dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") 
local nm =  dxDrawText(name,sw*.3,sh*.85) 
local spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) 
local txt =  dxDrawText(text,sw*.29,sh*.90+spacer) 
end 
  
function drawDialogue(splashpath,name,text) 
  local nm = "bartender" 
  local spl = "bartender.png" 
  local txt = "test" 
  addEventHandler("onClientRender",root,draw) 
end 
  
drawDialogue("bartender.png","bartender","testing the shoots") 
  
  
  

i removed the locals on top, and repaired the errors that anubhav wrote, but i still cant add the variables to the event

Link to comment
  
local sw,sh = guiGetScreenSize() 
local spacer = dxGetFontHeight(1.2,"default") 
local name = "" 
local splashpath = "" 
local text = "" 
  
function draw(splashpath,text) 
    local dg =  dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") 
    local nm =  dxDrawText(name,sw*.3,sh*.85) 
    local spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) 
    local txt =  dxDrawText(text,sw*.29,sh*.90+spacer) 
end 
  
function drawDialogue(splashpath,name,text) 
    name = "bartender" 
    splashpath = "bartender.png" 
    text = "test" 
     
    addEventHandler("onClientRender",root,draw) 
end 
  
drawDialogue("bartender.png","bartender","testing the shoots") 
  

Link to comment
  
local sw,sh = guiGetScreenSize() 
local spacer = dxGetFontHeight(1.2,"default") 
local name = "" 
local splashpath = "" 
local text = "" 
  
function draw() 
    local dg =  dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") 
    local nm =  dxDrawText(name,sw*.3,sh*.85) 
    local spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) 
    local txt =  dxDrawText(text,sw*.29,sh*.90+spacer) 
end 
  
function drawDialogue(splashpath,name,text) 
    name = "bartender" 
    splashpath = "bartender.png" 
    text = "test" 
  
    addEventHandler("onClientRender",root,draw) 
end 
  
drawDialogue("bartender.png","bartender","testing the shoots") 
  

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