Artenos Posted June 29, 2015 Share Posted June 29, 2015 so basically the same as creating a gui menu whenever a player clicks on a ped but this time whenever the player clicks on himself/herself it would display a dxrectangle here is what I got so far: function onPlayerClick(button, state, absX, absY, wx, wy, wz, element) if (element and getElementType(element) == "player" and state=="down") then local x, y, z = getElementPosition(localPlayer) if (getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <=3) then RenderHolo() end end end addEventHandler("onClientClick", getRootElement(), onPlayerClick) function RenderHolo function RenderHolo( startedRes) local thePlayer = getLocalPlayer () local x, y, z = getElementPosition ( thePlayer ) local r = getPedRotation ( thePlayer ) x = x - math.sin ( math.rad(r) ) * 1 y = y + math.cos ( math.rad(r) ) * 1 local holoscreen,RT_ID,RTE = createHoloScreen(x,y,z,-2,0,r,1.35,2) --Create our holoscreen setElementData(holoscreen,"interactive","aim") -- Make it interactive on user aim if RTE then -- If we got the render Target of the screen then RTE_Demo = RTE RTE_Holo = holoscreen addEventHandler ( "onHoloScrenRender", RTE_Holo,drawHoloDemo) -- Event handler for every render of the holo screen end end Link to comment
-Blaze- Posted June 29, 2015 Share Posted June 29, 2015 so basically the same as creating a gui menu whenever a player clicks on a ped but this time whenever the player clicks on himself/herself it would display a dxrectanglehere is what I got so far: function onPlayerClick(button, state, absX, absY, wx, wy, wz, element) if (element and getElementType(element) == "player" and state=="down") then local x, y, z = getElementPosition(localPlayer) if (getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <=3) then RenderHolo() end end end addEventHandler("onClientClick", getRootElement(), onPlayerClick) function RenderHolo function RenderHolo( startedRes) local thePlayer = getLocalPlayer () local x, y, z = getElementPosition ( thePlayer ) local r = getPedRotation ( thePlayer ) x = x - math.sin ( math.rad(r) ) * 1 y = y + math.cos ( math.rad(r) ) * 1 local holoscreen,RT_ID,RTE = createHoloScreen(x,y,z,-2,0,r,1.35,2) --Create our holoscreen setElementData(holoscreen,"interactive","aim") -- Make it interactive on user aim if RTE then -- If we got the render Target of the screen then RTE_Demo = RTE RTE_Holo = holoscreen addEventHandler ( "onHoloScrenRender", RTE_Holo,drawHoloDemo) -- Event handler for every render of the holo screen end end Well , if i didnt get you wrong , what you want to say is that if you click on a player or ped the window should show. If you click on yourself , it shouldnt show. Well , its easy. You just need to write an "if " statement to check that the clicked element is not the local player himself. Replace your first function with this -> function onPlayerClick(button, state, absX, absY, wx, wy, wz, element) if (element and getElementType(element) == "player" and state=="down") then if element == getLocalPlayer() then return end local x, y, z = getElementPosition(localPlayer) if (getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <=3) then RenderHolo() end end end addEventHandler("onClientClick", getRootElement(), onPlayerClick) Also , i would prefer not to use "element" as a parameter. Use "theelement" or something. Link to comment
Artenos Posted June 29, 2015 Author Share Posted June 29, 2015 No , sorry if you misunderstood what I said, here let me rephrase it: Basically what I want to accomplish is whenever a player clicks on themself the function should show the window. The window should NOT show if the player clicks on a ped or another player, so basically the opposite of what you said . Link to comment
-Blaze- Posted June 29, 2015 Share Posted June 29, 2015 function onPlayerClick(button, state, absX, absY, wx, wy, wz, element) if (element and getElementType(element) == "player" and state=="down") then if element ~= getLocalPlayer() then return end local x, y, z = getElementPosition(localPlayer) if (getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <=3) then RenderHolo() end end end addEventHandler("onClientClick", getRootElement(), onPlayerClick) Sorry , my bad. Try the above code . It should work. Link to comment
Artenos Posted June 30, 2015 Author Share Posted June 30, 2015 Fixed thanks for the help dude Link to comment
Artenos Posted June 30, 2015 Author Share Posted June 30, 2015 by the way how would I do it so that it removes the window when I click on the player again? Link to comment
-Blaze- Posted June 30, 2015 Share Posted June 30, 2015 Post the recent working code here and i'll show you and explain how. Link to comment
Artenos Posted July 1, 2015 Author Share Posted July 1, 2015 Nevermind I manage to remove the window by command Now I just need to know how to stop it from making the window everytime I click on the character 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