Jump to content

[Help]Avoid Repetition (Fade in)


3B00DG4MER

Recommended Posts

Posted

Today i made script,Which is An Intro for Server

I do Images fade in And Out,it work but i have lot of repetition,How do i avoid it ?

Part of Client Side:

Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.9)) 
   end, 5000, 1, true) 
    
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.9)) 
   end, 6000, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber( 0.8 )) 
    end, 6100, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.7)) 
    end, 6150, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.6)) 
    end, 6200, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.5)) 
    end, 6250, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.4)) 
    end, 6300, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.3)) 
    end, 6350, 1, true) 
  
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.2)) 
    end, 6400, 1, true) 
    
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0.1)) 
    end, 6450, 1, true) 
    
  Timer(function() 
    guiSetAlpha(s3d1, tonumber(0)) 
    end, 6500, 1, true) 
       
  Timer(function() 
    guiSetVisible(s3d1, false) 
    end, 6550, 1, true) 

Posted
Well, in my opinion onClientRender and getTickCount would be way better.

Can you give me the Code ?!

Because i don't have this only I have Many Repetition of Images Fade in and Out :x

Posted
local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
        end 
    end 
) 

Posted
local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
        end 
    end 
) 

It doesn't fade with Your Code it set the visible to false Directly without fading ...

Fix please

Posted
This is not the whole code you must complete it by yourself here we help you to make something we don't give you the whole code \ script .

i haven't understood,Please give me it for One only (Fade in only)

Because i have Many Images to Repeat the Function to it

  • Moderators
Posted
local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
        end 
    end 
) 

Where is the reset of iCallLast ??

@3B00DG4MER: Show us the code to see if you completed it correctly.

Posted
local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
        end 
    end 
) 

Where is the reset of iCallLast ??

@3B00DG4MER: Show us the code to see if you completed it correctly.

But it's too big

i want to Avoid the repetition

BACK = guiCreateStaticImage(0,0,1,1,"images/black.png",true) 
 
s3d1 = guiCreateStaticImage(0,0,1,1,"images/1.png",true)
s3d2 = guiCreateStaticImage(0,0,1,1,"images/2.jpg",true)
s3d3 = guiCreateStaticImage(0,0,1,1,"images/3.png",true)
war4 = guiCreateStaticImage(0,0,1,1,"images/war4.png",true)
  guiSetVisible(s3d2, false)
  guiSetVisible(s3d3, false)
  guiSetVisible(war4, false)
