Jump to content

smooth intro with pictures


Eistee

Recommended Posts

Not tested, it is just a brainfart. xD

local images = { "image1", "image2", "image3" } 
  
function startIntro () 
    drawPicture ( images[1] ); 
    image = 1; 
    addEventHandler ( "onClientRender", getRootElement(), drawPicture ); 
    setTimer ( function() 
                drawPicture ( images [ image + 1 ] ); 
                image = image + 1; 
                end, 5000, #images ); 
    if ( image == #images ) then 
        removeEventHandler ( "onClientRender", getRootElement(), drawPicture ); 
    end 
end 
  
function drawPicture ( pictureName ) 
    local x, y = guiGetScreenSize(); 
    dxDrawImage ( 0, 0, x, y, "images/".. pictureName ..".png" ); 
end 

Link to comment
local images = { "image1", "image2", "image3" } 
  
function startIntro () 
    drawPicture ( images[1] ); 
    image = 1; 
    addEventHandler ( "onClientRender", getRootElement(), drawPicture ); 
    setTimer ( function() 
                drawPicture ( images [ image + 1 ] ); 
                image = image + 1; 
                end, 1000, #images ); 
    if ( image == #images ) then 
        removeEventHandler ( "onClientRender", getRootElement(), drawPicture ); 
    end 
end 
  
  
function drawPicture ( pictureName ) 
    local x, y = guiGetScreenSize(); 
    dxDrawImage ( 0, 0, x, y, "images/".. pictureName ..".png" ); 
end 
  
  
function introstartt ( source, commandName ) 
    startIntro () 
end 
addCommandHandler ( "intro", introstartt  ) 

Error:

Error: test\client.lua:19: attempt to concatenate local 'pictureName' (a nil value) 

Link to comment
local images = {"img1","img2","img3"} 
local n = 1 
function draw() 
  if not isTimer(timer) then timer = setTimer(function () n = n + 1 end,1000,1) end 
   if n == #images then n = 1 end 
    local x, y = guiGetScreenSize(); 
    dxDrawImage ( 0, 0, x, y, "images/".. images[n]..".png" ); 
end 
addEventHandler ( "onClientRender", getRootElement(), draw);  
  

Link to comment
local images = {"img1","img2","img3"} 
local n = 1 
local show = false 
function draw() 
  if not isTimer(timer) then timer = setTimer(function () n = n + 1 end,1000,1) end 
   if n == #images then n = 1 end 
    local x, y = guiGetScreenSize() 
    dxDrawImage ( 0, 0, x, y, "images/".. images[n]..".png" ) 
end 
addCommandHandler("showImg", 
function () 
 if show then  
  removeEventHandler ( "onClientRender", getRootElement(), draw) 
else 
 addEventHandler ( "onClientRender", getRootElement(), draw) 
 end 
end) 
  

Link to comment

I know but how i can import this is the script?

local images = {"img1","img2","img3"} 
local n = 1 
function draw() 
  if not isTimer(timer) then timer = setTimer(function () n = n + 1 end,1000,1) end 
   if n == #images then n = 1 end 
    local x, y = guiGetScreenSize(); 
    dxDrawImage ( 0, 0, x, y, "images/".. images[n]..".png" ); 
end 
addEventHandler ( "onClientRender", getRootElement(), draw); 
  

Link to comment
local counter = 0 
local starttick 
local currenttick 
local images = {"img1","img2","img3"} 
local x, y = guiGetScreenSize(); 
local secondBetweenImageInMS = 3000 
  
  
addEventHandler("onClientRender",root, 
function() 
if getPedMoveState ( localPlayer ) == "sprint" then 
        if not starttick then 
            starttick = getTickCount() 
        end 
        currenttick = getTickCount() 
        if currenttick - starttick >= secondBetweenImageInMS then 
        counter = counter + 1 
            if counter == #images then  
                counter = 1  
            end 
            starttick = false 
        end 
            dxDrawImage ( 0, 0, x, y, "images/".. images[counter]..".png" ); 
    end 
end 
) 

Edited by Guest
Link to comment
  • 2 months later...

Okay and then 30 ms will work?

What i have to change?

local countersprint = 1 
local imagessprint = {"MW2Sprinten1","MW2Sprinten2","MW2Sprinten3","MW2Sprinten4","MW2Sprinten5","MW2Sprinten6","MW2Sprinten7","MW2Sprinten8","MW2Sprinten9","MW2Sprinten10","MW2Sprinten11","MW2Sprinten12","MW2Sprinten13","MW2Sprinten14","MW2Sprinten15","MW2Sprinten16","MW2Sprinten17","MW2Sprinten18","MW2Sprinten19","MW2Sprinten20","MW2Sprinten21","MW2Sprinten22","MW2Sprinten23","MW2Sprinten24","MW2Sprinten25","MW2Sprinten26"} 
local xsprint, ysprint = guiGetScreenSize(); 
local secondBetweenImageInMSsprint = 50 
  
  
addEventHandler("onClientRender",root, 
function() 
if getPedMoveState ( localPlayer ) == "sprint" then 
    if not isTimer(timer) then timer = setTimer(function () countersprint = countersprint + 1 end,secondBetweenImageInMSsprint,1) end 
        if countersprint == #imagessprint then countersprint = 1 end 
        local xsprint, ysprint = guiGetScreenSize(); 
        dxDrawImage ( 0, 0, xsprint, ysprint, "images/sprint/".. imagessprint[countersprint]..".png" ); 
    end 
end 
) 

Link to comment
  
local countersprint = 1 
local imagessprint = {"MW2Sprinten1","MW2Sprinten2","MW2Sprinten3","MW2Sprinten4","MW2Sprinten5","MW2Sprinten6","MW2Sprinten7","MW2Sprinten8","MW2Sprinten9","MW2Sprinten10","MW2Sprinten11","MW2Sprinten12","MW2Sprinten13","MW2Sprinten14","MW2Sprinten15","MW2Sprinten16","MW2Sprinten17","MW2Sprinten18","MW2Sprinten19","MW2Sprinten20","MW2Sprinten21","MW2Sprinten22","MW2Sprinten23","MW2Sprinten24","MW2Sprinten25","MW2Sprinten26"} 
local xsprint, ysprint = guiGetScreenSize(); 
local secondBetweenImageInMSsprint = 30 
  
  
addEventHandler("onClientRender",root, 
function() 
if getPedMoveState ( localPlayer ) == "sprint" then 
    if not isTimer(timer) then timer = setTimer(function () countersprint = countersprint + 1 end,secondBetweenImageInMSsprint,1) end 
        if countersprint == #imagessprint then countersprint = 1 end 
        local xsprint, ysprint = guiGetScreenSize(); 
        dxDrawImage ( 0, 0, xsprint, ysprint, "images/sprint/".. imagessprint[countersprint]..".png" ); 
    end 
end 
) 
  

local secondBetweenImageInMSsprint = 30

Link to comment
local counter = 1 
local starttick 
local currenttick 
local images = {"img1","img2","img3"} 
local x, y = guiGetScreenSize(); 
local secondBetweenImageInMS = 3000 
  
  
addEventHandler("onClientRender",root, 
function() 
if getPedMoveState ( localPlayer ) == "sprint" then 
        if not starttick then 
            starttick = getTickCount() 
        end 
        currenttick = getTickCount() 
        if currenttick - starttick >= secondBetweenImageInMS then 
        counter = counter + 1 
            if counter == (#images+1) then 
                counter = 1 
            end 
            starttick = false 
        end 
        dxDrawImage ( 0, 0, x, y, "images/".. images[counter]..".png" ); 
    end 
end 
) 

Don't use timers with onClientRender.... just use getTickCount..

Link to comment

Do this work?

local counter = 1 
local starttick 
local currenttick 
local images = {"img1","img2","img3"} 
local x, y = guiGetScreenSize(); 
local secondBetweenImageInMS = 30 
  
  
addEventHandler("onClientRender",root, 
function() 
if getPedMoveState ( localPlayer ) == "sprint" then 
        if not starttick then 
            starttick = getTickCount() 
        end 
        currenttick = getTickCount() 
        if currenttick - starttick >= secondBetweenImageInMS then 
        counter = counter + 1 
            if counter == (#images+1) then 
                counter = 1 
            end 
            starttick = false 
        end 
        dxDrawImage ( 0, 0, x, y, "images/".. images[counter]..".png" ); 
    end 
end 
) 

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