Sign in to follow this  
Hugos

help create commands, please.

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?

 

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post
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?

Share this post


Link to post
Posted (edited)

I want to make here so: /todo Text * RP player's.

vB24pjO.png

Edited by Hugos

Share this post


Link to post

+ edit 9 line

outputChatBox("«" ..string.gsub(message, "*", " - ").. "»#C2A2DA, - told " ..getPlayerName(player).. ", ", v, 200, 200, 200, true)

 

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.