Jump to content

Script de arrastar


Recommended Posts

Posted

estou tendo um erro em um script para arrastar a pessoa para o carro do policial , ele inicia o script mas não funciona e não apresenta nenhum erro. 

function seguirComando(player, commandName, playerid)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (player)), aclGetGroup ("ComandosCorporacoes")) then 

	if not (playerid) then return end
	
	local alvo = exports["ID_System"]:getPlayerID(tonumber(playerid))
	if not (alvo) then
		return player:outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
	end
end
end
if getElementData(alvo,"Algemado") then
	alvox,alvoy,alvoz = getElementPosition (alvo)
	playerx,playery,playerz = getElementPosition (player)
		local dist = GetDistanceBetweenPoints3D(alvox,alvoy,alvoz,playerx,playery,playerz)
		if (dist <=5) then
		local vehicle = getPedOccupiedVehicle(player))
		if vehicle then
			warpPedIntoVehicle (alvo , vehicle , 2)
		end
	
end
addCommandHandler("arrastar", seguirComando)

 

Posted (edited)
function seguirComando(player, commandName, playerid)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (player)), aclGetGroup ("ComandosCorporacoes")) then 

		if not (playerid) then return end
		
		local alvo = exports["ID_System"]:getPlayerID(tonumber(playerid))
		if not (alvo) then
			return player:outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
		end
		
		if getElementData(alvo,"Algemado") then
			alvox,alvoy,alvoz = getElementPosition (alvo)
			playerx,playery,playerz = getElementPosition (player)
			local dist = getDistanceBetweenPoints3D(alvox,alvoy,alvoz,playerx,playery,playerz)
			if (dist <=5) then
				local vehicle = getPedOccupiedVehicle(player)
				if vehicle then
					warpPedIntoVehicle (alvo , vehicle , 2)
				end
			end
		end
		
	end
end
addCommandHandler("arrastar", seguirComando)

 

Edited by MaligNos
Posted

Troque por isso e me diga o resultado da depuração.

				local vehicle = getPedOccupiedVehicle(player)
				if vehicle then
  					outputChatBox ("@Jogador preso no veículo.", player, 0, 255, 0)
					warpPedIntoVehicle (alvo , vehicle , 2)
				else
  					outputChatBox ("@Erro você não esta em um veículo.", player, 255, 120, 23)
  				end

 

Posted
43 minutes ago, Renazz said:

não apresenta nenhum erro. 

Como chegou a tal conclusão ? certamente se tivesse usado o /debugscript 3 diversos erros apareceriam, você precisa executar o trecho para que os erros aparecessem: /arrastar

Tem um trecho POO incorreto, troque por:

if not (alvo) then
	return outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
end

 

Posted
function seguirComando(player, commandName, playerid)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (player)), aclGetGroup ("ComandosCorporacoes")) then 

		if not (playerid) then return end
		
		local alvo = exports["[LusoRP](Sistema)ID_System"]:getPlayerID(tonumber(playerid))
		if not (alvo) then
			return outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
end
			if getElementData(alvo,"Algemado") then
			alvox,alvoy,alvoz = getElementPosition (alvo)
			playerx,playery,playerz = getElementPosition (player)
			local dist = getDistanceBetweenPoints3D(alvox,alvoy,alvoz,playerx,playery,playerz)
			if (dist <=6) then
				local vehicle = getPedOccupiedVehicle(player)
				if vehicle then
					warpPedIntoVehicle (alvo , vehicle , 3)
				end
			end
		end	
	end
end
addCommandHandler("puxar", seguirComando)

ficou desse jeito e ainda não funciona e não apresenta erros.

16 minutes ago, Jonas^ said:

testei desse jeito também e deu não funcionou na mesma

Posted (edited)

Certo, não apresenta mais erros, mas você está agindo de acordo com as verificações do script ?

  • Está no grupo da ACL ComandosCorporacoes ?
  • Essa função exportada de ID realmente funciona e retorna um player ?
  • Está digitando um ID existente ? Ex: /arrastar 1
  • O player alvo possui o elementdata “Algemado” ?
  • Você estava a uma distância menor ou igual a 6 unidades do player alvo ?
  • Você estava em um veículo quando usou o comando ?
Edited by MaligNos
Posted
2 minutes ago, MaligNos said:
  • Está no grupo da ACL ComandosCorporacoes ?
  • Essa função exportada de ID realmente funciona ?
  • Está digitando um ID existente ? Ex: /arrastar 1
  • O player alvo possui o elementdata “Algemado” ?
  • Você estava a uma distância menor ou igual à 6 unidades do player algo ?
  • Você estava em um veículo quando usou o comando ?

sim estou cumprindo esses fatores todos.

Posted

Até agora to esperando ele resolver mandar print das verificações, mas acredito que o erro esteja no element-data e nem esteja entrando no escopo da verificação.

Posted
1 minute ago, Jonas^ said:

Até agora to esperando ele resolver mandar print das verificações, mas acredito que o erro esteja no element-data e nem esteja entrando no escopo da verificação.

como assim print das verificações?

Posted
22 minutes ago, MaligNos said:

if not (alvo) then
	return outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
end

 

Na realidade seria:

