Jump to content

Não está reconhecendo o ID do jogador - chat.


Recommended Posts

Bom, não está reconhecendo o id do jogador quando digita num chat, está dando N/A.

Print: https://prnt.sc/u6ikjl
 

Código do chat: 


ComandoDoChatGlobal =                "cp" ----COMANDO PARA UTILIZAR NO CHAT Ex:( /cp OI )


function adminchat ( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    local ID = getElementData(source, "ID") or "N/A"
    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 ----ACL DE QUEM VAI VER/USAR O CHAT
	outputChatBox("#ffFFFF| #FFA500COPOM #ffFFFF|#FFA500  "..getPlayerName(thePlayer).. "  #ffffff["..ID..")  » :#FFA500 "..message, player, 255, 255, 255, true)
	
	elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Policial" ) ) then ----ACL DE QUEM VAI VER/USAR O CHAT
	outputChatBox("#ffFFFF| #FFA500COPOM #ffFFFF|#FFA500  "..getPlayerName(thePlayer).. "  #ffffff["..ID..")   » :#FFA500 "..message, player, 255, 255, 255, true)

	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 ----ACL DE QUEM VAI VER/USAR O CHAT
    if isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( group ) )   then
    inGroup = true
    break
    end
    end
    return inGroup
end

 

Link to comment
addEventHandler("onPlayerLogin", getRootElement(),
  function(_, conta)
   setElementData(source, 'ID', getAccountID (conta))
  end)

Parece que seu getElementData() da linha 7 está retornando nil e assim está setando N/A no ID. Tenta colocar esse código acima e vê se funciona

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