Jump to content

Problemas com getElementModel


Recommended Posts

Estou querendo fazer com que o comando seja executado apenas dentro de um veículo específico (id 596), porém não está funcionando corretamente, e mesmo que eu esteja dentro do veículo aparece a mensagem que era pra mostrar apenas se eu não estivesse no veículo.

function verPorte ( player, cmd, name, theVehicle)
  local alvo = findPlayer(name)
  local id = getElementModel(theVehicle)
  if id == 596 then
    if name and getElementData(alvo, "porte") == true then
      outputChatBox("O(a) " ..getPlayerName(alvo).. " possui um porte de arma válido.", player, 255,255,255, true)
      else
      outputChatBox("O(a) " ..getPlayerName(alvo).. " não possui um porte de arma valido.", player, 255,255,255, true)
      end
    else
    outputChatBox("Você não esta em uma viatura policial.", player, 255,255,255, true)
    end
  end
addCommandHandler("vporte", verPorte)

 

Link to comment
  • Other Languages Moderators

theVehicle nesse caso é uma string. Não tem como usar getElementModel em uma string.

Tente isso:

function verPorte (thePlayer, cmd, name)
	local alvo = findPlayer (thePlayer) -- Essa função não existe. Espero que vc tenha criado ela em outro lugar.
	if (getPedOccupiedVehicle (thePlayer)) then
		local id = getElementModel (getPedOccupiedVehicle (thePlayer))
		if (id == 596) then
			if (name and getElementData (alvo, "porte") == true) then
				outputChatBox ("O(a) "..getPlayerName (alvo).."#FFFFFF possui um porte de arma válido.", thePlayer, 255, 255, 255, true)
			else
				outputChatBox ("O(a) "..getPlayerName (alvo).."#FFFFFF não possui um porte de arma valido.", thePlayer, 255, 255, 255, true)
			end
		else
			outputChatBox ("Você não está em uma viatura policial.", thePlayer, 255, 255, 255)
		end
	else
		outputChatBox ("Você não está em um veículo.", thePlayer, 255, 255, 255)
	end
end
addCommandHandler ("vporte", verPorte)

 

Edited by Lord Henry
  • Thanks 1
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...