Jump to content

Respawn_Autos


mortal

Recommended Posts

me ayudan no puedo que la imagen duro tiempo se queta muy rapido 

 

----- Client -----

local screenWidth,screenHeight = guiGetScreenSize()  

----------------------------
function respawnVehicles ( )
    
        dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, "canakkale.png", 0, 0, tocolor( 255, 255, 255 ) )
        setTimer(function ()
        local vehicles = getElementsByType ( "vehicle" )
        local seconds = getTickCount() / 1000
    local angle = math.sin(seconds) * 100
     dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, "canakkale1.png",   0, 0, tocolor( 255, 255, 255 ) )
        for k, vehicle in ipairs ( vehicles ) do
            if isEmpty( vehicle ) then
                respawnVehicle ( vehicle )
            end
        end
        end, 20000, 1)
    end
    setTimer(respawnVehicles, 10000, 0)
     
    function isEmpty( vehicle )
        local passengers = getVehicleMaxPassengers( vehicle )
        if (type( passengers ) == 'number') then
            for seat = 0, passengers do
                if getVehicleOccupant( vehicle, seat ) then
                    return false
                end
            end
        end
        return true
    end

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

-----------server-----------

function respawnExplodedVehicle()
    setTimer(respawnVehicle, 5000, 1, source)
end
addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)

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

-----------meta -----------

<meta>
    <script src="server.lua" type="server" />
    <script src="client.lua" type="client" cache="false"/>
    <file src="canakkale.png" />
    <file src="canakkale1.png" />
</meta>

 

 

Edited by CodyJ(L)
Lua Formating
Link to comment
  • 1 month later...
  • MTA Team

Hola! Para renderizar un objeto dx en el tiempo es necesario que uses un evento client-side recurrente tal como lo es:
onClientRender

Te doy un ejemplo:
 

local screenWidth,screenHeight = guiGetScreenSize()  -- Get screen resolution.


function renderDisplay ( )
	local seconds = getTickCount() / 1000
	local angle = math.sin(seconds) * 80
	-- This will draw the graphic file 'arrow.png' at the top middle of the screen
	-- using the size of 100 pixels wide, and 240 pixels high.
	-- The center of rotation is at the top of the image.
	dxDrawImage ( screenWidth/2 - 50, 0, 100, 240, 'arrow.png', angle, 0, -120 )
end


function HandleTheRendering ( )
	addEventHandler("onClientRender", root, renderDisplay)  -- Keep everything visible with onClientRender.
end
addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering)

Si no usas este evento, o de alguna forma llamas a la función recurrentemente, la imagen se va a visualizar solo 1 tick, por eso la vez crearse y desaparecer.

Saludos!

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