Jump to content

new chat type


AHSS

Recommended Posts

Posted

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

Posted

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'.

Retired

Posted

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) 

Founder of SAUR - Founder/Owner of ARC RPG

Posted

What will briggs posted is an script from another topic, and yes, it should be to chat with nearly players only.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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?

Founder of SAUR - Founder/Owner of ARC RPG

Posted

I'm not saying that's wrong, you helped him doing that (in my opinion).

And, no, I didn't left SANL.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...