Jump to content

Military Guy

Members
  • Posts

    33
  • Joined

  • Last visited

Posts posted by Military Guy

  1. 2 hours ago, FernandoMTA said:

    You coud do something like this in a client script:

    local DAMAGE_AREA = createColPolygon(-1, 4, 5, 8, 9, 4, 5, -2, -1, 4) -- colshape coordinates here
    
    local DAMAGE_DELAY = 3000 -- miliseconds between damage hits
    
    local DAMAGE_AMOUNT = 5 -- health points to lose
    
    local damageTimer
    
    local function takeDamage()
    	-- cancel damage timer if dead
    	if isPedDead(localPlayer) then
    		if isTimer(damageTimer) then
    			killTimer(damageTimer)
    			damageTimer = nil
    		end
    		return
    	end
    
    	-- take damage (this may kill the player)
    	setElementHealth(localPlayer, math.max(0, getElementHealth(localPlayer) - DAMAGE_AMOUNT))
    	outputChatBox("Ouch", 255, 56, 56)
    
    	-- you can trigger some visual effects here (if you want)
    end
    
    addEventHandler( "onClientColShapeHit", DAMAGE_AREA, 
    function (theElement, matchingDimension)
    	if (theElement ~= localPlayer) then return end
    	if not (matchingDimension) then return end
    
    	-- take damage instantly (if you want)
    	takeDamage()
    
    	-- set damage timer
    	damageTimer = setTimer(takeDamage, DAMAGE_DELAY, 0)
    end)
    
    addEventHandler( "onClientColShapeLeave", DAMAGE_AREA, 
    function (theElement, matchingDimension)
    	if (theElement ~= localPlayer) then return end
    	if not (matchingDimension) then return end
    
    	-- cancel damage timer
    	if isTimer(damageTimer) then
    		killTimer(damageTimer)
    		damageTimer = nil
    	end
    end)

    THX!

    • Like 1
  2. Телепортируюсь в интерьер без машины, все окей. Телепортируюсь с машиной - Закидывает фиг знает куда и машину не видно.

    Не подскажете, в чём проблема?

     

    Teleport to the interior, everything is OK. 
    Teleport the car - the Car is not visible. What to do?

     

    local marker = createMarker ( 1176.56897, 2970.37427, 12, "cylinder", 3, 255, 255, 0, 170 ) -- Создаем маркер 1
    local marker2 = createMarker ( -2417.85571, 228.77899, 3537.26343, "cylinder", 3, 255, 255, 0, 170 ) -- Создаем маркер 2.
    local marker3 = createMarker ( 10, 0, 2, "cylinder", 3, 255, 255, 0, 170 ) -- Создаем маркер 3.
    
    addCommandHandler( "teleport", -- Добавляем команду /teleport
    
    	function () -- Функция
    		if isElementWithinMarker ( localPlayer, marker ) then -- Проревем находится ли игрок в маркере 1?
    			setElementPosition ( getPedOccupiedVehicle ( localPlayer ) or localPlayer, -2417.85571, 228.77899, 3537.26343 ) -- Телепортируем игрока находящегося в маркере 1.
    			setElementInterior ( getPedOccupiedVehicle ( localPlayer ) or localPlayer, 23 )
    		elseif isElementWithinMarker ( localPlayer, marker2 ) then -- Проревем находится ли игрок в маркере 2?
    			setElementPosition ( getPedOccupiedVehicle ( localPlayer ) or localPlayer, 0, 0, 20 ) -- Телепортируем игрока находящегося в маркере 2.
    		elseif isElementWithinMarker ( localPlayer, marker3 ) then -- Проревем находится ли игрок в маркере 3?
    			setElementPosition ( getPedOccupiedVehicle ( localPlayer ) or localPlayer, 0, 0, 100 ) -- Телепортируем игрока находящегося в маркере 3.
    		end
    	end
    )

     

  3. How to rotate missile? I attach missile to Packer, works. 

    Help pls, im need the missile to fly at an angle

     

     

     


     

    function shootProjectile() 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
            -- Only create projectile if we are inside a SWAT 
        if(vehicle) and getVehicleModel(vehicle) == 443 then 
        local x, y, z = getElementPosition(vehicle) 
            createProjectile(vehicle, 19, x, y, z+2)        
        end 
    end 
      
    function toggleDemControls(bool) 
        toggleControl ( "vehicle_fire", bool ) 
        toggleControl ( "vehicle_secondary_fire", bool) 
    end 
      
    function swatEnter (player) 
        if player ~= localPlayer then return end 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        if getElementModel (vehicle) == 443 then 
            toggleDemControls(false) 
            bindKey("vehicle_fire", "down", shootProjectile) 
            bindKey("vehicle_secondary_fire", "down", shootProjectile) 
        end 
    end 
    addEventHandler ( "onClientVehicleEnter", root, swatEnter )  
      
    -- enable vehicle fire when player exits the SWAT, or when he dies 
    -- so he can use hunter or anything else. 
      
    function enableVehicleFireIfDead () 
        if source ~= localPlayer then return end 
        toggleDemControls(true) 
    end 
      
    function swatExit (player) 
        if player ~= localPlayer then return end 
        toggleDemControls(true) 
    end 
    addEventHandler ( "onClientVehicleExit", root, swatExit ) 
    addEventHandler ( "onClientPlayerWasted", root, enableVehicleFireIfDead ) 

     


  4. 1 hour ago, alexaxel705 said:
    
    function VehEnt(theVehicle, seat)	if(getElementModel(theVehicle) == 411) then		addEventHandler("onClientRender", root, Target)	endendaddEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt)function VehExt(theVehicle, seat)	if(getElementModel(theVehicle) == 411) then		removeEventHandler("onClientRender", root, Target)	endendaddEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt)

     

    Спасибо бро! Люблю и уважаю тя :D

    • Like 1
  5. 17 hours ago, alexaxel705 said:
    
    local screenWidth, screenHeight = guiGetScreenSize()
    local scalex = (screenWidth/1920)
    local scaley = (screenHeight/1080)
    local PlayerBones = {1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 41, 42, 43, 44, 51, 52, 53, 54} 
    
    
    function Target()
    	for _, thePlayer in pairs(getElementsByType("player", root, true)) do
    		local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0
    		
    		for bones in pairs(PlayerBones) do
    			local x,y,z = getPedBonePosition(thePlayer, PlayerBones[bones]) 
    	
    			x,y = getScreenFromWorldPosition(x,y,z)
    			if(x and y) then
    				maxx = math.max(x, maxx)
    				maxy = math.max(y, maxy)
    				minx = math.min(x, minx)
    				miny = math.min(y, miny)
    			end
    		end
    		
    		dxDrawLine(maxx, maxy, maxx, miny, tocolor(255,255,255,255), 2)
    		dxDrawLine(maxx, miny, minx, miny, tocolor(255,255,255,255), 2)
    		dxDrawLine(minx, miny, minx, maxy, tocolor(255,255,255,255), 2)
    		dxDrawLine(minx, maxy, maxx, maxy, tocolor(255,255,255,255), 2)
    	
    	end
    	
    	for _, theVehicle in pairs(getElementsByType("vehicle", root, true)) do
    		local VehicleBones = getVehicleComponents(theVehicle)
    		local minx, maxx, miny, maxy = screenWidth, 0, screenHeight, 0
    
    		for bones in pairs(VehicleBones) do
    			local x,y,z = getVehicleComponentPosition(theVehicle, bones, "world")
    	
    			x,y = getScreenFromWorldPosition(x,y,z)
    			
    			if(x and y) then
    				maxx = math.max(x, maxx)
    				maxy = math.max(y, maxy)
    				minx = math.min(x, minx)
    				miny = math.min(y, miny)
    			end
    		end
    		
    		local sizeBox = 10
    		
    		dxDrawLine(maxx, maxy, maxx+sizeBox, maxy, tocolor(255,255,255,255), 2)
    		dxDrawLine(maxx+sizeBox, maxy, maxx+sizeBox, maxy-sizeBox, tocolor(255,255,255,255), 2)
    		
    		dxDrawLine(maxx, miny, maxx+sizeBox, miny, tocolor(255,255,255,255), 2)
    		dxDrawLine(maxx+sizeBox, miny, maxx+sizeBox, miny+sizeBox, tocolor(255,255,255,255), 2)
    		
    		dxDrawLine(minx, maxy, minx+sizeBox, maxy, tocolor(255,255,255,255), 2)
    		dxDrawLine(minx, maxy, minx, maxy-sizeBox, tocolor(255,255,255,255), 2)
    		
    		dxDrawLine(minx, miny, minx+sizeBox, miny, tocolor(255,255,255,255), 2)
    		dxDrawLine(minx, miny, minx, miny+sizeBox, tocolor(255,255,255,255), 2)
    	end
    end
    
    
    function VehEnt()
    	addEventHandler("onClientRender", root, Target)
    end
    addEventHandler("onClientPlayerVehicleEnter", localPlayer, VehEnt)
    
    function VehExt()
    	removeEventHandler("onClientRender", root, Target)
    end
    addEventHandler("onClientPlayerVehicleExit", localPlayer, VehExt)
    

    tar.png

    А можно сделать так, что бы такой вид был только при посадке в определённую машину ?(Например сел в Инфернус и только в нём будут обводиться игроки и машины)

  6. Как сделать стиль ходьбы для определённого скина?

    How do I make a walking style for a specific skin?

    Help Pls

    function onClientResourceStart()
    	setPedWalkingStyle(localPlayer,118) 
    end
    addEventHandler("onClientResourceStart",resourceRoot, onClientResourceStart)
  7. How to make messages on vehicle enter?

    If player enter the Hydra, message is displayed to the user in the chat "Press Z to start engine"

    ---------------------------

    Как сделать сообщения при посадке в определённую машину?

    Что бы когда игрок садился в Гидру, ему писало "Нажмите Z для запуска двигателя"

  8. 3 hours ago, The_GTA said:

    Hello [M]Province,

    since this is a scripting forum let's talk about how to create Rhino vehicle. You can use the createVehicle function for that, like...

    server-side:

    
    createVehicle(getVehicleModelFromName("Rhino"), 0, 0, 5)
    

    This will create a Tank in the middle of the map. The easiest way to test scripts is to use the runcode resource. Simply log in as admin to your server and start that resource. Then type /run into the chatbox to test Lua code! ;) 

    You don't understand me. I need to duplicate the Rhino tank and put a different model on the second tank

    Make a two different tanks

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

    Hello everyone, please tell me, is it possible to make the player to damage from water?

  10. Я хочу создать больше одного танка на сервере, возможно ли создать второй танк на сервере, что бы он мог стрелять и крутить башней?

    Подскажите пожалуйста, если возможно, то как так сделать?

  11. Пытаюсь заспавнить машины в ресурсе 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)

     

×
×
  • Create New...