Jump to content

chat por element data


Recommended Posts

Queria por esse chat para somente se a pessoa tem tal element data conseguir visualizar e escrever, ele está por acl, tentei por por element data mais não consegui, entendo um pouco sobre, fiz para aparecer blip e mensagem no chat, porém não consigo fazer um bate papo.
 

ComandoDoChatGlobal =                "copom" 


function adminchat ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
    for _, player in ipairs ( getElementsByType ( "player" ) ) do
    if ( isPlayerOnGroup ( player ) ) then


	conta = getAccountName(getPlayerAccount(thePlayer))					

	if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Policial" ) ) then
        if getElementData ( source, "TrabalhoPolicial", true ) then
	outputChatBox("#FF0000[Facção#FF0000]#ffffff "..getPlayerName(thePlayer).. "#FF0000:#ffffff "..message, player, 255, 255, 255, true)
	
	elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Policial" ) ) then
                if getElementData ( source, "TrabalhoPolicial", true ) then
	outputChatBox("#FF0000[Facção#FF0000]#ffffff "..getPlayerName(thePlayer).. "#FF0000:#ffffff "..message, player, 255, 255, 255, true)

	end
    end
    end
    end
end
end
	setElementData ( thePlayer, "Chat:Avisado", true )
	setElementData ( thePlayer, "Chat:Delay1",true )
    setTimer ( setElementData, 5000, 1, thePlayer, "Chat:Delay1", false )
end
addCommandHandler ( ComandoDoChatGlobal, adminchat )

--------------------------------------------------------------------------------------------

function isPlayerOnGroup ( thePlayer )
    local account = getPlayerAccount ( thePlayer )
    local inGroup = false
    for _, group in ipairs ( { "Policial" } ) do  
    if isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( "Policial" ) )   then
    inGroup = true
    break
    end
    end
    return inGroup
end

 

Link to comment

creio que em vez de "source" você teria que usar o "player",  para filtrar o loop para somente as pessoas que tem o element data
e o "elseif" aparenta estar fazendo a mesma coisa que o "if" acima então tirei e indentei o codigo
 

ComandoDoChatGlobal = "copom" 

function adminchat ( thePlayer, _, ... )
local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            if ( isPlayerOnGroup ( player ) ) then
            conta = getAccountName(getPlayerAccount(thePlayer))					
                if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Policial" ) ) then
                    if getElementData(player, "TrabalhoPolicial") == true then
	                outputChatBox("#FF0000[Facção#FF0000]#ffffff "..getPlayerName(thePlayer).. "#FF0000:#ffffff "..message, player, 255, 255, 255, true)
                    end
                end
            end
        end
    end
	setElementData ( thePlayer, "Chat:Avisado", true )
	setElementData ( thePlayer, "Chat:Delay1",true )
    setTimer ( setElementData, 5000, 1, thePlayer, "Chat:Delay1", false )
end
addCommandHandler ( ComandoDoChatGlobal, adminchat )

function isPlayerOnGroup ( thePlayer )
local account = getPlayerAccount ( thePlayer )
local inGroup = false
    for _, group in ipairs ( { "Policial" } ) do  
        if isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( "Policial" ) )   then
        inGroup = true
        break
        end
     end
    return inGroup
end

 

Edited by SciptNovato
  • Thanks 1
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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