Jump to content

[HELP]About DXdrawtext


Recommended Posts

Posted

Hi, I have a problem.

When i enter the colshape the text appears but it disappears after like 100 miliseconds.

How can i make it stay and leave when someone enters it and leaves it?

this is the code(client):

wepcol = createColCuboid ( 1495.6212158203, -3100.0891113281, 87.07982635498, 5, 5, 5 ) 
  
function enter() 
local text = dxDrawText("meep",329.0,412.0,482.0,425.0,tocolor(255,200,0,255),0.9,"default-bold","left","top",false,false,false) 
end 
addEventHandler("onClientColShapeHit", wepcol, enter) 
  
function leave() 
textDestroyTextItem ( text ) 
end 
addEventHandler("onClientColShapeLeave", wepcol, leave) 

Regards,

Jesseunit

Posted

dxDrawText does not return any elements, only true|false. it just renders the text for 1 (ONE) frame, so you have to call this function every frame (onClientRender event).

and textitems is a different thing, read the wiki links.

?

Posted

ok, but now i get a new error:

addEventHandler: onClientRender is already handled 

this is the code:

  
wepcol = createColCuboid ( 1495.6212158203, -3100.0891113281, 87.07982635498, 5, 5, 5 ) 
root = getRootElement() 
  
function enter() 
local text = dxDrawText("meep",329.0,412.0,482.0,425.0,tocolor(255,200,0,255),0.9,"default-bold","left","top",false,false,false) 
addEventHandler("onClientRender", root, enter) 
end 
addEventHandler("onClientColShapeHit", wepcol, enter) 
  
function leave() 
textDestroyTextItem ( text ) 
removeEventHandler("onClientRender",root,leave) 
end 
addEventHandler("onClientColShapeLeave", wepcol, leave) 

Posted

you need to call addEventHandler only once, and you have it in a loop.

wepcol = createColCuboid ( 1495.6212158203, -3100.0891113281, 87.07982635498, 5, 5, 5 ) 
root = getRootElement() 
  
function render() 
  dxDrawText("meep",329.0,412.0,482.0,425.0,tocolor(255,200,0,255),0.9,"default-bold","left","top",false,false,false) 
end 
  
function enter() 
  addEventHandler("onClientRender", root, render) 
end 
addEventHandler("onClientColShapeHit", wepcol, enter) 
  
function leave() 
  removeEventHandler("onClientRender", root, render) 
end 
addEventHandler("onClientColShapeLeave", wepcol, leave) 

?

Posted

thanks, but now im making it so that the player cna buy a weapon of the wall, But it seems to be its not working.

server:

addEvent("giveM4", true)   
function giveMeM4(playerName)    
local guy = getPlayerFromName( playerName ); 
if getPlayerMoney (guy) >= 1400 then 
giveWeapon(guy, 31, 100) 
outputChatBox("Ka ching!", 0, 255, 0, guy) -- TEST MESSAGE 
else 
outputChatBox("You dont have enough money!", 255, 0, 0, guy) 
end 
end 
addEventHandler ( "giveM4", getRootElement(), giveMeM4 ) 

client:

  
wepcol = createColCuboid ( 1495.6212158203, -3100.0891113281, 87.07982635498, 2, 5, 2 ) 
 root = getRootElement() 
  
 function render() 
  dxDrawText("Press [O] for a M4 (1400$)",329.0,412.0,482.0,425.0,tocolor(255,200,0,255),0.9,"default-bold","left","top",false,false,false) 
 end 
  
 function enter() 
 addEventHandler("onClientRender", root, render) 
    bindKey( "O", "down", m4) 
 outputChatBox("O BINDED", root, 255, 0, 0) -- TEST MESSAGE 
 end 
 addEventHandler("onClientColShapeHit", wepcol, enter) 
  
 function leave() 
   removeEventHandler("onClientRender", root, render) 
    unbindKey( "O", "down", m4) 
        outputChatBox("O UNBINDED", root, 255, 0, 0) -- TEST MESSAGE 
 end 
 addEventHandler("onClientColShapeLeave", wepcol, leave) 
  
  
 function m4(theElement, matchingDimension) 
 triggerServerEvent( "giveM4", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) 
end 
end 

Posted
wepcol = createColCuboid ( 1495.6212158203, -3100.0891113281, 87.07982635498, 2, 5, 2 ) 
root = getRootElement() 
  
 function render() 
  dxDrawText("Press [O] for a M4 (1400$)",329.0,412.0,482.0,425.0,tocolor(255,200,0,255),0.9,"default-bold","left","top",false,false,false) 
 end 
  
function enter() 
 addEventHandler("onClientRender", root, render) 
 bindKey( "O", "down", m4) 
 outputChatBox("O BINDED", root, 255, 0, 0) -- TEST MESSAGE 
end 
addEventHandler("onClientColShapeHit", wepcol, enter) 
  
function leave() 
   removeEventHandler("onClientRender", root, render) 
   unbindKey( "O", "down", m4) 
   outputChatBox("O UNBINDED", root, 255, 0, 0) -- TEST MESSAGE 
end 
addEventHandler("onClientColShapeLeave", wepcol, leave) 
  
  
function m4(theElement, matchingDimension) 
 triggerServerEvent( "giveM4", getLocalPlayer(),getLocalPlayer()) 
end 

addEvent("giveM4", true)   
function giveMeM4(client)    
if getPlayerMoney (client) >= 1400 then 
giveWeapon(client, 31, 100) 
outputChatBox("Ka ching!", client, 0, 255, 0) -- TEST MESSAGE 
else 
outputChatBox("You dont have enough money!", client, 255, 0, 0) 
end 
end 
addEventHandler ( "giveM4", getRootElement(), giveMeM4 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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