thund3rbird23 Posted August 11, 2020 Share Posted August 11, 2020 (edited) I want to make the dxDrawTextOnElement clickable for ex. here is a text "Buy" I want to make if I click on the Buy text then output "Clicked" in the chat. Is it possible to implement? And how can I put another text next to each others? I want to add "Sell" text too next to the "Buy" text This is draws the Buy text above every vehicles. function Draw() local vehs = getElementsByType("vehicle") for k,v in ipairs(vehs) do if getPedOccupiedVehicle( localPlayer ) ~= v then dxDrawTextOnElement (v, "Buy", 0.75, _, _, _, _, _, 2, _, tocolor(102,204,0,255)) end end end addEventHandler ("onClientRender", getRootElement(), Draw) Edited August 11, 2020 by thund3rbird23 Link to comment
MTA Team 0xCiBeR Posted August 12, 2020 MTA Team Share Posted August 12, 2020 It is possible, for this you should enable the cursor and listen on the following event: https://wiki.multitheftauto.com/wiki/OnClientClick Event parameters received when event is triggered: string button, string state, int absoluteX, int absoluteY, float worldX, float worldY, float worldZ, element clickedWorld That gives you the absoluteX & absoluteY and also the x,y,z from the world. Most importantly, the last argument passed by the event is an element if one has been clicked, you could check if that element is a car and it's on sale, and then print that out. 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