if not (alvo) then
	return outputChatBox("[Aviso] Jogador ' "..playerid.." ' não encontrado!", player,255,255,255)
end

Mas se o seu "alvo" existe, nem entraria nessa verificação. Então não é a causa de não funcionar.

Posted
function seguirComando(player, commandName, playerid)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (player)), aclGetGroup ("ComandosCorporacoes")) then 
		if not (playerid) then return end
		local alvo = exports["[LusoRP](Sistema)ID_System"]:getPlayerID(tonumber(playerid))
		if not (alvo) then
			return outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
		end
		outputChatBox ("@Antes de entrar no escopo executado!.", player)
		if getElementData(alvo,"Algemado") then
			outputChatBox ("@element-data.", player)
			local alvox,alvoy,alvoz = getElementPosition (alvo)
			local playerx,playery,playerz = getElementPosition (player)
			local dist = getDistanceBetweenPoints3D(alvox,alvoy,alvoz,playerx,playery,playerz)
			if (dist <= 6) then
				local vehicle = getPedOccupiedVehicle(player)
				if vehicle then
					outputChatBox ("@Jogador preso no veículo.", player, 0, 255, 0)
					warpPedIntoVehicle (alvo , vehicle , 2)
				else
					outputChatBox ("@Erro você não esta em um veículo.", player, 255, 120, 23)
				end
			end
		end	
	end
end
addCommandHandler ("puxar", seguirComando)

Executa esse código e envie print aqui pra gente ver por favor.

Posted

Impossível não estar executando nenhum dos outputs que coloquei no código.. você esta fazendo algo errado com certeza

Posted (edited)

http://prntscr.com/np28yp

 

function seguirComando(player, commandName, playerid)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (player)), aclGetGroup ("ComandosCorporacoes")) then 
		if not (playerid) then return end
		local alvo = exports["[LusoRP](Sistema)ID_System"]:getPlayerID(tonumber(playerid))
		if not (alvo) then
			return outputChatBox("[Aviso] Jogador ' "..alvo.name.." ' não encontrado!", player,255,255,255)
		end
		outputChatBox ("@Antes de entrar no escopo executado!.", player)
		outputChatBox ("@getElementData: "..tostring(getElementData(player,"Algemado")), player)
		if getElementData(alvo,"Algemado") then
			outputChatBox ("@element-data.", player)
			local alvox,alvoy,alvoz = getElementPosition (alvo)
			local playerx,playery,playerz = getElementPosition (player)
			local dist = getDistanceBetweenPoints3D(alvox,alvoy,alvoz,playerx,playery,playerz)
			if (dist <= 6) then
				local vehicle = getPedOccupiedVehicle(player)
				if vehicle then
					outputChatBox ("@Jogador preso no veículo.", player, 0, 255, 0)
					warpPedIntoVehicle (alvo , vehicle , 2)
				else
					outputChatBox ("@Erro você não esta em um veículo.", player, 255, 120, 23)
				end
			end
		end	
	end
end
addCommandHandler ("puxar", seguirComando)

 

Edited by Renazz
Posted

Coloque um output teste antes de verificar se esta na ACL (linha 2). Notei também uma divergência do comando, antes era /arrastar agora está /puxar, está usando o /puxar né ?

Posted
1 minute ago, MaligNos said:

Coloque um output teste antes de verificar se esta na ACL (linha 2). Notei também uma divergência do comando, antes era /arrastar agora está /puxar, está usando o /puxar né ?

correto.

Posted

Seu erro esta no element-data, acabei de testar aqui:

jmpmqoi.png

O problema então esta onde o player é algemado.

Se quiser testar aí pelo nick, fiz pelo nick pra mim testar pois não tenho o sistema de ID aqui:

addCommandHandler ("prender", function (player, cmd, nick)
	if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount (player)), aclGetGroup ("Admin")) then 
		if not nick then return outputChatBox ("Digite o nick de um jogador", player, 255, 30, 30) end
		local alvo = getPlayerFromPartialName (nick)
		if not alvo then return outputChatBox ("Não encontramos um jogador com esse nick", player, 255, 30, 30) end
		outputChatBox ("@Antes de entrar no escopo executado!.", player)
		outputChatBox ("@getElementData: "..tostring(getElementData(player,"Algemado")), player)
		if getElementData (alvo, "Algemado") then
			outputChatBox ("@element-data.", player)
			local alvox, alvoy, alvoz = getElementPosition (alvo)
			local playerx, playery, playerz = getElementPosition (player)
			local dist = getDistanceBetweenPoints3D (alvox, alvoy, alvoz, playerx, playery, playerz)
			if (dist <= 6) then
				local vehicle = getPedOccupiedVehicle (player)
				if vehicle then
					outputChatBox ("@Jogador preso no veículo.", player, 0, 255, 0)
					warpPedIntoVehicle (alvo , vehicle , 2)
				else
					outputChatBox ("@Erro você não esta em um veículo.", player, 255, 120, 23)
				end
			end
		end	
	end
end)

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

@Renazz

Posted

para colocar por id é so substituir a linha 5 por local alvo = exports["[LusoRP](Sistema)ID_System"]:getPlayerID(tonumber(playerid)) ?

  • Other Languages Moderators
Posted

Precisa ter o resource ID_System instalado e funcionando no servidor.

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