Jump to content

Text Radius Help.


v0nz

Recommended Posts

Posted

-- define our chat radius 
  
local chatRadius = 20 --units 
  
-- define a handler that will distribute the message to all nearby players 
function sendMessageToNearbyPlayers( message, messageType ) 
    -- we will only send normal chat messages, action and team types will be ignored 
    if messageType == 0 then 
        -- get the chatting player's position 
        local posX, posY, posZ = getElementPosition( source ) 
         
        -- create a sphere of the specified radius in that position 
        local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
        -- get a table all player elements inside it 
        local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
        -- and destroy the sphere, since we're done with it 
        destroyElement( chatSphere ) 
         
        -- deliver the message to each player in that table 
        for index, nearbyPlayer in ipairs( nearbyPlayers ) do 
            outputChatBox( message, nearbyPlayer ) 
        end 
    end 
end 
-- attach our new chat handler to onPlayerChat 
addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) 
  
-- define another handler function that cancels the event so that the message won't be delivered through the  
function blockChatMessage() 
    cancelEvent() 
end 
-- attach it as a handler to onPlayerChat 
  
  
addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage ) 

I am trying to make it... A name: "Chat"

I was looking at outputChatBox( message, nearbyPlayer ). Adding getClientName: does not work.

25567.png

25110.png

4600.gif

gtasampplayerlg3.png

mtateam5fq.png

Posted

You just pasted an example straight from the wiki entry for the onPlayerChat() event... It should work just fine. What are you trying to do to modify it??? And that example is for server-side code, so make sure you're running it that way.

Build a man a fire - he shall be warm for a night.

Light a man on fire - he shall be warm for the rest of his life.

--Cho Mo

Posted

Also, learn to use the proper subforums! This is NOT an add-on, it's a normal script.

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

Posted

Im just trying to make it have a name before the text such as... "v0nz: I like to type". And yes, I know, its serversided.

25567.png

25110.png

4600.gif

gtasampplayerlg3.png

mtateam5fq.png

Posted

This is scripting, the topic should be there.

Do NOT PM ME for help unless invited. - New MTA Script Editor

Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...