Jump to content

[Ajuda] com getPedOccupiedVehicle


Recommended Posts

Olá, peguei um script de exemplo no site do MTA que usa a função getPedOccupiedVehicle.

O problema é o seguinte, o código sempre retorna para mim que não estou em um veículo (mesmo dirigindo ava). O meu script está funcionando como client.

  
function showVehicleName ( thePlayer ) 
   local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
   if theVehicle then 
      outputChatBox ( "Name of the Vehicle: " .. getVehicleName ( theVehicle ), thePlayer ) 
   else 
      outputChatBox ( "You do not have a Vehicle!", thePlayer, 255, 0, 0, true ) 
   end 
end 
addCommandHandler ( "getcarname", showVehicleName ) 

meta.xml:

  
<meta> 
    <script src="script.lua" type="client" /> 
</meta> 

O que pode ser? Já usei também o getPlayerOccupiedVehicle e continua igual. Alguém? :D

Fonte: https://wiki.multitheftauto.com/wiki/Ge ... iedVehicle

Link to comment

Somente em server o player é passado como parâmetro(no caso thePlayer).

function showVehicleName () 
   local theVehicle = getPedOccupiedVehicle (localPlayer) 
   if theVehicle then 
      outputChatBox ( "Name of the Vehicle: " .. getVehicleName ( theVehicle ), thePlayer ) 
   else 
      outputChatBox ( "You do not have a Vehicle!", thePlayer, 255, 0, 0, true ) 
   end 
end 
addCommandHandler ( "getcarname", showVehicleName ) 

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