Jump to content

Using Set time and Fade Camera


Unique23

Recommended Posts

Good afternoon everyone!

I needed your help as always.Let me explain what wrong is,

I want script to show me black screen then warp me to somewhere.But this script warps me to somewhere then show me a blackscreen.

Here is the code,

markerinside=createMarker(265.2,1915.7,19,"arrow",1,200,200,200,255,getRootElement()) 
marerinsidecol=createColSphere(264.2,1915.2,17,1) 
markeroutside=createMarker(271.8,1926.8,19,"arrow",1,200,200,200,255,getRootElement()) 
markeroutsidecol=createColSphere(272,1927,17,1) 
  
function warpout(player) 
    fadeCamera(player,false, 1, 0,0,0) 
    setTimer(fadeCamera, 2000, 1, player, true) 
setElementPosition(player,273,1929,17) 
  
end 
function warpin(player) 
    fadeCamera(player,false, 1, 0, 0, 0) 
    setTimer(fadeCamera, 2000, 1,player, true) 
setElementPosition(player,263,1913,17) 
  
end 
addEventHandler("onColShapeHit",marerinsidecol,warpout) 
addEventHandler("onColShapeHit",markeroutsidecol,warpin) 

Link to comment

You change the players position in almost no time after starting to fade his screen out, which is set to take one second. So there's what happens:

1. The camera starts to fade (but at the time of execution, it is still visible)

2. The timer is created to fade the camera in

3. The position of player gets changed while the camera is still fading out

4. The camera ends fading out one second after the player's position has been changed

5. The camera fades in after two seconds due to the timer

(At least that's how I think it should work, I haven't tested your code)

To fix, replace

setElementPosition(player,x,y,z) 

with

setTimer(setElementPosition, 1000, 1, player, x, y, z) 

Again, I haven't tested the code because I don't have access to a computer with MA installed right now, but it should work.

Link to comment
markerinside=createMarker(265.2,1915.7,19,"arrow",1,200,200,200,255,getRootElement()) 
marerinsidecol=createColSphere(264.2,1915.2,17,1) 
markeroutside=createMarker(271.8,1926.8,19,"arrow",1,200,200,200,255,getRootElement()) 
markeroutsidecol=createColSphere(272,1927,17,1) 
  
addEventHandler("onColShapeHit", root, 
function (hitPlayer) 
if isElement(markerinsidecol) and (source == markerinsidecol) then 
            if (getElementType(hitPlayer) == "player") then 
                 fadeCamera ( hitPlayer, false, 0.1, 0, 0, 0 )  
                 setTimer ( fadeCamera, 2000, 1, hitPlayer , true, 0.5 )  
                 setElementPosition(hitPlayer,273,1929,17) 
            end 
       end 
  end 
) 
addEventHandler("onColShapeHit", root, 
function (hitPlayer) 
if isElement(markeroutsidecol) and (source == markeroutsidecol) then 
            if (getElementType(hitPlayer) == "player") then 
                fadeCamera ( hitPlayer, false, 0.1, 0, 0, 0 )  
               setTimer ( fadeCamera, 2000, 1, hitPlayer , true, 0.5 )  
                setElementPosition(hitPlayer,263,1913,17) 
            end 
       end 
  end 
) 
  

Link to comment
markerinside=createMarker(265.2,1915.7,19,"arrow",1,200,200,200,255,getRootElement()) 
marerinsidecol=createColSphere(264.2,1915.2,17,1) 
markeroutside=createMarker(271.8,1926.8,19,"arrow",1,200,200,200,255,getRootElement()) 
markeroutsidecol=createColSphere(272,1927,17,1) 
  
addEventHandler("onColShapeHit", root, 
function (hitPlayer) 
if isElement(markerinsidecol) and (source == markerinsidecol) then 
            if (getElementType(hitPlayer) == "player") then 
                 fadeCamera ( hitPlayer, false, 0.1, 0, 0, 0 )  
                 setTimer ( fadeCamera, 2000, 1, hitPlayer , true, 0.5 )  
                 setElementPosition(hitPlayer,273,1929,17) 
            end 
       end 
  end 
) 
addEventHandler("onColShapeHit", root, 
function (hitPlayer) 
if isElement(markeroutsidecol) and (source == markeroutsidecol) then 
            if (getElementType(hitPlayer) == "player") then 
                fadeCamera ( hitPlayer, false, 0.1, 0, 0, 0 )  
               setTimer ( fadeCamera, 2000, 1, hitPlayer , true, 0.5 )  
                setElementPosition(hitPlayer,263,1913,17) 
            end 
       end 
  end 
) 
  

It didn't work for me

Link to comment
What about mine solution? Have you tried it?

It shows me black screen but doesn't warp.

I did this,

markerinside=createMarker(265.2,1915.7,19,"arrow",1,200,200,200,255,getRootElement()) 
marerinsidecol=createColSphere(264.2,1915.2,17,1) 
markeroutside=createMarker(271.8,1926.8,19,"arrow",1,200,200,200,255,getRootElement()) 
markeroutsidecol=createColSphere(272,1927,17,1) 
  
function warpout(player) 
    fadeCamera(player,false, 1, 0,0,0) 
    setTimer(setElementPosition, 1000, 1, player, 273,1929,17) 
  
end 
function warpin(player) 
    fadeCamera(player,false, 1, 0, 0, 0) 
    setTimer(setElementPosition, 1000, 1, player, 263,1913,17) 
  
  
end 
addEventHandler("onColShapeHit",marerinsidecol,warpout) 
addEventHandler("onColShapeHit",markeroutsidecol,warpin) 

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