triggerServerEvent('onLoadedClient',localPlayer,localPlayer)
   
  local Timer = setTimer
  Timer(function()
    sound = playSound("Other/sound.mp3", true)  
   end, 1000, 1, true)  
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.9))
   end, 5000, 1, true)
   
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.9))
   end, 6000, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.8 ))
    end, 6100, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.7))
    end, 6150, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.6))
    end, 6200, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.5))
    end, 6250, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.4))
    end, 6300, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.3))
    end, 6350, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.2))
    end, 6400, 1, true)
   
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0.1))
    end, 6450, 1, true)
   
  Timer(function()
    guiSetAlpha(s3d1, tonumber(0))
    end, 6500, 1, true)
     
  Timer(function()
    guiSetVisible(s3d1, false)
    end, 6550, 1, true)
   
  Timer(function()
    guiSetVisible(s3d2, true)
    end, 6600, 1, true)  
 
   Timer(function()
   guiSetAlpha(s3d2, tonumber(0.1))
    end, 6750, 1, true)
       Timer(function()
       guiSetAlpha(s3d2, tonumber(0.2))
       end, 6800, 1, true)
     Timer(function()
      guiSetAlpha(s3d2, tonumber(0.3))
       end, 6850, 1, true)
            Timer(function()
      guiSetAlpha(s3d2, tonumber(0.4))
       end, 6900, 1, true)
            Timer(function()
      guiSetAlpha(s3d2, tonumber(0.5))
       end, 6950, 1, true)
            Timer(function()
      guiSetAlpha(s3d2, tonumber(0.6))
       end, 7000, 1, true)
            Timer(function()
      guiSetAlpha(s3d2, tonumber(0.7))
       end, 7050, 1, true)
            Timer(function()
      guiSetAlpha(s3d2, tonumber(0.8 ))
       end, 7100, 1, true)
   Timer(function()
    guiSetAlpha(s3d2, tonumber(0.9))
    end, 7150, 1, true)
 
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.8 ))
    end,8850 , 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.7))
    end, 8900, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.6))
    end, 8950, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.5))
    end, 9000, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.4))
    end, 10050, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.3))
    end, 10100, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.2))
    end, 10150, 1, true)
 
  Timer(function()
    guiSetAlpha(s3d2, tonumber(0.1))
   end, 10200, 1, true)
 
 
  Timer(function()
    guiSetVisible(s3d2, false)
    end, 10248, 1, true)
   
  Timer(function()
    guiSetVisible(war4, true)
    end, 10249, 1, true)    
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.1))
    end, 10250, 1, true)
   
  Timer(function()
    guiSetAlpha(war4, tonumber(0.2))
    end, 10300, 1, true)
 
    Timer(function()
    guiSetAlpha(war4, tonumber(0.3))
    end, 10350, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.4))
    end, 10400, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.5))
    end, 10450, 1, true)
   
  Timer(function()
    guiSetAlpha(war4, tonumber(0.6))
    end, 10500, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.7))
    end, 10550, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.8 ))
    end, 10600, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.9))
    end, 10650, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.8 ))
    end, 12000, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.7))
   end, 11050, 1, true)
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.6))
    end, 11100, 1, true)
   
  Timer(function()
    guiSetAlpha(war4, tonumber(0.5))
    end, 11150, 1, true)  
 
  Timer(function()
    guiSetAlpha(war4, tonumber(0.4))
    end, 11250, 1, true)  
   
      Timer(function()
    guiSetAlpha(war4, tonumber(0.3))
    end, 11300, 1, true)
   
      Timer(function()
    guiSetAlpha(war4, tonumber(0.2))
    end, 11350, 1, true)
   
          Timer(function()
    guiSetAlpha(war4, tonumber(0.1))
    end, 11350, 1, true)
      Timer(function()
         guiSetVisible(war4, false)
         guiSetVisible(s3d3, true)
    guiSetAlpha(s3d3, tonumber(0.2))
    end, 11400, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.3))
    end, 11450, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.4))
    end, 11500, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.5))
    end, 11550, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.6))
    end, 11600, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.7))
    end, 11650, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.8 ))
    end, 11700, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.9))
    end, 11750, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.8 ))
    end, 13500, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.7))
    end, 13550, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.6))
    end, 13600, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.5))
    end, 13650, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.4))
    end, 13700, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.3))
    end, 13750, 1, true)  
      Timer(function()
    guiSetAlpha(s3d3, tonumber(0.2))
    end, 13800, 1, true)  
      Timer
  • Moderators
Posted

Where is the Mr.Pres[T]ege's code in this script ??? I don't see it !

One more time, you have to use this and a variable to change the alpha:

local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
        end 
    end 
) 

Posted
local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
        end 
    end 
) 

Where is the reset of iCallLast ??

@3B00DG4MER: Show us the code to see if you completed it correctly.

I'm not going to make a full ready code for him .

local iTime = 10000 
local iCallLast = getTickCount ( ) 
-- Complete Here 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- Complete Here 
                  iCallLast = iTickNow 
        end 
    end 
) 

  • Moderators
Posted
I'm not going to make a full ready code for him .

You gave him a not working skeleton so yeah, I just said what was missing in it. But ofc he will do the rest.

Posted
I'm not going to make a full ready code for him .

You gave him a not working skeleton so yeah, I just said what was missing in it. But ofc he will do the rest.

xD hhh :lol:

Can you give me code which work's correctly

  • Moderators
Posted
-- Create GUI elements here 
local iTime = 10000 
local iCallLast = getTickCount ( ) 
  
addEventHandler ( 'onClientRender',getRootElement (     ), 
function  ( ) 
        local iTickNow = getTickCount ( ) 
            if ( iTickNow - iCallLast > iTime ) then 
                -- change their alpha here 
                  iCallLast = iTickNow 
        end 
    end 
) 

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