Jump to content

Camera slideshow


FuriouZ

Recommended Posts

Hello!

I have a problem, how i should make that camera positsion changes after every 10 seconds?

Maybe some tip ? Thanks

This is probably wrong way, because it's not working, debug giving a bad argument @fadeCamera & @setCameraMatrix

server-side:

  
local g_Cameras = { 
    { -2800.7409667969, 1223.7073974609, 21.463973999023, -2810.4326171875, 1124.2016601563, 23.62508392334 }; 
    { -2667.4091796875, 375.99395751953, 10.6223487854, -2767.3198242188, 376.38967895508, 6.4156184196472 }; 
} 
  
addEventHandler("onPlayerJoin", root,  
    function( ) 
        setTimer(function() 
            local cam_X, cam_Y, cam_Z, cam_LX, cam_LY, cam_LZ = unpack( g_Cameras[math.random(#g_Cameras)] ) 
            fadeCamera( source, true, 5) 
            setCameraMatrix( source, cam_X, cam_Y, cam_Z, cam_LX, cam_LY, cam_LZ) 
        end, 1000, 1)    
        showPlayerHudComponent( source, "all", false )  
        showChat( source, false )        
    end 
) 

Link to comment

This is how I would do it

(I didn't test it, so you might get an error)

local g_Cameras = { 
    { -2800.7409667969, 1223.7073974609, 21.463973999023, -2810.4326171875, 1124.2016601563, 23.62508392334 }; 
    { -2667.4091796875, 375.99395751953, 10.6223487854, -2767.3198242188, 376.38967895508, 6.4156184196472 }; 
} 
  
local playerCameras = { } 
local playerTimers = { } 
  
addEventHandler("onPlayerJoin", root, 
    function( ) 
        loadPlayerCamera ( source ) 
        playerTimers[source] = setTimer ( function ( p ) 
            if ( not isGuestAccount ( getPlayerAccount ( p ) ) ) then 
                killTimer ( playerTimers[p] )  
                return 
            end 
             
            loadPlayerCamera ( p ) 
        end, 8000, 0, source )  
    end 
) 
  
function loadPlayerCamera ( p ) 
    if ( not playerCameras [ p ] ) then  
        playerCameras [ p ] = 1 
    else 
        while ( i == playerCameras [ p ] ) do 
            i = math.random ( #g_Cameras ) 
        end 
        playerCameras[p] = i 
    end 
     
    fadeCamera ( p, false ) 
    setTimer ( function ( p, i ) 
        fadeCamera ( p, true ) 
        setCameraMatrix( p, unpack ( g_Cameras [ i ] ) ) 
    end, 1500, 1, p, i ) 
end 

Link to comment
This is how I would do it

(I didn't test it, so you might get an error)

local g_Cameras = { 
    { -2800.7409667969, 1223.7073974609, 21.463973999023, -2810.4326171875, 1124.2016601563, 23.62508392334 }; 
    { -2667.4091796875, 375.99395751953, 10.6223487854, -2767.3198242188, 376.38967895508, 6.4156184196472 }; 
} 
  
local playerCameras = { } 
local playerTimers = { } 
  
addEventHandler("onPlayerJoin", root, 
    function( ) 
        loadPlayerCamera ( source ) 
        playerTimers[source] = setTimer ( function ( p ) 
            if ( not isGuestAccount ( getPlayerAccount ( p ) ) ) then 
                killTimer ( playerTimers[p] )  
                return 
            end 
             
            loadPlayerCamera ( p ) 
        end, 8000, 0, source )  
    end 
) 
  
function loadPlayerCamera ( p ) 
    if ( not playerCameras [ p ] ) then  
        playerCameras [ p ] = 1 
    else 
        while ( i == playerCameras [ p ] ) do 
            i = math.random ( #g_Cameras ) 
        end 
        playerCameras[p] = i 
    end 
     
    fadeCamera ( p, false ) 
    setTimer ( function ( p, i ) 
        fadeCamera ( p, true ) 
        setCameraMatrix( p, unpack ( g_Cameras [ i ] ) ) 
    end, 1500, 1, p, i ) 
end 

Thanks, works, but cameras doesn't change only fade works

@ line 36 Something is wrong, i tought that the "#" is missing from g_Cameras ,but then i get another error ( attempt to get length of field '?'

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