Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MessageRp by Rickoff for Sędzia
- tes3mp 0.7.0
- ---------------------------
- DESCRIPTION :
- Script principal for rp message in chat
- ---------------------------
- INSTALLATION:
- Save the file as MessageRp.lua inside your server/scripts/custom folder.
- Edits to customScripts.lua
- MessageRp = require("custom.MessageRp")
- ---------------------------
- FUNCTION:
- your message received by players just in your cell
- ! before message in your chat for global chat
- ---------------------------
- ]]
- local Methods = {}
- Methods.OnPlayerSendMessage = function(eventStatus, pid, message)
- if Players[pid] ~= nil and Players[pid]:IsLoggedIn() then
- if message:sub(1, 1) == '/' then
- else
- local message1 = color.Grey .. logicHandler.GetChatName(pid) .. color.White .. " : " .. message
- if Players[pid]:IsServerStaff() then
- if Players[pid]:IsServerOwner() then
- message1 = config.rankColors.serverOwner .. "[Adm] " .. message1 .. "\n"
- elseif Players[pid]:IsAdmin() then
- message1 = config.rankColors.admin .. "[Adm] " .. message1 .. "\n"
- elseif Players[pid]:IsModerator() then
- message1 = config.rankColors.moderator .. "[Mod] " .. message1 .. "\n"
- end
- end
- if message:sub(1, 1) == '!' then
- Methods.SendGlobalMessage(pid, message1)
- else
- Methods.SendLocalMessage(pid, message1)
- end
- return customEventHooks.makeEventStatus(false,false)
- end
- end
- end
- Methods.SendGlobalMessage = function(pid, message)
- tes3mp.SendMessage(pid, message, true)
- end
- Methods.SendLocalMessage = function(pid, message)
- local playerName = Players[pid].name
- local localChatCellRadius = 1
- -- Get top left cell from our cell
- local myCellDescription = Players[pid].data.location.cell
- if tes3mp.IsInExterior(pid) == true then
- local cellX = tonumber(string.sub(myCellDescription, 1, string.find(myCellDescription, ",") - 1))
- local cellY = tonumber(string.sub(myCellDescription, string.find(myCellDescription, ",") + 2))
- local firstCellX = cellX - localChatCellRadius
- local firstCellY = cellY + localChatCellRadius
- local length = localChatCellRadius * 2
- for x = 0, length, 1 do
- for y = 0, length, 1 do
- -- loop through all y inside of x
- local tempCell = (x+firstCellX)..", "..(firstCellY-y)
- -- send message to each player in cell
- if LoadedCells[tempCell] ~= nil then
- SendMessageToAllInCell(tempCell, message)
- end
- end
- end
- else
- SendMessageToAllInCell(myCellDescription, message)
- end
- end
- function SendMessageToAllInCell(cellDescription, message)
- for index,pid in pairs(LoadedCells[cellDescription].visitors) do
- if Players[pid].data.location.cell == cellDescription then
- tes3mp.SendMessage(pid, message, false)
- end
- end
- end
- customEventHooks.registerValidator("OnPlayerSendMessage", Methods.OnPlayerSendMessage)
- return Methods
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement