Razzer47 Posted August 11, 2013 Share Posted August 11, 2013 How i can make new chat .. like help chat (where newbies ask) and public chat (where you chat with the players that around you) Link to comment
tosfera Posted August 11, 2013 Share Posted August 11, 2013 You mean a Local chat? You can create a Col around the person that said something, send the message to everyone thats in that Col and done. The support chat can be found here; https://community.multitheftauto.com/in ... ls&id=6552 Link to comment
Vector Posted August 11, 2013 Share Posted August 11, 2013 hey, this is an example. -> only players around you will be able to see your chat messages. server-side. local maxDistance = 20; -- 20 metres will be the maximum distance to see player messages. addEventHandler("onPlayerChat", getRootElement(), function (message, messageType) if messageType==1 then return; end; -- do nothing if message is an action message. -- now, get players near the player who sent the message and store them in a table. local nearestPlayers = {}; local players = getElementsByType("player", getRootElement()); local pX, pY, pZ = getElementPosition(source); for _,player in ipairs(players) do local sX, sY, sZ = getElementPosition(player); if ((pX-sX)^2 + (pY-sY)^2 + (pZ-sZ)^2) <= maxDistance^2 then -- player is near, so, add it to the list... table.insert(nearestPlayers,player); end; end; -- now, check if the message is a team message. in that case, we remove from the table all the players -- that are not inside the team of the player who sendt the message. local playerTeam = getPlayerTeam(source); if playerTeam and (messageType==2) then for index,player in ipairs(nearestPlayers) do if getPlayerTeam(player) ~= playerTeam then -- if teams are different, remove from list... table.remove(nearestPlayers, index); end; end; end; -- now send the chat message for that players... local chatMessage = getPlayerName(source) .. "#FFFFFF: " .. message; for _,player in ipairs(nearestPlayers) do outputChatBox(chatMessage, player, 255,255,255, true); end; cancelEvent(); -- cancel event so that the chat message will not be shown directly. end); Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now