Jump to content

Unlimited Vehicle


Recommended Posts

Пытаюсь заспавнить машины в ресурсе Unlimited Vehicle, ничего не получается даже с createVehicle.

Помогите пожалуйста разобраться как эти машины заспавнить, дайте пример пожалуйста.

 

Trying to spawn the cars in the online Vehicle Unlimited, is impossible, even with createVehicle.

Please help to understand how these cars to spawn, give an example please.

 

meta.xml

<meta>
    <info name="Unlimited Vehicle" version="0.0.1" type="script" author="alexaxel705" description="Unlimited Vehicle"/>
    <script src="client.Lua" type="client"/>
    <script src="server.Lua" type="server"/>
    <file src="models/Name111.dff" type="client" download="true" />
    <file src="models/Name111.txd" type="client" download="true" />
</meta>

 

server.Lua

function scriptCreateTank ( commandName )
      local luckyBugger = getLocalPlayer() -- get the local player
      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position
      createVehicle ( 737, x, y, z + 10 ) -- create the tank 10 units above them
      outputChatBox ( "You got Tank'd!", 255, 0, 0)
end
--Attach the 'scriptCreateTank' function to the "tank" command
addCommandHandler ( "tank", scriptCreateTank )

 

client.Lua

 


local x,y,_ = getElementPosition(localPlayer)
local ReplaceModel = {}
local LoadedTxd = {}
local DownloadList = {}
local Loading = 0
local FullLoading = false
local screenWidth, screenHeight = guiGetScreenSize()
local scale = ((screenWidth/1920)+(screenHeight/1080))
local DownloadNext = true


local UsedIds = {}

local ModelsDownloads = {}

