Jump to content

separate chat for VIP


Samking

Recommended Posts

 local isPlayerInGroup, onChat
     
local function onChatCommand (player)
    if isPlayerInGroup (player, "VIP") then
        onChat (player)
    else
        outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true)
    end 
end
addCommandHandler("v", onChatCommand)

chat_range=10000000 
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index, player in pairs(getElementsByType("player")) do 
  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) 
local r,g,b = getTeamColor(getPlayerTeam(player)) 
  for _,v in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox("[VIP Chat]"..nick..": #ffffff"..msg,v,255,0,255,true) 
    end 
  end 
end 

function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( player )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            return true
        end
    end
    return false
end
  
  

Can someone tell me how to make separate VIP chat and that can visible to those who are in the VIP group?

 

I am getting this error

Bad argument @ 'getTeamColor' [Expected team at argument 1 , got boollean]

 

Can someone make code and send me plz 

Thanks!

Link to comment

Yes that not about acl that is for game teams which player it in your are not in a team

4 minutes ago, Samking said:

before the test, I set myself in VIP group 

but still giving me the error 

 

 local isPlayerInGroup, onChat
     
local function onChatCommand (player)
    if isPlayerInGroup (player, "VIP") then
        onChat (player)
    else
        outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true)
    end 
end
addCommandHandler("v", onChatCommand)

chat_range=10000000 
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index, player in pairs(getElementsByType("player")) do 
  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("[VIP Chat]"..nick..": #ffffff"..msg,v,255,0,255,true) 
    end 
  end 
end 

function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( player )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            return true
        end
    end
    return false
end
  
  

 

Link to comment
1 hour ago, Dimos7 said:

Yes that not about acl that is for game teams which player it in your are not in a team

 


 local isPlayerInGroup, onChat
     
local function onChatCommand (player)
    if isPlayerInGroup (player, "VIP") then
        onChat (player)
    else
        outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true)
    end 
end
addCommandHandler("v", onChatCommand)

chat_range=10000000 
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
end) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index, player in pairs(getElementsByType("player")) do 
  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("[VIP Chat]"..nick..": #ffffff"..msg,v,255,0,255,true) 
    end 
  end 
end 

function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( player )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            return true
        end
    end
    return false
end
  
  

 

how can I create a chat for acl?

 

Link to comment
function vipChat(thePlayer, _,...) 
  local message = table.concat ({...}, " ") 
  for _, v in ipairs (getElementsByType("player")) do
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("VIP")) then
      outputChatBox("[VIP Chat]".. getPlayerName(thePlayer).. ":#ffffff ".. message, v, 255, 0, 255, true) 
      else 
      return outputChatBox("You are not VIP", thePlayer, 255, 0, 0)
      end
    end
  end 
addCommandHandler("v", vipChat) 

 

Edited by Dimos7
Link to comment
1 hour ago, Dimos7 said:

function vipChat(thePlayer, _,...) 
  local message = table.concat ({...}, " ") 
  for _, v in ipairs (getElementsByType("player")) do
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("VIP")) then
      outputChatBox("[VIP Chat]".. getPlayerName(thePlayer).. ":#ffffff ".. message, v, 255, 0, 255, true) 
      else 
      return outputChatBox("You are not VIP", thePlayer, 255, 0, 0)
      end
    end
  end 
addCommandHandler("v", vipChat) 

 

thanks but this visible to only VIPs?

 

Link to comment

Didn't read all the comments but:
 

local r,g,b = 255, 255, 255
if getPlayerTeam(player) then
  if getTeamColor(getPlayerTeam(player)) then
  	r,g,b = getTeamColor(getPlayerTeam(player))
  end
end
  

With this you don't get error if team's color didn't set. 

Edited by sanyisasha
Link to comment

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