Bean666 Posted January 1, 2015 Share Posted January 1, 2015 hi , is it possible for local chat to do commands in it? because i have a global chat as O and local chat as T. and i want to make it to be able to do commands NOTE: The script is not mine , i just downloaded it from the community and edited a little bit. here is the local chat code: chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"u","down","chatbox","Local") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"u","down","chatbox","Local") end end) function isPlayerInRangeOfPoint(player,x,y,z,range) local px,py,pz=getElementPosition(player) return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range end function onChat(player,_,...) local px,py,pz=getElementPosition(player) local msg = table.concat({...}, " ") local nick=getPlayerName(player) local r,g,b = getTeamColor(getPlayerTeam(player)) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("(Local) "..nick..": "..msg,v,r,g,b,true) end end end addCommandHandler("Local",onChat) Link to comment
Castillo Posted January 1, 2015 Share Posted January 1, 2015 Well, you could edit it to be able to support commands. Things you would need: string.find string.gsub executeCommandHandler Link to comment
Bean666 Posted January 1, 2015 Author Share Posted January 1, 2015 could u give a small example? please. so i could understand easily. , sorry i'm currently new in these kind of things Link to comment
MTA Team botder Posted January 1, 2015 MTA Team Share Posted January 1, 2015 local msg = table.concat({...}, " ") if msg:find("/") == 1 and msg:len() > 1 then -- Command local cmd, params = msg:match("/(%S+)%s*(.*)") return executeCommandHandler(cmd, player, params) else -- Message -- ... end Link to comment
Castillo Posted January 1, 2015 Share Posted January 1, 2015 Problem of this is, that it only runs your server side commands, it won't trigger any client side command. 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