Jump to content

Ajuda ID Player


Recommended Posts

Posted

Olá, Estou com problemas com o sistema de id player.

No meu comando eu uso para puxar um player usando o id dele e não o nick, mais ai que esta o problema o player nao tem um id fixo. 

no scoreboard tem um id fixo mais quando puxo não tem.

no score board marca assim exemplo :   

ID 1 Giio

ID 2 Fulano   

se o ID 1 Desloga automatico o 2 fulano vira o id 1 mais você não ve, no scoreboard continua ID 2, oque seria ??

  • Moderators
Posted

Sem código fica difícil adivinhar.

Mas já vou logo adiantando que vc usa o getAccountID.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

Se não tiver funcionando corretamente, baixe um sistema de ID funcional ou apenas use a função mencionada acima.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
21 hours ago, Lord Henry said:

Sem código fica difícil adivinhar.

Mas já vou logo adiantando que vc usa o getAccountID.

 

19 hours ago, DNL291 said:

Se não tiver funcionando corretamente, baixe um sistema de ID funcional ou apenas use a função mencionada acima.


function getPlayer(player, cmd, id)
	if tonumber(id) then
		local mx, my, mz = getElementPosition(player)
		local player2 = getPlayerFromID ( tonumber(id) )
		if not player2 or not isElement(player2) then
			return outputChatBox( "Player Offline", player )
		end
		local trplayername = getPlayerName(player):gsub("#%x%x%x%x%x%x","")
		local rand = math.random(1, 5)
		setElementPosition(player2, mx+rand, my+rand, mz + 1)
		
		for i, p in ipairs(getElementsByType("player")) do
			local xp, yp, zp = getElementPosition ( p )
			
			if getDistanceBetweenPoints3D ( mx, my, mz, xp, yp, zp ) <= 50 then
				outputChatBox ( "#c9c9c9[#1a6cefFW-COMANDO#c9c9c9]O #1a6cef".. trplayername .."#c9c9c9 Puxou o #1a6cef".. tostring(id), p, 255, 0, 0, true );
			end
		end
	end
end
addCommandHandler("tr", getPlayer)

Esse é o comando onde uso para puxar o player usando o id em vez do nome

 

function getIDFromPlayer(player)
	if player then
		local theid
		players = getElementsByType("player")
		for id,p in ipairs(players) do
			if player == p then
				theid = i
			end
		end
		return theid
	else return false end
end

function getPlayerFromID(theID)
	if theID then
		theID = tonumber(theID)
		local theplayer
		players = getElementsByType("player")
		for id,p in ipairs(players) do
			if theID == id then
				theplayer = p
			end
		end
		return theplayer
	else return false end
end

Esse  é para pegar o id do player

  • Moderators
Posted

Essa sua função getPlayerFromID está errada. Não tem nada a ver com ID dos jogadores, apenas com o índice daquele loop. Dai é óbvio que não vai retornar o mesmo ID pro mesmo jogador.

function getPlayerFromID (theID)
	if (tonumber (theID)) then
		theID = tonumber (theID)
		local players = getElementsByType ("player")
		for id, p in ipairs (players) do
			local accID = getAccountID (getPlayerAccount (p))
			if (theID == accID) then
				return p
			end
		end
		return false
	else
		return false
	end
end

 

  • Thanks 1

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted
8 hours ago, Lord Henry said:

Essa sua função getPlayerFromID está errada. Não tem nada a ver com ID dos jogadores, apenas com o índice daquele loop. Dai é óbvio que não vai retornar o mesmo ID pro mesmo jogador.


function getPlayerFromID (theID)
	if (tonumber (theID)) then
		theID = tonumber (theID)
		local players = getElementsByType ("player")
		for id, p in ipairs (players) do
			local accID = getAccountID (getPlayerAccount (p))
			if (theID == accID) then
				return p
			end
		end
		return false
	else
		return false
	end
end

 

Entendi, vou tentar testar com alguem jaja

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