Jump to content

Main Chat


FlyingSpoon

Recommended Posts

I've got this script, I've edited the main chat, but commands dont work anymore, like ./reconnect ./disconnect ./quit etc,

How can I enable them again? When I type, it just outputs the message e.g. RayZ says: /reconnect

 

addEventHandler("onPlayerJoin",getRootElement(),
function ()
bindKey(source,"t","down","chatbox","Say")
end)
 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
function ()
for index, player in pairs(getElementsByType("player")) do
bindKey(player,"t","down","chatbox","Say")
  end
end)
 

function sayChat(player,_,...)
  local px,py,pz=getElementPosition(player)
  local msg = table.concat({...}, " ")
  	   local players = getPlayerName(player)
	   nick = tostring ( players ):gsub( "_", " " );
  for _,v in ipairs(getElementsByType("player")) do
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) and isPedInVehicle ( player ) then
	      outputChatBox("[Vehicle] "..nick.." says: "..msg,v,255,255,255,true)
    elseif isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
      outputChatBox(""..nick.." says: "..msg,v,255,255,255,true)
    end
	end
  outputServerLog("[Local]: "..nick.." says: ".. msg)
end
addCommandHandler("Say", sayChat)

 

Link to comment
Guest Guest4401

You can use

onPlayerChat
cancelEvent


instead.

This way you only cancel normal messages and manually output whatever you wish.

Try:

 

addEventHandler('onPlayerChat',root,
	function(msg,mt)
		if mt == 0 then
			cancelEvent()
			local px,py,pz=getElementPosition(source)
			local players = getPlayerName(source)
			nick = tostring ( players ):gsub( "_", " " );
			for _,v in ipairs(getElementsByType("player")) do
				if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) and isPedInVehicle ( source ) then
					outputChatBox("[Vehicle] "..nick.." says: "..msg,v,255,255,255,true)
				elseif isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then
					outputChatBox(""..nick.." says: "..msg,v,255,255,255,true)
				end
			end
			outputServerLog("[Local]: "..nick.." says: ".. msg)
		end
	end
)

 

Edited by Guest4401
Link to comment

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...