Jump to content

problem


manve1

Recommended Posts

Posted

i have a problem on my script which i don't know how to fix.

chat_range=9999 
  
addEventHandler("onPlayerJoin",getRootElement(), 
function (p) 
if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Admin" ) ) then 
bindKey(source,"u","down","chatbox","GOOC") 
end 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function (p) 
if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Admin" ) ) then 
for index, player in pairs(getElementsByType("player")) do 
bindKey(player,"u","down","chatbox","GOOC") 
  end 
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, p, _, ...) 
 if isObjectInACLGroup ( "user." ..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Admin" ) ) then 
  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("(GOOC) ".. nick ..": "..msg,v,r,g,b,true) 
    end 
  end 
 end 
end 
addCommandHandler("GOOC",onChat) 

wKbvI.png

P.S. This script is taken from community

Posted

Why do you need to check whether or not the resource is in the "Admin" ACL group? As far as I can see, the conditional check at line 12 can be removed entirely.

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