Search code examples
imageluagrand-theft-autofivem

How to draw an image on screen (Like a logo of some sort) for FiveM LUA


Just a simple question with, I believe, a not so simple answer; Is it possible with LUA to draw an image on screen? If yes; which Native is used for that? If no; what is an easy way to do it with another language?

Thanks in advance!


Solution

  • Lua itself doesn't have functions to do that, but FiveM does. (The upshot of this is that other games that use Lua will have their own functions to draw, and won't have this one). In this case, you'll want the DrawSprite function:

    -- 0xE7FFAE5EBF23D890 0x1FEC16B0
    -- DRAW_SPRITE
    DrawSprite(
      textureDict --[[ string ]], 
      textureName --[[ string ]], 
      screenX --[[ number ]], 
      screenY --[[ number ]], 
      width --[[ number ]], 
      height --[[ number ]], 
      heading --[[ number ]], 
      red --[[ integer ]], 
      green --[[ integer ]], 
      blue --[[ integer ]], 
      alpha --[[ integer ]]
    )
    

    Draws a 2D sprite on the screen. Parameters:

    • textureDict - Name of texture dictionary to load texture from (e.g. "CommonMenu", "MPWeaponsCommon", etc.)
    • textureName - Name of texture to load from texture dictionary (e.g. "last_team_standing_icon", "tennis_icon", etc.)
    • screenX/Y - Screen offset (0.5 = center)
    • scaleX/Y - Texture scaling. Negative values can be used to flip the texture on that axis. (0.5 = half)
    • heading - Texture rotation in degrees (default = 0.0) positive is clockwise, measured in degrees
    • red,green,blue - Sprite color (default = 255/255/255)
    • alpha - opacity level
    NativeDB Added Parameter 12: BOOL p11