Как узнать x y z машины по модельки?

Tenkara

Потрачен
Автор темы
380
171
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Версия MoonLoader
.026-beta
Шапка. Модель 123 допустим
 
  • Эм
Реакции: qdIbp

Sidney31

Известный
1,132
385
x, y, z = getCarCoordinates(car_handle)
res, car_handle = sampGetCarHandleBySampVehicleId(car_id)
modelId = getCarModel(car_handle)
Думаю, сообразишь, как объединить


Lua:
function sampev.onVehicleStreamIn(vehid, data)
    res, car_handle = sampGetCarHandleBySampVehicleId(vehid)
    if res then
        if getCarModel(car_handle) == 123 then
            x, y, z = getCarCoordinates(car_handle)
        end
    end
end


не понял, почему версия выше не работает.
тоже самое без ивента:

Lua:
function main()
    while not isSampAvailable() do wait(0) end
       
    while true do
        wait(0)
        for i = 0, 2000 do
            res, carhandle = sampGetCarHandleBySampVehicleId(i)
            if res then
                if getCarModel(carhandle) == 510 then
                    x, y, z = getCarCoordinates(carhandle)
                    marker = addBlipForCar(carhandle)
                end
            end
        end
    end
end
1657636855985.png
 
Последнее редактирование:
  • Bug
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,387
1,143
Нету такой модели чел...
Может ид авто?

x, y, z = getCarCoordinates(car_handle)
res, car_handle = sampGetCarHandleBySampVehicleId(car_id)
modelId = getCarModel(car_handle)
Думаю, сообразишь, как объединить


Lua:
function sampev.onVehicleStreamIn(vehid, data)
    res, car_handle = sampGetCarHandleBySampVehicleId(vehid)
    if res then
        if getCarModel(car_handle) == 123 then
            x, y, z = getCarCoordinates(car_handle)
        end
    end
end
getCarModel действует в диапазоне от 400 до 611
(id транспорта)

Шапка. Модель 123 допустим
Если именно ид модель тогда


Lua:
        sampRegisterChatCommand('findcar',function(arg) -- id model
            if #arg == 0 then
                return sampAddChatMessage('/findcar [idmodel]')
          
            elseif string.match(arg,'%d+') then
                arg = tonumber(arg)
                if arg >= 400 and arg <= 611 then
                    local carname = getNameOfVehicleModel(arg)
                    if carname ~= nil then
                        for i = 0, 2000 do
                            local res, car = sampGetCarHandleBySampVehicleId(i)
                            if res then
                                local modelId = getCarModel(car)
                                if carname == getNameOfVehicleModel(modelId) then
                                    local x, y, z = getCarCoordinates(car)
                                    sampAddChatMessage(string.format('X:%d Y:%d Z:%d model:%s[%d]',x, y, z,carname,arg),-1)
                                end
                            end
                        end
                    end
                else
                    sampAddChatMessage('от 400 до 611', -1)
                end
            end
        end)
 
Последнее редактирование: