dugasz1 Posted May 12, 2013 Share Posted May 12, 2013 (edited) Hello! I found a new local chat script. It's working just when a write a command (example.: /reconnect) It's writing out in the cahtbox /reconenct. I searching on the internet and now the script know what is command what it's simple message,but i don't know what can i do whit the command how i can use. chat_range=5 function bindOnJoin() bindKey(source,"t","down","chatbox","Mondod") end addEventHandler("onPlayerJoin",getRootElement(),bindOnJoin) function bindRStart() for index, player in pairs(getElementsByType("player")) do bindKey(player,"t","down","chatbox","Mondod") end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), bindRStart) 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) if string.sub(msg, 1, 1) == "/" then --What should here write? else for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox(nick.." mondja: "..msg,v,255,255,255,true) end end end end addCommandHandler("Mondod",onChat) Edited May 12, 2013 by Guest Link to comment
dugasz1 Posted May 12, 2013 Author Share Posted May 12, 2013 Sorry. So, here's this local chat script only the nerby players see the message. I binded it "t" key it's overwrite the original chat. Now when i want to use a command (example /login or /reconnect or my commands) there's aren't work just send the command in the chatbox the commands don't work. At line 24 the script check it's a command or just a message but if it's a command i don't know what can i do whit it to i can use it. Note: In the script "mondod" / "mondja" are hungarian words means "say" Link to comment
xXMADEXx Posted May 13, 2013 Share Posted May 13, 2013 As far as i know, the only way to use commands are though the console (F8) or the mian chat box, that isn't re-scripted. Link to comment
dugasz1 Posted May 13, 2013 Author Share Posted May 13, 2013 I don't know how but it's possible. I saw a server whit local chat and binded to "t" Link to comment
Guest Guest4401 Posted May 13, 2013 Share Posted May 13, 2013 return executeCommandHandler(split(msg,' ')[1]:gsub("/",""),player,msg:gsub(split(msg,' ')[1],'')) Link to comment
dugasz1 Posted May 13, 2013 Author Share Posted May 13, 2013 if string.sub(msg, 1, 1) == "/" then executeCommandHandler(split(msg,' ')[1]:gsub("/",""),player,msg:gsub(split(msg,' ')[1],'')) else for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox(nick.." mondja: "..msg,v,255,255,255,true) end end end I copyed it. Now the if is look like this. But it's still don't work. No error message. EDIT: No sorry, it's working just i tryed hardcoded (reconnect,quit) commands. Whit harcoded don't work but it isn't problem. Thank you very much Link to comment
myonlake Posted May 13, 2013 Share Posted May 13, 2013 If you really want to replace 'T' then you might as well use onPlayerChat and cancelEvent. Then just make it display everything locally. 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