# Export and Events

#### ADD NEW TEXT

To add a text, we first need code that uses loops. Now we will replace any DrawText with the frkn-text system

```lua
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if frkncraftv2action then
            for k, v in pairs(FRKN.CraftSystem["Pos"]) do
                local distance = #(GetEntityCoords(PlayerPedId()) - v)
                if distance < 3.0 then
                    if FRKN.Job then 
                      if ESX.GetPlayerData().job.name == FRKN.JobName then 
                        DrawText3D(v.x, v.y, v.z + 0.2, "[E] - Craft")
                        if IsControlJustReleased(0, 38) then
                            TriggerEvent('frkn-craftv2:openMenu')
                        end
                    end
                else
                    DrawText3D(v.x, v.y, v.z + 0.2, "[E] - Craft")
                    if IsControlJustReleased(0, 38) then
                        TriggerEvent('frkn-craftv2:openMenu')
                    end   
                end
            end
        end
    else
        Citizen.Wait(500)
    end
    end
end)
```

:warning: The 1st data you see at the bottom must contain the item table you see at the bottom of it. The more data you add into that table, the more transactions you will have in your list.\
The 2nd <mark style="color:red;">**v**</mark> data is the position.\
The 3rd data <mark style="color:red;">**3**</mark> is the distance value. You can increase or decrease this value depending on how far you want the text to open and close.\
The 4th value, <mark style="color:red;">**pink**</mark>, is the color. You can customize this as you view it on the config page<br>

```lua
exports["frkn-text"]:openTextUi(item,v,3,"pink")
```

```lua
Citizen.CreateThread(function()
    local sleep = 1000  
    while true do
        if frkncraftv2action then
            for k, v in pairs(FRKN.CraftSystem["Pos"]) do
                local distance = #(GetEntityCoords(PlayerPedId()) - v)
                if distance ~= -1 and distance <= 2.5 then
                    if FRKN.Job then 
                       if ESX.GetPlayerData().job.name == FRKN.JobName then 
                        item = {
                            ["item"] = {
                            [1] = {name = "Open",event = "frkn-craftv2:open" , icon = "fa fa-mouse-pointer"},
                            [2] = {name = "Close",event = "frkn-craftv2:close" , icon = "fa fa-close"},
                        }}
                        exports["frkn-text"]:openTextUi(item,v,3,"pink")
                    end
                else
                    item = {
                        ["item"] = {
                            [1] = {name = "Open",event = "frkn-craftv2:open" , icon = "fa fa-mouse-pointer"},
                            [2] = {name = "Close",event = "frkn-craftv2:close" , icon = "fa fa-close"},
                    }}
                    exports["frkn-text"]:openTextUi(item,v,3,"pink")
                    sleep = 1
                end
            end
        end
    end
    Citizen.Wait(sleep)
    end
end)
```
