Jump to content

Camerastuff


Tete omar

Recommended Posts

Hi, all you missed me ? :P

i want when the player join directly , i don't want to let him play so i first show him a place in game or something or set the cam looking at something and fadeCamera and these stuff because if the players spawned in 1 area something bad will be happen i want the player's cam looking at something that's all like this

Vinewood_sign.jpeg

Link to comment

ok what's wrong here now

function setCameraOnPlayerJoin() 
     fadeCamera(source, true, 1); 
     setCameraMatrix(source, -2135.708984375, -187.71142578125, 157.66786193848, 0, 0, 0); 
end 
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin); 
  
function herewego(player) 
setCameraTarget( player ) 
bindKey( player, "f", "down", herewego ) 
end 
addEventHandler("onResourceStart", getRootElement(), herewego) 

i want if i pressed on F button then the cam gets back to the player

Link to comment

Just don't copy this code I'm posting, compare it with your last one to learn your mistakes.

function setCameraOnPlayerJoin() 
     fadeCamera(source, true, 1); 
     setCameraMatrix(source, -2135.708984375, -187.71142578125, 157.66786193848, 0, 0, 0); 
end 
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin); 
  
function setTarget( player ) 
     setCameraTarget( player, player ) 
end 
  
function hereWeGo( res ) 
     for key, value in ipairs ( getElementsByType("player") ) do 
          bindKey( value, "f", "down", setTarget ) 
     end 
end 
addEventHandler("onResourceStart", resourceRoot, hereWeGo) 

Link to comment
No, that function cancels events, you must unbind the key after using it.

Well, i used it like this

    function setCameraOnPlayerJoin() 
         fadeCamera(source, true, 1); 
         setCameraMatrix(source, -2135.708984375, -187.71142578125, 157.66786193848, 0, 0, 0); 
         bindKey( source, "F", "down", herewego ) 
    end 
    addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin); 
      
    function herewego ( thePlayer ) 
       gX, gY, gZ = getElementPosition ( thePlayer ) 
       setCameraTarget ( thePlayer ) 
       setElementPosition ( thePlayer, 2450.7463378906, -1659.6678466797, 13.3046875 ) 
       fadeCamera(source, true, 1); 
       setElementFrozen ( thePlayer, false ) 
       unbindKey( source, "F", "down", herewego ) -- when he done spawning & everything here , then unbind this key so what's the problem ? 
    end 

i still can spawn my self over then over

Link to comment

try this:

    function setCameraOnPlayerJoin() 
         fadeCamera(source, true, 1) 
         setCameraMatrix(source, -2135.708984375, -187.71142578125, 157.66786193848, 0, 0, 0) 
         bindKey( source, "F", "down", herewego ) 
    end 
    addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin); 
      
    function herewego ( thePlayer ) 
       gX, gY, gZ = getElementPosition ( thePlayer ) 
       setCameraTarget ( thePlayer,thePlayer ) 
       spawnPlayer( thePlayer, 2450.7463378906, -1659.6678466797, 13.3046875 ) --Spawn the player, instead of setting his new position 
        --plus, the player hasn't been spawned yet, so you can't set an element position if the element isn't available 
       fadeCamera(source, true, 1) 
       setElementFrozen ( thePlayer, false ) 
       unbindKey( source, "F", "down", herewego ) -- when he done spawning & everything here , then unbind this key so what's the problem ? 
    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...