Jump to content

[HELP] Cameras


AlvareZ_

Recommended Posts

Posted

What its the problem here? Not debugscript errors

local cx1, cy1, cz1 = 1262, -1154, 96 
local cpx1, cpy1, cpz1 = 1190, -1195, 58 
  
local cx2, cy2, cz2 = 512.2, -1263.57, 32.53 
local cpx2, cpy2, cpz2 = 542.16, -1287.07, 17.24 
  
function firstSlider(source) 
        setTimer(function() 
            setCameraMatrix(source, cx1, cy1, cz1, cpx1, cpy1, cpz1) 
            fadeCamera(source, true, 1.0) 
        end, 1000, 1) 
        setTimer(secondSlider, 4000, 1, source) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), firstSlider) 
  
function secondSlider(source) 
        setTimer(function() 
            setCameraMatrix(source, cx2, cy2, cz2, cpx2, cpy2, cpz2) 
            fadeCamera(source, true, 1.0) 
        end, 1000, 1) 
        setTimer(thirdSlider, 4000, 1, source) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), secondSlider) 
  

bandera_de_Venezuela.png

Posted

Remove "source" from function name.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

why don't you just put them in a table?

try this:

local camTable = { 
 {1262, -1154, 96,1190, -1195, 58}, --cs,cy,cz,cpx,cpy,cpz 
{512.2, -1263.57, 32.53,542.16, -1287.07, 17.24} 
} 
  
function firstSlider(source) 
     setTimer(function() 
          local cx,cy,cz,cpx,cpy,cpz = unpack(camTable[math.random(#camTable)]) 
          setCameraMatrix(source, cx1, cy1, cz1, cpx1, cpy1, cpz1) 
          fadeCamera(source, true, 1.0) 
     end, 1000, 2) 
end 
addEventHandler("onPlayerLogin", getRootElement(), firstSlider) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

Done, but not work

local cx1, cy1, cz1 = 1262, -1154, 96 
local cpx1, cpy1, cpz1 = 1190, -1195, 58 
  
local cx2, cy2, cz2 = 512.2, -1263.57, 32.53 
local cpx2, cpy2, cpz2 = 542.16, -1287.07, 17.24 
  
function firstSlider() 
        setTimer(function() 
            setCameraMatrix(source, cx1, cy1, cz1, cpx1, cpy1, cpz1) 
            fadeCamera(source, true, 1.0) 
        end, 1000, 1) 
        setTimer(secondSlider, 4000, 1, source) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), firstSlider) 
  
function secondSlider() 
        setTimer(function() 
            setCameraMatrix(source, cx2, cy2, cz2, cpx2, cpy2, cpz2) 
            fadeCamera(source, true, 1.0) 
        end, 1000, 1) 
        setTimer(thirdSlider, 4000, 1, source) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), secondSlider) 
  

bandera_de_Venezuela.png

Posted

Jaysds1 debugscripts:

bad argument @ ' setCameraMatrix'

bad 'player' pointer @ 'fadeCamera'(1)

bad argument @ ' setCameraMatrix'

bad 'player' pointer @ 'fadeCamera'(1)

bandera_de_Venezuela.png

Posted
local camTable = 
    { 
        { 1262, -1154, 96,1190, -1195, 58 }, --cs,cy,cz,cpx,cpy,cpz 
        { 512.2, -1263.57, 32.53,542.16, -1287.07, 17.24 } 
    } 
  
function firstSlider ( ) 
     setTimer (  
        function ( thePlayer ) 
            setCameraMatrix ( thePlayer, unpack ( camTable [ math.random ( #camTable ) ] ) ) 
            fadeCamera ( thePlayer, true, 1 ) 
        end, 1000, 2, source 
     ) 
end 
addEventHandler ( "onPlayerLogin", getRootElement(), firstSlider ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It doesn't "freeze", it just returns the same random camera twice.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
local camTable = 
    { 
        { 1262, -1154, 96,1190, -1195, 58 }, --cs,cy,cz,cpx,cpy,cpz 
        { 512.2, -1263.57, 32.53,542.16, -1287.07, 17.24 } 
    } 
local cameras = { } 
  
function firstSlider ( ) 
    cameras [ source ] = 0 
    setTimer ( 
        function ( thePlayer ) 
            cameras [ thePlayer ] = ( cameras [ thePlayer ] + 1 ) 
            setCameraMatrix ( thePlayer, unpack ( camTable [ cameras [ thePlayer ] ] ) ) 
            fadeCamera ( thePlayer, true, 1 ) 
        end, 1000, 2, source 
    ) 
end 
addEventHandler ( "onPlayerLogin", getRootElement(), firstSlider ) 

Try it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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