Alex2112 Posted September 15, 2020 Share Posted September 15, 2020 Hi, as the title says I am trying to make a script that blows vehicle at 6959 object but I want the player to be warned with a text like this one dxDrawText("Do not try to camp!", 0, 0, x, y, tocolor(255, 0, 0), 2, "pricedown", "center", "center") but I want to add SetTimer too, because players should have time to read/ and to go back to track. This is the script which I have tried to do. addEventHandler("onClientVehicleCollision", getRootElement(), function(hitElement) if source ~= getPedOccupiedVehicle(localPlayer) then return end if getElementType(hitElement) == "object" and getElementModel(hitElement) == 6959 then blowVehicle(source) end end) The problem is I do not really know where to add the DrawText and SetTimer too Thanks for helping me ! Link to comment
AfuSensi Posted September 16, 2020 Share Posted September 16, 2020 To draw the text, you need to put it in an onClientRender event, because you need to draw it at every frame. Then you need to add an "onClientRender" event handler to draw your text. You can then use a timer to remove the event handler, so that the text disappears after the timer executes. Example: -- Create a function that draws your text. function drawWarning() dxDrawText("Do not try to camp!", 0, 0, x, y, tocolor(255, 0, 0), 2, "pricedown", "center", "center") end addEventHandler("onClientVehicleCollision", getRootElement(), function(hitElement) if source ~= getPedOccupiedVehicle(localPlayer) then return end if getElementType(hitElement) == "object" and getElementModel(hitElement) == 6959 then -- Show text (handle "onClientRender" event) addEventHandler("onClientRender", root, drawWarning) -- Create a timer that makes sure the "onClientRender" handler gets removed when it expires. setTimer(removeEventHandler, 5000, 1, "onClientRender", root, drawWarning) blowVehicle(source) end end) 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