Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. RegisterCommand('veh', function(source, args, rawCommand)
  2. local veh = args[1]
  3. if veh then
  4. Citizen.CreateThread(function()
  5. local vehicle = GetHashKey(veh)
  6. if IsModelInCdimage(vehicle) then
  7. local ped = GetPlayerPed(-1)
  8. if ped and ped ~= -1 then
  9. RequestModel(vehicle)
  10. while not HasModelLoaded(vehicle) do
  11. Wait(1)
  12. end
  13. local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0, 5.0, 0)
  14. local _vehicle = CreateVehicle(vehicle, coords, GetEntityHeading(GetPlayerPed(-1), true, false))
  15. SetVehicleOnGroundProperly(_vehicle)
  16. SetModelAsNoLongerNeeded(vehicle)
  17. Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(_vehicle))
  18. local name = GetDisplayNameFromVehicleModel(vehicle)
  19. TriggerEvent("chatMessage", "Server", {54, 244, 140}, "You have spawned a "..name)
  20. end
  21. else
  22. TriggerEvent("chatMessage", "Error", {255, 0, 0}, "That vehicle name does not exist.")
  23. end
  24. end)
  25. else
  26. TriggerEvent("chatMessage", "Error", {255, 0, 0}, "Incorrect Usage: /veh [vehicle hash]")
  27. end
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement