Baseplate Posted June 6, 2011 Posted June 6, 2011 Hey all I would like to have a local chat so please help me
karlis Posted June 6, 2011 Posted June 6, 2011 chat_range=100 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,_,msg) local px,py,pz=getElementPosition(player) local nick=getPlayerName(player) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("[local]"..nick..": #ffffff"..msg,v,30,30,200,true) end end end addCommandHandler("l",onChat) [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Aibo Posted June 6, 2011 Posted June 6, 2011 -- code what about MTA's getDistanceBetweenPoints3D? https://wiki.multitheftauto.com/wiki/Get ... enPoints3D ?
karlis Posted June 6, 2011 Posted June 6, 2011 yep, would be same, but i doubt that its more efficient to call a function for simple math. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
karlis Posted June 6, 2011 Posted June 6, 2011 errors? you have to use /l text btw. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Baseplate Posted June 6, 2011 Author Posted June 6, 2011 Can you make it a bind? I tought It was a bind so I pressed l wait
karlis Posted June 6, 2011 Posted June 6, 2011 i don't know how to open chatbox with custom textbox [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
karlis Posted June 6, 2011 Posted June 6, 2011 (edited) try bindKey("L","chatbox: l") doubt it will work tough(thats just the syntax binds use for default chatbox inputs). Edited June 7, 2011 by Guest [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Castillo Posted June 6, 2011 Posted June 6, 2011 chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"L","down","chatbox","L") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"L","down","chatbox","L") 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,_,msg) local px,py,pz=getElementPosition(player) local nick=getPlayerName(player) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("[local]"..nick..": #ffffff"..msg,v,30,30,200,true) end end end addCommandHandler("L",onChat) I think that should work. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators Citizen Posted June 6, 2011 Moderators Posted June 6, 2011 Personnaly I create a colsphere, I send the message for every players in it, and then I destroy the colShape. The rEvolution is coming ...
karlis Posted June 7, 2011 Posted June 7, 2011 meh imo colsphere is a waste. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
laserlaser Posted June 7, 2011 Posted June 7, 2011 Try; chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"L","down","chatbox","Local") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"L","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 args = { ... } local message = "" for _,arg in ipairs(args) do if message == "" then message = arg else message = message .. " " .. arg end local px,py,pz=getElementPosition(player) local nick=getPlayerName(player) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("[LOCAL]"..nick..": #ffffff"..message,v,30,30,200,true) end end end addCommandHandler("Local",onChat)
Baseplate Posted June 7, 2011 Author Posted June 7, 2011 hmm @laserlaser:It dosen't work @Castillo:huh I press 'l' and it works fine but it only write one word like that if we say like :Kill Him it writes only Kill
laserlaser Posted June 7, 2011 Posted June 7, 2011 hmm @laserlaser:It dosen't work Why, i use this.and it work.
Castillo Posted June 7, 2011 Posted June 7, 2011 chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"L","down","chatbox","L") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"L","down","chatbox","L") 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) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("[local]"..nick..": #ffffff"..msg,v,30,30,200,true) end end end addCommandHandler("L",onChat) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Baseplate Posted June 7, 2011 Author Posted June 7, 2011 I'll try it and I'll edit the post with the end EDIT:Yeah Castillo it works fine thank you all
karlis Posted June 7, 2011 Posted June 7, 2011 but try replace "chatbox" with "chatbox: local say", see if it works and does it change tile for the writing box. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Castillo Posted June 7, 2011 Posted June 7, 2011 Karlis, if you do that the bind won't work at all. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
karlis Posted June 8, 2011 Posted June 8, 2011 ok, then the option bind syntax is a bit confusing [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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