Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local image
- local timer
- local duration = 5000
- local activeImage = false
- local imagesEnabled = true
- local images = {
- angry = "images/angry.png",
- bored = "images/bored.png",
- ...
- }
- function drawImageOnVehicleTop(imageFile)
- if activeImage then
- return
- end
- local vehicle = getPedOccupiedVehicle(localPlayer)
- if vehicle then
- image = dxCreateTexture(imageFile)
- if image then
- activeImage = true
- addEventHandler("onClientRender", root, renderImageOnVehicleTop)
- timer = setTimer(destroyImageAndHandlers, duration, 1)
- end
- end
- end
- function renderImageOnVehicleTop()
- local vehicle = getPedOccupiedVehicle(localPlayer)
- if not isElement(vehicle) or isPedDead(localPlayer) then
- destroyImageAndHandlers()
- return
- end
- local x, y, z = getElementPosition(vehicle)
- dxDrawMaterialLine3D(x, y, z + 2, x, y, z + 1, image, 1)
- end
- function destroyImageAndHandlers()
- if image then
- destroyElement(image)
- image = nil
- activeImage = false
- end
- if isTimer(timer) then
- killTimer(timer)
- end
- removeEventHandler("onClientRender", root, renderImageOnVehicleTop)
- end
- local buttons = {
- {key = "1", image = images.angry},
- {key = "2", image = images.bored},
- ...
- }
- function toggleImages()
- imagesEnabled = not imagesEnabled
- outputChatBox(imagesEnabled and "*" ..greycolor.. " Emoji images has been" ..col_g.. " enabled" or "*" ..greycolor.. " Emoji images has been" ..col_r.. " disabled", 255, 255, 255, true)
- end
- bindKey( "F6", "down", toggleImages )
- function handleKey(button, press)
- if imagesEnabled and press and getKeyState("mouse2") then
- local image = nil
- for i, btn in ipairs(buttons) do
- if button == btn.key then
- image = btn.image
- break
- end
- end
- if image then
- drawImageOnVehicleTop(image)
- end
- end
- end
- addEventHandler("onClientKey", root, handleKey)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement