Jump to content

Text on a position


Tete omar

Recommended Posts

Hello everyone

I'm asking now how could i create a text or a static image on an position not on the screen then attach it over the player's head

i know with attachElements

but my question is about the text on an position

please i don't want editors downloads i wanna make it manually.

Link to comment
  • Other Languages Moderators
Have you ever searched on community?

http://community.multitheftauto.com/ind ... ls&id=3090

please i don't want editors downloads i wanna make it manually.

Have you read my topic correctly ?

and i don't want this text / image only show up to the player , i want make it show up for all players

How you expect to make it without looking at other resources?

what does manually mean for you?

check this, it's will show for all players

http://community.multitheftauto.com/ind ... ls&id=4931

if you don't want to download it, this your problem.

Link to comment

is that going to work ?

function drawImage() 
    local screenX, screenY = getScreenFromWorldPosition(posX, posY, posZ) 
    local camX, camY, camZ = getCameraMatrix() 
    local distance = getDistanceBetweenPoints2D(camX, camY, posX, posY) 
    if (screenX and distance < 50) then 
        local scale = 1000 / screenWidth 
        local width = 80 / scale 
        local image = dxDrawImage(screenX - width / 2, screenY - screenHeight / 10, width, 80, "Attention.png") 
        dxDrawText( guiGetText(theText), screenX, screenY, screenX, screenY, tocolor( 0, 0, 0, 255 ), 5, "arial", "center", "center" ) 
    end 
end 
addEventHandler("onClientGUIClick",Buy,drawImage) 

i tested it but it actually doesn't work.

Link to comment
  • Other Languages Moderators
is that going to work ?
function drawImage() 
    local screenX, screenY = getScreenFromWorldPosition(posX, posY, posZ) 
    local camX, camY, camZ = getCameraMatrix() 
    local distance = getDistanceBetweenPoints2D(camX, camY, posX, posY) 
    if (screenX and distance < 50) then 
        local scale = 1000 / screenWidth 
        local width = 80 / scale 
        local image = dxDrawImage(screenX - width / 2, screenY - screenHeight / 10, width, 80, "Attention.png") 
        dxDrawText( guiGetText(theText), screenX, screenY, screenX, screenY, tocolor( 0, 0, 0, 255 ), 5, "arial", "center", "center" ) 
    end 
end 
addEventHandler("onClientGUIClick",Buy,drawImage) 

i tested it but it actually doesn't work.

posX and posY and posZ and screenWidth and screenHeight not defined.

and you need event onClientRender not onClientGUIClick.

Link to comment
  • Other Languages Moderators
Possible to make it on button click ?

Of course

function onClick() 
addEventHandler("onClientRender",root,drawImage) 
end 
addEventHandler("onClientGUIClick",Buy,onClick) 
  
function drawImage() 
.. 
end 

Link to comment
Possible to make it on button click ?

Of course

function onClick() 
addEventHandler("onClientRender",root,drawImage) 
end 
addEventHandler("onClientGUIClick",Buy,onClick) 
  
function drawImage() 
.. 
end 

But the image is shown up when the resource start not when the button clicked

Link to comment

well, there might be an error, try this:

function drawImage() 
    local screenX, screenY = getScreenFromWorldPosition(posX, posY, posZ) 
    local camX, camY, camZ = getCameraMatrix() 
    local distance = getDistanceBetweenPoints2D(camX, camY, posX, posY) 
    if (screenX and distance < 50) then 
        local scale = 1000 / screenWidth 
        local width = 80 / scale 
        local image = dxDrawImage(screenX - width / 2, screenY - screenHeight / 10, width, 80, "Attention.png") 
        dxDrawText( guiGetText(theText), screenX, screenY, screenX, screenY, tocolor( 0, 0, 0, 255 ), 5, "arial", "center", "center" ) 
    end 
end 
function onClick() 
    addEventHandler("onClientRender",root,drawImage) 
end 
addEventHandler("onClientGUIClick",Buy,onClick) 

Link to comment
well, there might be an error, try this:
function drawImage() 
    local screenX, screenY = getScreenFromWorldPosition(posX, posY, posZ) 
    local camX, camY, camZ = getCameraMatrix() 
    local distance = getDistanceBetweenPoints2D(camX, camY, posX, posY) 
    if (screenX and distance < 50) then 
        local scale = 1000 / screenWidth 
        local width = 80 / scale 
        local image = dxDrawImage(screenX - width / 2, screenY - screenHeight / 10, width, 80, "Attention.png") 
        dxDrawText( guiGetText(theText), screenX, screenY, screenX, screenY, tocolor( 0, 0, 0, 255 ), 5, "arial", "center", "center" ) 
    end 
end 
function onClick() 
    addEventHandler("onClientRender",root,drawImage) 
end 
addEventHandler("onClientGUIClick",Buy,onClick) 

the same problem . :(

look here

2qvcnle.jpg

when i restart the resource

i get that

154yr0g.jpg

2q39jk0.jpg

there's a button but i won't show my idea , but i want the theText and the image show up when the button clicked

Edited by Guest
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...