Norby127 Posted September 12, 2022 Share Posted September 12, 2022 (edited) Hello! Why the /me not working properly? I tried to solve but i can't :/. The problem is when the player type just /me the script doesn't react to that. And if i type after the /me many spaces the msg is sent. Here's the code: function sendMessage( message,messageType) if messageType == 1 then -- /me cancelEvent() sendMe(source,message) end end addEventHandler ( "onPlayerChat", root,sendMessage) function sendMe(source,...) local check = ... local msg = table.concat({...}, " ") if not check then outputChatBox("#77ba50Usage:#FFFFFF /me [text]",source,255,0,0,true) else local name = string.gsub(getPlayerName(source),"_"," ") pX,pY,pZ = getElementPosition(source) local zone = createColSphere(pX,pY,pZ,range) for _, thePlayer in ipairs(getElementsWithinColShape(zone,"player")) do outputChatBox(colorME.."*** "..name.." "..msg,thePlayer,255,0,0,true) end destroyElement(zone) end outputChatBox(string.len(msg),source) end Edited September 12, 2022 by Norby127 Link to comment
Tails Posted September 12, 2022 Share Posted September 12, 2022 (edited) I think you have to cancel onPlayerCommand. Otherwise try doing it on the client side instead. https://wiki.multitheftauto.com/wiki/OnPlayerCommand Edited September 12, 2022 by Tails Link to comment
AngelAlpha Posted September 12, 2022 Share Posted September 12, 2022 4 hours ago, Norby127 said: Hello! Why the /me not working properly? I tried to solve but i can't :/. The problem is when the player type just /me the script doesn't react to that. And if i type after the /me many spaces the msg is sent. Here's the code: function sendMessage( message,messageType) if messageType == 1 then -- /me cancelEvent() sendMe(source,message) end end addEventHandler ( "onPlayerChat", root,sendMessage) function sendMe(source,...) local check = ... local msg = table.concat({...}, " ") if not check then outputChatBox("#77ba50Usage:#FFFFFF /me [text]",source,255,0,0,true) else local name = string.gsub(getPlayerName(source),"_"," ") pX,pY,pZ = getElementPosition(source) local zone = createColSphere(pX,pY,pZ,range) for _, thePlayer in ipairs(getElementsWithinColShape(zone,"player")) do outputChatBox(colorME.."*** "..name.." "..msg,thePlayer,255,0,0,true) end destroyElement(zone) end outputChatBox(string.len(msg),source) end addCommandHandler ("me", function(pl, _, ...) local message = table.concat({...}, " ") if message:gsub(" ", "") == "" then outputChatBox ("#77ba50Usage:#FFFFFF /me [text]", pl, 255, 0, 0, true) return end local pos1 = Vector3 (getElementPosition(pl)) for i, v in ipairs (getElementsByType("player")) do local pos2 = Vector3 (getElementPosition(v)) if getDistanceBetweenPoints3D (pos1, pos2) <= 20 then -- 20 - this range outputChatBox ("*** "..getPlayerName(pl).." "..message, v, 255, 200, 0, true) end end end) Try this code Link to comment
Norby127 Posted September 13, 2022 Author Share Posted September 13, 2022 No it's not working unfortenetly Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now