ta_programavel Posted April 26, 2016 Share Posted April 26, 2016 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? Fonte: https://wiki.multitheftauto.com/wiki/Ge ... iedVehicle Link to comment
RenanPG Posted April 26, 2016 Share Posted April 26, 2016 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
ta_programavel Posted April 26, 2016 Author Share Posted April 26, 2016 Agora sim, está tudo funcionando. Obrigado, podem fechar o post Link to comment
ta_programavel Posted April 26, 2016 Author Share Posted April 26, 2016 Aproveitando o post existe alguma maneira de criar uma variável que é acessível tanto em um script client e server? Link to comment
ta_programavel Posted April 27, 2016 Author Share Posted April 27, 2016 Agora sim, podem fechar, achei o que queria: https://wiki.multitheftauto.com/wiki/AddEvent Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now