Jump to content

RP LOCAL CHAT BUG


Normand

Recommended Posts

Posted

Error: 

[2017-12-28 09:08:30] WARNING: chat/server.lua:44: Bad argument @ 'getElementPosition' [Expected element at argument 1, got nil]
[2017-12-28 09:08:30] WARNING: chat/server.lua:45: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil]
[2017-12-28 09:08:30] WARNING: chat/server.lua:55: Bad argument @ 'addEventHandler' [Expected function at argument 3, got none]

Code:

local chat_tavolsag = 100

function onChat(player, _, msg)
	local X, Y, Z = getElementPosition(player)
	local nev = getPlayerName(player)
	for _, v in ipairs(getElementsByType("player")) do
		if messageType == 0 then
			if isPlayerInRangeOfPoint(v, X, Y, Z, chat_tavolsag) then
				outputChatBox("".. nev .." mondja: ".. msg .."", v, 255, 255, 255, true)
			end
		end
	end	
end 

addEventHandler("onPlayerChat", getRootElement(), onChat(player, _, messsage))

Please help, i want a local chat.

Posted

So i tried to make a local chat based on the basic mta chat function (The T Bind) but it does not work because i think the mta basic chat overwrites my script.

Posted
local chat_tavolsag = 100

function onChat( msg, messagetype )
	local X, Y, Z = getElementPosition(source)
	local nev = getPlayerName(source)
	for _, v in ipairs(getElementsByType("player")) do
		if messageType == 0 then
			if isPlayerInRangeOfPoint(v, X, Y, Z, chat_tavolsag) then
				outputChatBox("".. nev .." mondja: ".. msg .."", v, 255, 255, 255, true)
			end
		end
	end	
end 

addEventHandler("onPlayerChat", getRootElement(), onChat)

 

Posted (edited)

My new problem, double messages. Default chat and my chat.

Richard Norrington: asd

Richard Norrington mondja: asd

Code:

local chat_tavolsag = 100

function onChat(msg, messageType)
	local X, Y, Z = getElementPosition(source)
	local nev = getPlayerName(source)
	for _, v in ipairs(getElementsByType("player")) do
		if messageType == 0 then
			cancelEvent()
			if isPlayerInRangeOfPoint(v, X, Y, Z, chat_tavolsag) then
				outputChatBox("".. nev .." mondja: ".. msg .."", v, 255, 255, 255, true)
			end
		end
	end	
end 

addEventHandler("onPlayerChat", root, onChat)

 

Edited by Normand

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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