mortal Posted June 2, 2018 Share Posted June 2, 2018 (edited) 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 June 2, 2018 by CodyJ(L) Lua Formating Link to comment
MTA Team 0xCiBeR Posted July 18, 2018 MTA Team Share Posted July 18, 2018 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now