Coder Social home page Coder Social logo

lgf-chat's Introduction

LGF Chat

SHOWCASE

FORUM

This resource provides a chat interface for players to communicate in-game. Below are the instructions for using the chat functionality

image

  • Framework Support: Compatible with ESX , Qbox and LGF. QBCore support coming soon.
  • Roleplay Integration: Designed specifically for roleplay servers.
    • Job Chat: Communicate with others in the same profession.
    • Admin Chat: Dedicated chat for server administrators.
    • Auto Message: Automated messages for various events.
    • Staff Chat: Exclusive chat for staff members only.
    • Fully Editable: Customize to fit your server's needs.
    • Blacklisted words: Avoid Players They use incorrect terms.
    • UI Draggable: Easily reposition the chat interface.

Sending Messages

To send a message via the chat interface, use the following function:

Types

--- @param data table The message data.
--- @param playerId  | number 
--- @param message   | string 
--- @param playerJob | string 
--- @param author    | string 
--- @param bgColor   | string 
--- @param icon      | string 

Exports (Server Side)

exports['LGF-Chat']:CreateSendMessage({
    playerId = source,              -- The ID of the player sending the message.
    message = 'Your message here',  -- The content of the message.
    playerJob = 'Class or job',     -- Optional: The job or group of the player or the class example 'OOC' ecc.
    author = 'Your Name',           -- The name of the player sending the message.
    bgColor = '#312B2B',            -- Optional: The background color of the message box.
    icon = 'eye'                    -- Optional: The icon to display alongside the message.
})
  • playerId number The ID of the player sending the message.
  • message string The content of the message.
  • playerJob string Optional. The job or group of the player sending the message.
  • author string The name of the player sending the message.
  • bgColor string Optional. The background color of the message box (#RRGGBB format).
  • icon string Optional. The icon to display alongside the message.

Example with ESX

Global Message

RegisterCommand('ooc', function(source, args)
    local playerId = source
    local description = table.concat(args, " ")
    if args and #args > 0 then -- Let's avoid sending an empty message
        exports['LGF-Chat']:CreateSendMessage({
            playerId = playerId,
            message = description, 
            playerJob = 'OOC', -- Example You don't want jobs or groups, just put 'OOC' or 'IC' or you choose
            author = playerName,
            bgColor = '#312B2B',
            icon = 'globe'
        })
    end
end)

Job Message

RegisterCommand('police', function(source, args)
    local xPlayer = ESX.GetPlayerFromId(source)
    local PlayerJob = xPlayer.getJob()
    local Text = table.concat(args, " ")
    if args and #args > 0 then
        if PlayerJob == 'police' then -- check player have correct job
            exports['LGF-Chat']:CreateSendMessage({
                playerId = source,
                message = Text,
                playerJob = PlayerJob,
                author = GetPlayerName(source), -- Use Steam Name
                bgColor = '#312B2B',
                icon = 'user-shield'
            })
        else
            print('no job for send message)
        end
    end
end)

lgf-chat's People

Contributors

ent510 avatar maximus7474 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.