Jump to content

ME-AJUDA-A-CRIAR-ESSE-COMANDO


Recommended Posts

Eu quero criar um comando parecido com esse: 

function SkinPrivK13_1 ( player )
     local accName = getAccountName ( getPlayerAccount (player) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PrivadosK13" ) ) then
        setElementModel(player, 123)
        setElementData(player, "k13",123)
    end
end
addCommandHandler("k13", SkinPrivK13_1)

 

Só que em vez de pegar a skin eu quero pegar um carro ex: Eu quero colocar o comando /meucarroexclusivo ai o carro aparece tlg mas só quem tem tag que poderá pegar esse carro...

Ai aparece no chat somente para o player que executou o comando...

"Você pegou seu carro exclusivo com sucesso"

ALGUÉM ME AJUDA ❤️

Edited by K13
Link to comment
  • Moderators
function comando_criarVeiculo ( player )
	local accName = getAccountName ( getPlayerAccount (player) )
	if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PrivadosK13" ) ) then -- verificar se o jogador está no grupo acl
		local x,y,z = getElementPosition(player) -- obter a localização do jogador
		local veh = createVehicle( id, x,y,z ) -- função para criar o veíoculo; criar nas coordenadas do jogador
		setTimer( warpPedIntoVehicle, 50, 1, player, veh ) -- teleportar o player para dentro em um timer de 50ms
		outputChatBox("Você pegou seu carro exclusivo com sucesso", player) -- mostrar mensagem no chat apenas para o jogador
	end
end
addCommandHandler("meucarroexclusivo", comando_criarVeiculo) -- aqui vai o nome do comando

Em id você define o id do veículo. > https://wiki.multitheftauto.com/wiki/Vehicle_IDs

Lembre-se de postar aqui da próxima vez: https://forum.multitheftauto.com/forum/127-programação-em-Lua/

@K13

  • Thanks 1
Link to comment

Tente isso 
Testado e funcionando

veh = {}
vehCol = {}

function veiculodayz (thePlayer)
  local accountname = getAccountName (getPlayerAccount (thePlayer)) -- accountname recebe o nome da conta do jogador que usou o comando.
  if isObjectInACLGroup ("user."..accountname, aclGetGroup ("CarroEnder")) then  -- Se o nome da conta estiver na ACL Group Admin, então:
  
  
    local x, y, z = getElementPosition (thePlayer) -- x, y, z recebem a posição do jogador que usou o comando.
    if isElement (veh[thePlayer]) then -- Se já existe o veh[thePlayer] criado, então:
      spawnVehicle (veh[thePlayer], x+3, y, z) -- Spawna ele perto do jogador, sem criar outro.
      setElementData (vehCol[thePlayer], "parent", veh[thePlayer]) -- Reseta as datas do colider.
      setElementData (veh[thePlayer], "parent", vehCol[thePlayer])
      setElementData (vehCol[thePlayer], "vehicle", true)
      setElementData (vehCol[thePlayer], "Tire_inVehicle", 4)
      setElementData (vehCol[thePlayer], "Engine_inVehicle", 1)
      setElementData (vehCol[thePlayer], "Parts_inVehicle", 1)
      setElementData (vehCol[thePlayer], "fuel", 100)

    else -- Se não existe um veh[thePlayer] criado, então:
      veh[thePlayer] = createVehicle (506, x+3, y, z) -- Cria o veh[thePlayer].
      setVehicleColor (veh[thePlayer], 255, 255, 255) -- escolhe a cor do veiculo
      if isElement (vehCol[thePlayer]) then -- Se já existe o colider (veículo foi deletado e o colider ficou lá), então:
        attachElements (vehCol[thePlayer], veh[thePlayer], 0, 0, 0) -- Anexa o colider novamente ao veh[thePlayer].
      else -- Se não existe colider nenhum, então:
        vehCol[thePlayer] = createColSphere (x, y, z, 2.5) -- Cria o colider.
        attachElements (vehCol[thePlayer], veh[thePlayer], 0, 0, 0) -- Anexa ele ao veh[thePlayer].
      
      setElementData (vehCol[thePlayer], "parent", veh[thePlayer]) -- Seta as datas no veh[thePlayer] e no colider.
      setElementData (veh[thePlayer], "parent", vehCol[thePlayer])
      setElementData (vehCol[thePlayer], "vehicle", true)
      setElementData (vehCol[thePlayer], "Tire_inVehicle", 4)
      setElementData (vehCol[thePlayer], "Engine_inVehicle", 1)
      setElementData (vehCol[thePlayer], "Parts_inVehicle", 1)
      setElementData (vehCol[thePlayer], "fuel", 100)
      
    end
  end
end

        

end
addCommandHandler ("meucarro", veiculodayz)

addEventHandler("onPlayerQuit", root,
  function()
    if (veh[source] and isElement(veh[source])) then
      destroyElement(veh[source])
    end
  end
)

 

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