Jump to content

help create commands, please.


Hugos

Recommended Posts

I have a "/do" team, want to make still "/todo". It works approximately so:

function doChat(player, cmd, ...)
	if ... then
		local message = table.concat({...}, "")
		for i, v in pairs(getElementsByType("player")) do
			local x, y, z = getElementPosition(player)
			local xt, yt, zt = getElementPosition(v)
			if getDistanceBetweenPoints3D(x, y, z, xt, yt, zt) <= 10 then
				outputChatBox("" ..message.. " (" ..getPlayerName(player).. ")", v, 194, 162, 218, true)
			end
		end
	end
end
addEventHandler("CommmandHandler", getRootElement(), doChat)
addCommandHandler("do", doChat)


The player writes the message:  todo text1*text2
As a result to the player such message is displayed: nickname text1 - told text2

How to me to replace "*" with the text necessary to me?

 

Link to comment

I do not understand what you are trying to do, could you explain better?

function doChat(player, command, ...)
	if ... then
		local message = table.concat({...}, "")
		for i, v in pairs(getElementsByType("player")) do
			local x, y, z = getElementPosition(player)
			local xt, yt, zt = getElementPosition(v)
			if getDistanceBetweenPoints3D(x, y, z, xt, yt, zt) <= 10 then
				outputChatBox(string.gsub(message, "*", " - ").." (" ..getPlayerName(player).. ")", v, 194, 162, 218, true)
			end
		end
	end
end
addEventHandler("CommmandHandler", getRootElement(), doChat)
addCommandHandler("do", doChat)

I did what I understood.

replace "*" with " - "

Edited by Tommy.
  • Thanks 1
Link to comment
7 hours ago, Tommy. said:

I do not understand what you are trying to do, could you explain better?


function doChat(player, command, ...)
	if ... then
		local message = table.concat({...}, "")
		for i, v in pairs(getElementsByType("player")) do
			local x, y, z = getElementPosition(player)
			local xt, yt, zt = getElementPosition(v)
			if getDistanceBetweenPoints3D(x, y, z, xt, yt, zt) <= 10 then
				outputChatBox(string.gsub(message, "*", " - ").." (" ..getPlayerName(player).. ")", v, 194, 162, 218, true)
			end
		end
	end
end
addEventHandler("CommmandHandler", getRootElement(), doChat)
addCommandHandler("do", doChat)

I did what I understood.

replace "*" with " - "

Yes is that I wanted. And whether it is possible to make still color to "*" and after "*" a miscellaneous?

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