shaio Posted August 22, 2016 Posted August 22, 2016 I need help creating a phone system with dx GUI, I can't get it to work, this is my code so far.. Please help me out Client.lua - addEventHandler("onClientRender",root,function() for _,phone in ipairs(getElementsByType("Object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then local x,y,z = getElementPosition(getLocalPlayer()) local vx,vy,vz = getElementPosition(phone) if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then addEventHandler("onClientRender",root,function() dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) dxDrawImage(28, 487, 44, 39, "/images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) end) end end end end) Meta.xml - <meta> <script src="client.lua" type="client"/> <file src="images/phone.png"/> </meta> phone.png - ~ Shaio Fencski
Wumbaloo Posted August 22, 2016 Posted August 22, 2016 getElementsByType shouldn't be Object but object Computer science student at { EPITECH }
G-Stefan Posted August 22, 2016 Posted August 22, 2016 I need help creating a phone system with dx GUI, I can't get it to work, this is my code so far.. Please help me out Client.lua - addEventHandler("onClientRender",root,function() for _,phone in ipairs(getElementsByType("object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then local x,y,z = getElementPosition(getLocalPlayer()) local vx,vy,vz = getElementPosition(phone) if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then addEventHandler("onClientRender",root,function() dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) dxDrawImage(28, 487, 44, 39, "/images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) end) end end end end) Meta.xml - <meta> <script src="client.lua" type="client"/> <file src="images/phone.png"/> </meta> phone.png - Try this one: addEventHandler("onClientRender",root,function() for _,phone in ipairs(getElementsByType("Object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then local x,y,z = getElementPosition(getLocalPlayer()) local vx,vy,vz = getElementPosition(phone) if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) dxDrawImage(28, 487, 44, 39, "images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) end end end end end) Make sure that the phones are added by script or .map file Multi Theft Auto : Racers Land 10%
shaio Posted August 22, 2016 Author Posted August 22, 2016 Try this one: addEventHandler("onClientRender",root,function() for _,phone in ipairs(getElementsByType("Object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then local x,y,z = getElementPosition(getLocalPlayer()) local vx,vy,vz = getElementPosition(phone) if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) dxDrawImage(28, 487, 44, 39, "images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) end end end end end) Make sure that the phones are added by script or .map file But by doing this for _,phone in ipairs(getElementsByType("Object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then it grabs all of the phone OBJECTS in the map, whether they are added by map, script or not added at all.. The script doesn't work yet ~ Shaio Fencski
Wumbaloo Posted August 22, 2016 Posted August 22, 2016 What would you want to do? Computer science student at { EPITECH }
1LoL1 Posted August 22, 2016 Posted August 22, 2016 Try this one: addEventHandler("onClientRender",root,function() for _,phone in ipairs(getElementsByType("Object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then local x,y,z = getElementPosition(getLocalPlayer()) local vx,vy,vz = getElementPosition(phone) if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) dxDrawImage(28, 487, 44, 39, "images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) end end end end end) Make sure that the phones are added by script or .map file But by doing this for _,phone in ipairs(getElementsByType("Object")) do if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then it grabs all of the phone OBJECTS in the map, whether they are added by map, script or not added at all.. The script doesn't work yet Look what Wumbaloo said.. for _,phone in ipairs(getElementsByType("object")) do and use getElementModel() not getObjectModel()
shaio Posted August 23, 2016 Author Posted August 23, 2016 For now I just want to show the dx gui when near a payphone, and I did try getElementModel(), it still doesn't work. ~ Shaio Fencski
Wumbaloo Posted August 24, 2016 Posted August 24, 2016 I can't help you by my phone. I have to wait Sunday Computer science student at { EPITECH }
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