Commenting code

This commit is contained in:
Lauren Toivanen 2019-10-24 23:49:22 +03:00
parent c55d70b65b
commit 68a88e4422
4 changed files with 22 additions and 15 deletions

View file

@ -1,7 +1,9 @@
RegisterCommand('car', function(source, args)
-- Default to futo
local vehicle = args[1] or "futo"
-- Check existance and if a vehicle
if not IsModelInCdimage(vehicle) or not IsModelAVehicle(vehicle) then
TriggerEvent("chat:addMessage", {
color = {255,0,0},
@ -10,34 +12,34 @@ RegisterCommand('car', function(source, args)
return
end
-- Load model
RequestModel(vehicle)
while not HasModelLoaded(vehicle) do
Wait(500)
end
-- Position vehicle niceishly
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local head, vect = GetClosestVehicleNodeWithHeading(pos.x, pos.y, pos.z, 1)
local x,y,z = table.unpack(vect)
-- local veh = CreateVehicle(vehicle, pos.x+5, pos.y+5, pos.z, GetEntityHeading(ped), true, false)
local veh = CreateVehicle(vehicle, x, y, z, GetEntityHeading(ped), true, false)
-- local veh = CreateVehicle(vehicle, x, y, z, head, true, false)
SetVehicleOnGroundProperly(veh)
-- Set register plate and a blip
SetVehicleNumberPlateText(veh, GetPlayerName())
TriggerEvent('chat:addMessage', {
color = {0,255,0},
args = { 'Tässä pyytämäsi upouusi ' .. vehicle }
})
local blip = AddBlipForEntity(veh)
SetBlipSprite(blip, 225)
SetBlipFlashes(blip, true)
SetBlipFlashTimer(blip, 10000)
-- Inform vehicle spawned
TriggerEvent('chat:addMessage', {
color = {0,255,0},
args = { 'Tässä pyytämäsi upouusi ' .. vehicle }
})
-- Cleaning up. Let R* handle despawning
SetModelAsNoLongerNeeded(vehicle)
SetEntityAsNoLongerNeeded(veh)
end, false)