Tete omar Posted August 21, 2012 Share Posted August 21, 2012 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
xPiwel Posted August 21, 2012 Share Posted August 21, 2012 Did you try with the dxDrawText ? https://wiki.multitheftauto.com/wiki/DxDrawText Link to comment
Tete omar Posted August 21, 2012 Author Share Posted August 21, 2012 dxDrawText is in my mind , but it only draws a text on the screen , not on a position ... getScreenFromWorldPosition this may work ... Link to comment
TAPL Posted August 21, 2012 Share Posted August 21, 2012 Have you ever searched on community? https://community.multitheftauto.com/ind ... ls&id=3090 Link to comment
Tete omar Posted August 21, 2012 Author Share Posted August 21, 2012 Have you ever searched on community?https://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 Link to comment
TAPL Posted August 21, 2012 Share Posted August 21, 2012 Have you ever searched on community?https://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 https://community.multitheftauto.com/ind ... ls&id=4931 if you don't want to download it, this your problem. Link to comment
AMARANT Posted August 21, 2012 Share Posted August 21, 2012 He probably wants the example right here on this topic. Link to comment
Tete omar Posted August 21, 2012 Author Share Posted August 21, 2012 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
TAPL Posted August 21, 2012 Share Posted August 21, 2012 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
Tete omar Posted August 21, 2012 Author Share Posted August 21, 2012 Possible to make it on button click ? Link to comment
TAPL Posted August 21, 2012 Share Posted August 21, 2012 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
Tete omar Posted August 22, 2012 Author Share Posted August 22, 2012 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
Jaysds1 Posted August 22, 2012 Share Posted August 22, 2012 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
Tete omar Posted August 22, 2012 Author Share Posted August 22, 2012 (edited) 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 when i restart the resource i get that 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 August 22, 2012 by Guest Link to comment
AMARANT Posted August 22, 2012 Share Posted August 22, 2012 It starts showing the image when the resource starts or after at least one click on button? Link to comment
Jaysds1 Posted August 22, 2012 Share Posted August 22, 2012 can you pm me your full code? Link to comment
Tete omar Posted August 22, 2012 Author Share Posted August 22, 2012 can you pm me your full code? Thanks jaysds1 thanks it worked thanks ! but i got another question :p how to attach the image and the text to the player Link to comment
Jaysds1 Posted August 22, 2012 Share Posted August 22, 2012 well, you have to get coordinates tho, I actually never tried this before. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now