local ModelsName = {
    [400] = {"models/landstal", "Automobile"}, 
    [401] = {"models/bravura", "Automobile"}, 
    [402] = {"models/buffalo", "Automobile"}, 
    [403] = {"models/linerun", "Automobile"}, 
    [404] = {"models/peren", "Automobile"}, 
    [405] = {"models/sentinel", "Automobile"}, 
    [406] = {"models/dumper", "Monster Truck"}, 
    [407] = {"models/firetruk", "Automobile"}, 
    [408] = {"models/trash", "Automobile"}, 
    [409] = {"models/stretch", "Automobile"}, 
    [410] = {"models/manana", "Automobile"}, 
    [411] = {"models/infernus", "Automobile"}, 
    [412] = {"models/voodoo", "Automobile"}, 
    [413] = {"models/pony", "Automobile"}, 
    [414] = {"models/mule", "Automobile"}, 
    [415] = {"models/cheetah", "Automobile"}, 
    [416] = {"models/ambulan", "Automobile"}, 
    [417] = {"models/leviathn", "Helicopter"}, 
    [418] = {"models/moonbeam", "Automobile"}, 
    [419] = {"models/esperant", "Automobile"}, 
    [420] = {"models/taxi", "Automobile"}, 
    [421] = {"models/washing", "Automobile"}, 
    [422] = {"models/bobcat", "Automobile"}, 
    [423] = {"models/mrwhoop", "Automobile"}, 
    [424] = {"models/bfinject", "Automobile"}, 
    [425] = {"models/hunter", "Helicopter"}, 
    [426] = {"models/premier", "Automobile"}, 
    [427] = {"models/enforcer", "Automobile"}, 
    [428] = {"models/securica", "Automobile"}, 
    [429] = {"models/banshee", "Automobile"}, 
    [430] = {"models/predator", "Boat"}, 
    [431] = {"models/bus", "Automobile"}, 
    [432] = {"models/rhino", "Automobile"}, 
    [433] = {"models/barracks", "Automobile"}, 
    [434] = {"models/hotknife", "Automobile"}, 
    [435] = {"models/artict1", "Trailer"}, 
    [436] = {"models/previon", "Automobile"}, 
    [437] = {"models/coach", "Automobile"}, 
    [438] = {"models/cabbie", "Automobile"}, 
    [439] = {"models/stallion", "Automobile"}, 
    [440] = {"models/rumpo", "Automobile"}, 
    [441] = {"models/rcbandit", "Automobile"}, 
    [442] = {"models/romero", "Automobile"}, 
    [443] = {"models/packer", "Automobile"}, 
    [444] = {"models/monster", "Monster Truck"}, 
    [445] = {"models/admiral", "Automobile"}, 
    [446] = {"models/squalo", "Boat"}, 
    [447] = {"models/seaspar", "Helicopter"}, 
    [448] = {"models/pizzaboy", "Bike"}, 
    [449] = {"models/tram", "Train"}, 
    [450] = {"models/artict2", "Trailer"}, 
    [451] = {"models/turismo", "Automobile"}, 
    [452] = {"models/speeder", "Boat"}, 
    [453] = {"models/reefer", "Boat"}, 
    [454] = {"models/tropic", "Boat"}, 
    [455] = {"models/flatbed", "Automobile"}, 
    [456] = {"models/yankee", "Automobile"}, 
    [457] = {"models/caddy", "Automobile"}, 
    [458] = {"models/solair", "Automobile"}, 
    [459] = {"models/topfun", "Automobile"}, 
    [460] = {"models/skimmer", "Plane"}, 
    [461] = {"models/pcj600", "Bike"}, 
    [462] = {"models/faggio", "Bike"}, 
    [463] = {"models/freeway", "Bike"}, 
    [464] = {"models/rcbaron", "Plane"}, 
    [465] = {"models/rcraider", "Helicopter"}, 
    [466] = {"models/glendale", "Automobile"}, 
    [467] = {"models/oceanic", "Automobile"}, 
    [468] = {"models/sanchez", "Bike"}, 
    [469] = {"models/sparrow", "Helicopter"}, 
    [470] = {"models/patriot", "Automobile"}, 
    [471] = {"models/quad", "Quad"}, 
    [472] = {"models/coastg", "Boat"}, 
    [473] = {"models/dinghy", "Boat"}, 
    [474] = {"models/hermes", "Automobile"}, 
    [475] = {"models/sabre", "Automobile"}, 
    [476] = {"models/rustler", "Plane"}, 
    [477] = {"models/zr350", "Automobile"}, 
    [478] = {"models/walton", "Automobile"}, 
    [479] = {"models/regina", "Automobile"}, 
    [480] = {"models/comet", "Automobile"}, 
    [481] = {"models/bmx", "BMX"}, 
    [482] = {"models/burrito", "Automobile"}, 
    [483] = {"models/camper", "Automobile"}, 
    [484] = {"models/marquis", "Boat"}, 
    [485] = {"models/baggage", "Automobile"}, 
    [486] = {"models/dozer", "Automobile"}, 
    [487] = {"models/maverick", "Helicopter"}, 
    [488] = {"models/vcnmav", "Helicopter"}, 
    [489] = {"models/rancher", "Automobile"}, 
    [490] = {"models/fbiranch", "Automobile"}, 
    [491] = {"models/virgo", "Automobile"}, 
    [492] = {"models/greenwoo", "Automobile"}, 
    [493] = {"models/jetmax", "Boat"}, 
    [494] = {"models/hotring", "Automobile"}, 
    [495] = {"models/sandking", "Automobile"}, 
    [496] = {"models/blistac", "Automobile"}, 
    [497] = {"models/polmav", "Helicopter"}, 
    [498] = {"models/boxville", "Automobile"}, 
    [499] = {"models/benson", "Automobile"}, 
    [500] = {"models/mesa", "Automobile"}, 
    [501] = {"models/rcgoblin", "Helicopter"}, 
    [502] = {"models/hotrina", "Automobile"}, 
    [503] = {"models/hotrinb", "Automobile"}, 
    [504] = {"models/bloodra", "Automobile"}, 
    [505] = {"models/rnchlure", "Automobile"}, 
    [506] = {"models/supergt", "Automobile"}, 
    [507] = {"models/elegant", "Automobile"}, 
    [508] = {"models/journey", "Automobile"}, 
    [509] = {"models/bike", "BMX"}, 
    [510] = {"models/mtbike", "BMX"}, 
    [511] = {"models/beagle", "Plane"}, 
    [512] = {"models/cropdust", "Plane"}, 
    [513] = {"models/stunt", "Plane"}, 
    [514] = {"models/petro", "Automobile"}, 
    [515] = {"models/rdtrain", "Automobile"}, 
    [516] = {"models/nebula", "Automobile"}, 
    [517] = {"models/majestic", "Automobile"}, 
    [518] = {"models/buccanee", "Automobile"}, 
    [519] = {"models/shamal", "Plane"}, 
    [520] = {"models/hydra", "Plane"}, 
    [521] = {"models/fcr900", "Bike"}, 
    [522] = {"models/nrg500", "Bike"}, 
    [523] = {"models/copbike", "Bike"}, 
    [524] = {"models/cement", "Automobile"}, 
    [525] = {"models/towtruck", "Automobile"}, 
    [526] = {"models/fortune", "Automobile"}, 
    [527] = {"models/cadrona", "Automobile"}, 
    [528] = {"models/fbitruck", "Automobile"}, 
    [529] = {"models/willard", "Automobile"}, 
    [530] = {"models/forklift", "Automobile"}, 
    [531] = {"models/tractor", "Automobile"}, 
    [532] = {"models/combine", "Automobile"}, 
    [533] = {"models/feltzer", "Automobile"}, 
    [534] = {"models/remingtn", "Automobile"}, 
    [535] = {"models/slamvan", "Automobile"}, 
    [536] = {"models/blade", "Automobile"}, 
    [537] = {"models/freight", "Train"}, 
    [538] = {"models/streak", "Train"}, 
    [539] = {"models/vortex", "Plane"}, 
    [540] = {"models/vincent", "Automobile"}, 
    [541] = {"models/bullet", "Automobile"}, 
    [542] = {"models/clover", "Automobile"}, 
    [543] = {"models/sadler", "Automobile"}, 
    [544] = {"models/firela", "Automobile"}, 
    [545] = {"models/hustler", "Automobile"}, 
    [546] = {"models/intruder", "Automobile"}, 
    [547] = {"models/primo", "Automobile"}, 
    [548] = {"models/cargobob", "Helicopter"}, 
    [549] = {"models/tampa", "Automobile"}, 
    [550] = {"models/sunrise", "Automobile"}, 
    [551] = {"models/merit", "Automobile"}, 
    [552] = {"models/utility", "Automobile"}, 
    [553] = {"models/nevada", "Plane"}, 
    [554] = {"models/yosemite", "Automobile"}, 
    [555] = {"models/windsor", "Automobile"}, 
    [556] = {"models/monstera", "Monster Truck"}, 
    [557] = {"models/monsterb", "Monster Truck"}, 
    [558] = {"models/uranus", "Automobile"}, 
    [559] = {"models/jester", "Automobile"}, 
    [560] = {"models/sultan", "Automobile"}, 
    [561] = {"models/stratum", "Automobile"}, 
    [562] = {"models/elegy", "Automobile"}, 
    [563] = {"models/raindanc", "Helicopter"}, 
    [564] = {"models/rctiger", "Automobile"}, 
    [565] = {"models/flash", "Automobile"}, 
    [566] = {"models/tahoma", "Automobile"}, 
    [567] = {"models/savanna", "Automobile"}, 
    [568] = {"models/bandito", "Automobile"}, 
    [569] = {"models/freiflat", "Train"}, 
    [570] = {"models/streakc", "Train"}, 
    [571] = {"models/kart", "Automobile"}, 
    [572] = {"models/mower", "Automobile"}, 
    [573] = {"models/duneride", "Monster Truck"}, 
    [574] = {"models/sweeper", "Automobile"}, 
    [575] = {"models/broadway", "Automobile"}, 
    [576] = {"models/tornado", "Automobile"}, 
    [577] = {"models/at400", "Plane"}, 
    [578] = {"models/dft30", "Automobile"}, 
    [579] = {"models/huntley", "Automobile"}, 
    [580] = {"models/stafford", "Automobile"}, 
    [581] = {"models/bf400", "Bike"}, 
    [582] = {"models/newsvan", "Automobile"}, 
    [583] = {"models/tug", "Automobile"}, 
    [584] = {"models/petrotr", "Trailer"}, 
    [585] = {"models/emperor", "Automobile"}, 
    [586] = {"models/wayfarer", "Bike"}, 
    [587] = {"models/euros", "Automobile"}, 
    [588] = {"models/hotdog", "Automobile"}, 
    [589] = {"models/club", "Automobile"}, 
    [590] = {"models/freibox", "Train"}, 
    [591] = {"models/artict3", "Trailer"}, 
    [592] = {"models/androm", "Plane"}, 
    [593] = {"models/dodo", "Plane"}, 
    [594] = {"models/rccam", "Automobile"}, 
    [595] = {"models/launch", "Boat"}, 
    [596] = {"models/copcarla", "Automobile"}, 
    [597] = {"models/copcarsf", "Automobile"}, 
    [598] = {"models/copcarvg", "Automobile"}, 
    [599] = {"models/copcarru", "Automobile"}, 
    [600] = {"models/picador", "Automobile"}, 
    [601] = {"models/swatvan", "Automobile"}, 
    [602] = {"models/alpha", "Automobile"}, 
    [603] = {"models/phoenix", "Automobile"}, 
    [604] = {"models/glen:~", "Automobile"}, 
    [605] = {"models/sadl:~", "Automobile"}, 
    [606] = {"models/bagboxa", "Trailer"}, 
    [607] = {"models/bagboxb", "Trailer"}, 
    [608] = {"models/tugstair", "Trailer"}, 
    [609] = {"models/boxburg", "Automobile"}, 
    [610] = {"models/farmtr1", "Trailer"}, 
    [611] = {"models/utiltr1", "Trailer"}, 
    
    [612] = {"modelslc/admiral", "Automobile"}, 
    [613] = {"modelslc/alpha", "Automobile"}, 
    [614] = {"modelslc/ambulan", "Automobile"}, 
    [615] = {"modelslc/banshee", "Automobile"}, 
    [616] = {"modelslc/barracks", "Automobile"}, 
    [617] = {"modelslc/benson", "Automobile"}, 
    [618] = {"modelslc/bfinject", "Automobile"}, 
    [619] = {"modelslc/bloodra", "Automobile"}, 
    [620] = {"modelslc/bobcat", "Automobile"}, 
    [621] = {"modelslc/boxburg", "Automobile"}, 
    [622] = {"modelslc/boxville", "Automobile"}, 
    [623] = {"modelslc/bravura", "Automobile"}, 
    [624] = {"modelslc/burrito", "Automobile"}, 
    [625] = {"modelslc/bus", "Automobile"}, 
    [626] = {"modelslc/cabbie", "Automobile"}, 
    [627] = {"modelslc/cheetah", "Automobile"}, 
    [628] = {"modelslc/copcarla", "Automobile"}, 
    [629] = {"modelslc/dodo", "Plane"}, 
    [630] = {"modelslc/elegant", "Automobile"}, 
    [631] = {"modelslc/enforcer", "Automobile"}, 
    [632] = {"modelslc/esperant", "Automobile"}, 
    [633] = {"modelslc/fbiranch", "Automobile"}, 
    [634] = {"modelslc/feltzer", "Automobile"}, 
    [635] = {"modelslc/firetruk", "Automobile"}, 
    [636] = {"modelslc/flatbed", "Automobile"}, 
    [637] = {"modelslc/infernus", "Automobile"}, 
    [638] = {"modelslc/intruder", "Automobile"}, 
    [639] = {"modelslc/landstal", "Automobile"}, 
    [640] = {"modelslc/linerun", "Automobile"}, 
    [641] = {"modelslc/manana", "Automobile"}, 
    [642] = {"modelslc/moonbeam", "Automobile"}, 
    [643] = {"modelslc/mrwhoop", "Automobile"}, 
    [644] = {"modelslc/mule", "Automobile"}, 
    [645] = {"modelslc/patriot", "Automobile"}, 
    [646] = {"modelslc/peren", "Automobile"}, 
    [647] = {"modelslc/pony", "Automobile"}, 
    [648] = {"modelslc/premier", "Automobile"}, 
    [649] = {"modelslc/previon", "Automobile"}, 
    [650] = {"modelslc/rancher", "Automobile"}, 
    [651] = {"modelslc/rcbandit", "Automobile"}, 
    [652] = {"modelslc/reefer", "Boat"}, 
    [653] = {"modelslc/rumpo", "Automobile"}, 
    [654] = {"modelslc/securica", "Automobile"}, 
    [655] = {"modelslc/sentinel", "Automobile"}, 
    [656] = {"modelslc/solair", "Automobile"}, 
    [657] = {"modelslc/speeder", "Boat"}, 
    [658] = {"modelslc/stallion", "Automobile"}, 
    [659] = {"modelslc/stretch", "Automobile"}, 
    [660] = {"modelslc/taxi", "Automobile"}, 
    [661] = {"modelslc/topfun", "Automobile"}, 
    [662] = {"modelslc/trash", "Automobile"}, 
    [663] = {"modelslc/voodoo", "Automobile"}, 
    [664] = {"modelslc/yankee", "Automobile"}, 
    
    [665] = {"modelsvc/admiral", "Automobile"}, 
    [666] = {"modelsvc/ambulan", "Automobile"}, 
    [667] = {"modelsvc/baggage", "Automobile"}, 
    [668] = {"modelsvc/banshee", "Automobile"}, 
    [669] = {"modelsvc/barracks", "Automobile"}, 
    [670] = {"modelsvc/benson", "Automobile"}, 
    [671] = {"modelsvc/bfinject", "Automobile"}, 
    [672] = {"modelsvc/bloodra", "Automobile"}, 
    [673] = {"modelsvc/bobcat", "Automobile"}, 
    [674] = {"modelsvc/boxburg", "Automobile"}, 
    [675] = {"modelsvc/boxville", "Automobile"}, 
    [676] = {"modelsvc/bravura", "Automobile"}, 
    [677] = {"modelsvc/buffalo", "Automobile"}, 
    [678] = {"modelsvc/burrito", "Automobile"}, 
    [679] = {"modelsvc/bus", "Automobile"}, 
    [680] = {"modelsvc/cabbie", "Automobile"}, 
    [681] = {"modelsvc/cheetah", "Automobile"}, 
    [682] = {"modelsvc/clover", "Automobile"}, 
    [683] = {"modelsvc/copcarla", "Automobile"}, 
    [684] = {"modelsvc/copcarsf", "Automobile"}, 
    [685] = {"modelsvc/copcarvg", "Automobile"}, 
    [686] = {"modelsvc/elegant", "Automobile"}, 
    [687] = {"modelsvc/enforcer", "Automobile"}, 
    [688] = {"modelsvc/esperant", "Automobile"}, 
    [689] = {"modelsvc/fbiranch", "Automobile"}, 
    [690] = {"modelsvc/firetruk", "Automobile"}, 
    [691] = {"modelsvc/flatbed", "Automobile"}, 
    [692] = {"modelsvc/glendale", "Automobile"}, 
    [693] = {"modelsvc/glen:~", "Automobile"}, 
    [694] = {"modelsvc/greenwoo", "Automobile"}, 
    [695] = {"modelsvc/hermes", "Automobile"}, 
    [696] = {"modelsvc/hotrinb", "Automobile"}, 
    [697] = {"modelsvc/hotring", "Automobile"}, 
    [698] = {"modelsvc/hunter", "Helicopter"}, 
    [699] = {"modelsvc/infernus", "Automobile"}, 
    [700] = {"modelsvc/intruder", "Automobile"}, 
    [701] = {"modelsvc/landstal", "Automobile"}, 
    [702] = {"modelsvc/majestic", "Automobile"}, 
    [703] = {"modelsvc/manana", "Automobile"}, 
    [704] = {"modelsvc/maverick", "Helicopter"}, 
    [705] = {"modelsvc/mesa", "Automobile"}, 
    [706] = {"modelsvc/mrwhoop", "Automobile"}, 
    [707] = {"modelsvc/mule", "Automobile"}, 
    [708] = {"modelsvc/nebula", "Automobile"}, 
    [709] = {"modelsvc/newsvan", "Automobile"}, 
    [710] = {"modelsvc/oceanic", "Automobile"}, 
    [711] = {"modelsvc/peren", "Automobile"}, 
    [712] = {"modelsvc/pizzaboy", "Bike"}, 
    [713] = {"modelsvc/polmav", "Helicopter"}, 
    [714] = {"modelsvc/pony", "Automobile"}, 
    [715] = {"modelsvc/premier", "Automobile"}, 
    [716] = {"modelsvc/primo", "Automobile"}, 
    [717] = {"modelsvc/rancher", "Automobile"}, 
    [718] = {"modelsvc/regina", "Automobile"}, 
    [719] = {"modelsvc/rumpo", "Automobile"}, 
    [720] = {"modelsvc/sabre", "Automobile"}, 
    [721] = {"modelsvc/sadl:~", "Automobile"}, 
    [722] = {"modelsvc/sanchez", "Bike"}, 
    [723] = {"modelsvc/sandking", "Automobile"}, 
    [724] = {"modelsvc/securica", "Automobile"}, 
    [725] = {"modelsvc/sentinel", "Automobile"}, 
    [726] = {"modelsvc/skimmer", "Plane"}, 
    [727] = {"modelsvc/stafford", "Automobile"}, 
    [728] = {"modelsvc/stallion", "Automobile"}, 
    [729] = {"modelsvc/supergt", "Automobile"}, 
    [730] = {"modelsvc/taxi", "Automobile"}, 
    [731] = {"modelsvc/topfun", "Automobile"}, 
    [732] = {"modelsvc/vcnmav", "Helicopter"}, 
    [733] = {"modelsvc/voodoo", "Automobile"}, 
    [734] = {"modelsvc/walton", "Automobile"}, 
    [735] = {"modelsvc/willard", "Automobile"}, 
    [736] = {"modelsvc/yankee", "Automobile"}, 
    [737] = {"modelsvc/Name111", "Automobile"},
    
}

