Skip to content
Necroso edited this page Nov 9, 2023 · 3 revisions

Following is a list of useful scripts created by users of this plugin and decided to share!

Chat Messages

Description

This system uses a more simplified way of sending messages to the player's chat. The colors used are similar to those used in the Official VCMP Squirrel Plugin.

Here is a list of comparisons between Squirrel Plugin functions and equivalents in this script:

Squirrel Plugin Lua Message Arguments in both
PrivMessage chatMessage.private (Player player, String message)
PrivMessageAll chatMessage.privateToAll (String message)
MessagePlayer chatMessage.toPlayer (String message, Player player)
Message chatMessage.toAll (String message)
MessageAllExcept chatMessage.toAllExcept (String message, Player player)
ClientMessage chatMessage.client (String message, Player player, int R, int G, int B)
ClientMessageToAll chatMessage.clientToAll (String message, int R, int G, int B)

Script

chatMessage = {
    private = function(player, message)
        player:msg("** pm >> " .. message, tocolor(0, 121, 21))
    end,

    privateToAll = function(message)
        for i, player in pairs(Player.getActive()) do
            player:msg("** pm >> " .. message, tocolor(0, 121, 21))
        end
    end,
  
    toPlayer = function(message, player)
        player:msg(message, tocolor(10, 91, 157))
    end,
  
    toAll = function(message)
        for i, player in pairs(Player.getActive()) do
            player:msg(message, tocolor(10, 91, 157))
        end
    end,
  
    toAllExcept = function(message, player)
        for i, plr in pairs(Player.getActive()) do
            if(plr ~= player) then
                player:msg(message, tocolor(10, 91, 157))
            end
        end
    end,
  
    client = function(message, player, r, g, b)
        player:msg(message, tocolor{r, g, b})
    end,
  
    clientToAll = function(message, r, g, b)
        for i, player in pairs(Player.getActive()) do
            player:msg(message, tocolor(r, g, b))
        end
    end
}

Notes

tocolor function is required.

Example

Event.bind("onPlayerConnect", function(player)
    chatMessage.private(player, "chatMessage.private: Only you can read this. #1")
    chatMessage.privateToAll("chatMessage.privateToAll: Everyone can read this. #1")
    chatMessage.toPlayer("chatMessage.toPlayer: Only you can read this. #2", player)
    chatMessage.toAll("chatMessage.toAll: Everyone can read this. #2")
    chatMessage.toAllExcept("chatMessage.toAllExcept: " .. player.name .. " cannot read this message.", player) -- This one won't show up for you, duh
    chatMessage.client("chatMessage.client: Only you can read this. #3", player, 255, 255, 0)
    chatMessage.clientToAll("chatMessage.clientToAll: Everyone can read this. #3", 255, 255, 0)
end)
Clone this wiki locally