AHSS Posted June 14, 2011 Share Posted June 14, 2011 is there a way to make a new chat type like this: bindKey(player, 'l', 'chatbox', 'Localchat') and then script what happens when the player types in the chat and press enter is this possible? thanks in advance Link to comment
Callum Posted June 14, 2011 Share Posted June 14, 2011 If I recall correctly, you have to use addCommandHandler to bind "Localchat" to a function. From that function, you can create a new 'chat type'. Link to comment
AHSS Posted June 14, 2011 Author Share Posted June 14, 2011 Can you explain more please? Perhaps give me an example? thanks. Link to comment
will briggs Posted June 14, 2011 Share Posted June 14, 2011 Hey, I have wrote you a code, Not tested but works hopefully.... You said new chat type, So ive created a local one... I think thats what u mean... 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,i,...) local px,py,pz=getElementPosition(player) local nick=getPlayerName(player) local msg = table.concat({...}, " ") for i,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("(local)"..nick..": #ffffff"..msg,v,255,255,255,true) end end end addCommandHandler("Local",onChat) Link to comment
Chlorek Posted June 14, 2011 Share Posted June 14, 2011 will brigga, is it chat which show msg for nearly players, is it not? Link to comment
Castillo Posted June 14, 2011 Share Posted June 14, 2011 What will briggs posted is an script from another topic, and yes, it should be to chat with nearly players only. Link to comment
will briggs Posted June 14, 2011 Share Posted June 14, 2011 Ok, Yeah i presumed from the title you wanted a local chat and your code example... Sorry im only trying to help EDIT : Castillo you left SANL? Link to comment
Castillo Posted June 14, 2011 Share Posted June 14, 2011 I'm not saying that's wrong, you helped him doing that (in my opinion). And, no, I didn't left SANL. Link to comment
Chlorek Posted June 14, 2011 Share Posted June 14, 2011 and I have one question about scripting chat: is it possible to make upper script like this it can be detected as normal chat? I think about it's detected by eg. onPlayerChat handler. Link to comment
will briggs Posted June 14, 2011 Share Posted June 14, 2011 Chlorek said: make upper script like this it can be detected as normal chat? I What? What is this? Link to comment
Chlorek Posted June 14, 2011 Share Posted June 14, 2011 will, I mean is it possible to make new chat which is same as standardly chat (abilty to write cmds by using slash etc). Link to comment
will briggs Posted June 14, 2011 Share Posted June 14, 2011 Im not sure thats posible... Sorry 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