local Txds = {}
local Dffs = {}

    
local FreeIds = {}
for v = 400, 611 do
    local vt = getVehicleType(v)
    if(not FreeIds[vt]) then FreeIds[vt] = {} end
    FreeIds[vt][#FreeIds[vt]+1] = v
end

function GetFreeIds(VehicleType)
    local out = FreeIds[VehicleType][#FreeIds[VehicleType]]
    table.remove(FreeIds[VehicleType], #FreeIds[VehicleType])
    return out
end

local FileProcess = {}


local NowLoading = {}
function LoadVehicleToModel(name, model)
    NowLoading[name] = true
    if(not Txds[name]) then Txds[name] = engineLoadTXD(ModelsName[name][1]..".txd") end
    engineImportTXD(Txds[name], model)
    if(not Dffs[name]) then Dffs[name] = engineLoadDFF(ModelsName[name][1]..".dff") end
    engineReplaceModel(Dffs[name], model)
end

function onDownloadFinish(file, success)
    if(source == resourceRoot) then
        if(success) then
            ModelsDownloads[FileProcess[file]] = ModelsDownloads[FileProcess[file]]+1
            if(ModelsDownloads[FileProcess[file]] == 2) then
                if(not UsedIds[FileProcess[file]]) then
                    UsedIds[FileProcess[file]] = GetFreeIds(ModelsName[FileProcess[file]][2])
                end
                LoadVehicleToModel(FileProcess[file], UsedIds[FileProcess[file]])
            end
            FileProcess[file] = nil
        end
    end
end
addEventHandler("onClientFileDownloadComplete", root, onDownloadFinish)


local VehicleInStream = {}
function VehStreamIn()
    if(getElementType(source) == "vehicle") then
        local model = getElementData(source, "model")
        if(model) then
            model = tonumber(model)
            
            if(not ModelsName[model]) then return false end
            
            if (not VehicleInStream[model]) then VehicleInStream[model] = 0 end
            
            if(not ModelsDownloads[model]) then
                ModelsDownloads[model] = 0
                FileProcess[ModelsName[model][1]..".txd"] = model
                FileProcess[ModelsName[model][1]..".dff"] = model
                downloadFile(ModelsName[model][1]..".txd")
                downloadFile(ModelsName[model][1]..".dff")
            else
                NowLoading[model] = nil
            end
            
            
            if(not UsedIds[model]) then
                UsedIds[model] = GetFreeIds(ModelsName[model][2])
                LoadVehicleToModel(model, UsedIds[model])
            end
            
            if(UsedIds[model] == getElementModel(source)) then
                VehicleInStream[model] = VehicleInStream[model]+1
            else
                setElementModel(source, UsedIds[model])
            end
        end
    end
end
addEvent("onClientElementStreamIn", true)
addEventHandler("onClientElementStreamIn", getRootElement(), VehStreamIn)


function VehStreamOut()
    if(getElementType(source) == "vehicle") then
        local model = getElementData(source, "model")
        if(model) then
            model = tonumber(model)
            if(VehicleInStream[model]) then
                VehicleInStream[model] = VehicleInStream[model]-1
                
                if(VehicleInStream[model] < 1) then
                    VehicleInStream[model] = nil
                    if(not NowLoading[model]) then
                        table.insert(FreeIds[ModelsName[model][2]], UsedIds[model])
                        UsedIds[model] = nil
                    end
                end
            end
        end
    end
end
addEvent("onClientElementStreamOut", true)
addEventHandler("onClientElementStreamOut", getRootElement(), VehStreamOut)


function displayLoadedRes(res)
    if(getResourceName(res) == "Vehicle") then
        for _, theVehicle in pairs(getElementsByType("vehicle", getRootElement(), true)) do
            triggerEvent("onClientElementStreamIn", theVehicle)
        end
    end
end
addEventHandler("onClientResourceStart", getRootElement(), displayLoadedRes)


function createText()
    local playerX, playerY, playerZ = getElementPosition ( localPlayer )
    local playerZoneName = getZoneName ( playerX, playerY, playerZ )    

    local text = ""
    for i,v in pairs(VehicleInStream) do
        text = text.."\nid: "..i.." count: "..v
    end
    dxDrawText(text, screenWidth-200, 300, screenWidth, screenHeight, tocolor(0, 0, 0, 255), 0.7, "pricedown")
    dxDrawText(text, screenWidth-200+2, 300+2, screenWidth, screenHeight, tocolor(255, 255, 255, 255), 0.7, "pricedown")
end
--addEventHandler("onClientRender", root, createText)

 

Edited by IIYAMA
formatting
Link to comment
function scriptCreateTank ( commandName )
      local luckyBugger = getLocalPlayer() -- get the local player
      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position
      local theVehicle = createVehicle ( 404, x, y, z + 10 ) -- create the tank 10 units above them
      setElementData(theVehicle, "model", 737)
      outputChatBox ( "You got Tank'd!", 255, 0, 0)
end
--Attach the 'scriptCreateTank' function to the "tank" command
addCommandHandler ( "tank", scriptCreateTank )

[M]Province

Надо указать новый ID модели setElementData(theVehicle, "model").

Модель которая указывается в createVehicle значения не имеет, главное чтобы была в диапазоне от 400 до 611.
Во время события onClientElementStreamIn он читает новую модель, и занимает свободный слот в диапазоне игровых моделей от 400 до 611 с учетом типа транспортного средства, в данном случае "Automobile".
При событии onClientElementStreamOut он освобождает раннее занятый слот.

Edited by alexaxel705
  • Thanks 1
Link to comment
  • 2 weeks later...
On 07/08/2019 at 13:29, alexaxel705 said:

function scriptCreateTank ( commandName )      local luckyBugger = getLocalPlayer() -- get the local player      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position      local theVehicle = createVehicle ( 404, x, y, z + 10 ) -- create the tank 10 units above them      setElementData(theVehicle, "model", 737)      outputChatBox ( "You got Tank'd!", 255, 0, 0)end--Attach the 'scriptCreateTank' function to the "tank" commandaddCommandHandler ( "tank", scriptCreateTank )

[M]Province

Надо указать новый ID модели setElementData(theVehicle, "model").

Модель которая указывается в createVehicle значения не имеет, главное чтобы была в диапазоне от 400 до 611.
Во время события onClientElementStreamIn он читает новую модель, и занимает свободный слот в диапазоне игровых моделей от 400 до 611 с учетом типа транспортного средства, в данном случае "Automobile".
При событии onClientElementStreamOut он освобождает раннее занятый слот.

And if all the old IDs are busy, it turns out that the script will not work?

Link to comment

@Erema93
Теоретически, для этого необходимо единовременно загрузить более 211 уникальных моделей в радиусе 300 метров.
На практике такое трудно представить, разве что какая нибудь пирамида из авто.

 

Theoretically, for this it is necessary to simultaneously load more than 211 unique models within a radius of 300 meters.
In practice, it’s hard to imagine, except perhaps some kind of pyramid from a car.

 

Link to comment
  • 2 weeks later...

@alexaxel705

Я немного о другом имел ввиду. Если у всех старых ID авто уже будут заменены модели на новые, то скрипт уже не будет работать как надо?

 

I meant a little about something else. If all old car IDs already have models replaced by new ones, then the script will no longer work as it should?

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