Tete omar Posted July 21, 2012 Share Posted July 21, 2012 Hi, all you missed me ? 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 Link to comment
Tete omar Posted July 21, 2012 Author Share Posted July 21, 2012 ok if i want to get back to the player ? Link to comment
Tete omar Posted July 21, 2012 Author Share Posted July 21, 2012 setCameraTarget this function , i tried to set camera target to an moveable object it didn't work setCameraTarget(theObject) does it work ? Link to comment
Castillo Posted July 21, 2012 Share Posted July 21, 2012 That's because the only supported element is a player for now, wiki quote: This function allows you to set a player's camera to follow other elements instead. Currently supported element type is:Players Link to comment
Tete omar Posted July 21, 2012 Author Share Posted July 21, 2012 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
Castillo Posted July 21, 2012 Share Posted July 21, 2012 onResourceStart has no player argument. Link to comment
Dev Posted July 22, 2012 Share Posted July 22, 2012 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
Tete omar Posted July 22, 2012 Author Share Posted July 22, 2012 if i want the player press F one time only should i use cancelEvent ? Link to comment
Castillo Posted July 22, 2012 Share Posted July 22, 2012 No, that function cancels events, you must unbind the key after using it. Link to comment
Tete omar Posted July 22, 2012 Author Share Posted July 22, 2012 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
Castillo Posted July 22, 2012 Share Posted July 22, 2012 That's because you got a problem on unbindKey: unbindKey( source, "F", "down", herewego ) Your player argument is 'thePlayer', not 'source'. Link to comment
Jaysds1 Posted July 22, 2012 Share Posted July 22, 2012 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
Tete omar Posted July 22, 2012 Author Share Posted July 22, 2012 thanks jaysds ^^ i fixed it before I'm off to bed now meet me regards Link to comment
Flaker Posted July 23, 2012 Share Posted July 23, 2012 Easier to use it at client side Link to comment
Tete omar Posted July 23, 2012 Author Share Posted July 23, 2012 Easier to use it at client side what is it ? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now