Gothem Posted April 4, 2008 Posted April 4, 2008 (edited) well im like make a skin selector but im have a problem.... here is the code function seleccion(player) spawnPlayer(player, -2026.5035, 156.7506, 29.0391, 269.1424, 0) fadeCamera(player,true) if ( getCameraMode ( player ) == "player" ) then setCameraMode ( player, "fixed" ) else setCameraMode ( player, "player" ) setCameraMode ( player, "fixed" ) --Not bullshit. Fo real. end setCameraPosition(player, -2010.5035, 156.7506, 29.0391) setTimer( setCameraLookAt, 500, 10, player, -2026.5035, 156.7506, 29.0391) bindKey(player,"enter","down",Aparecer,player) bindKey(player,"arrow_l","down",Cambiar,player) bindKey(player,"arrow_r","down",Cambiar,player) end function Cambiar( player, key ) local skin skin = getPlayerSkin(player) if(key == "arrow_l" and skin ~= 0) then setPlayerSkin(player,skin - 1) else setPlayerSkin(player,skin + 1) end setCameraPosition(player, -2010.5035, 156.7506, 29.0391) setCameraLookAt( player, -2026.5035, 156.7506, 29.0391) end function Aparecer( player ) unbindKey ( player, "enter", "down", Aparecer ) unbindKey ( player, "arrow_l", "down", Cambiar ) unbindKey ( player, "arrow_r", "down", Cambiar ) setCameraMode ( player, "player" ) end this are the functions to be called you need put seleccion(source) in the player join well the problem is.. it dont change skin Edited April 8, 2008 by Guest
Morelli Posted April 4, 2008 Posted April 4, 2008 Do you have any event handlers or calls on that function? You'd probably want to add this line in, then. addEventHandler ( "onPlayerJoin", getRootElement(), seleccion ) Also, the OnPlayerJoin has no parameters, so you'd want to replace all the 'player' with source, where you're referring to the player. Read over this page for an example on how you should structure it.
Cazomino05 Posted April 4, 2008 Posted April 4, 2008 i would also like to point out there is some skins that wont work properly might even crash i ain't tested so i don't know but you might wanna stop people using these skins http://development.mtasa.com/index.php? ... cter_Skins
Morelli Posted April 4, 2008 Posted April 4, 2008 (edited) i would also like to point out there is some skins that wont work properly might even crash i ain't testeds From my own tests that I've conducted, I've concluded that using a skin ID that isn't an accepted MTA skin will not crash the server. This isn't SAMP after all . EDIT: Doesn't seem like it crashes the client, either, if that's what you're wondering. Edited April 4, 2008 by Guest
Gothem Posted April 4, 2008 Author Posted April 4, 2008 Do you have any event handlers or calls on that function?You'd probably want to add this line in, then. addEventHandler ( "onPlayerJoin", getRootElement(), seleccion ) Also, the OnPlayerJoin has no parameters, so you'd want to replace all the 'player' with source, where you're referring to the player. Read over this page for an example on how you should structure it. yeah i put a handler (never too idiot ) well im think the problem is the skins but i dont know how make the code for jump the crasher skins
50p Posted April 4, 2008 Posted April 4, 2008 Camera functions are not working well. Some people say it works for them w/o any problems but some people say (inc. me) that they've got some issues. I've never managed to make them work, even using more timers. What do you see if you said you can't see yourself? My camera is somewhere in the middle of SA and it's facing East. Also, the camera's position is (I assume from what I see) 0, 0, 0.
Gothem Posted April 5, 2008 Author Posted April 5, 2008 Camera functions are not working well. Some people say it works for them w/o any problems but some people say (inc. me) that they've got some issues.I've never managed to make them work, even using more timers. What do you see if you said you can't see yourself? My camera is somewhere in the middle of SA and it's facing East. Also, the camera's position is (I assume from what I see) 0, 0, 0. yeah that is true but i have see it work when the resource start when the player is already connected no for connecting players
Winky Posted April 5, 2008 Posted April 5, 2008 I think you need to make another onPlayerJoin and a timer function playerJoin () setTimer ( seleccion, 2000, 1, source ) end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) Like this i think
Ace_Gambit Posted April 5, 2008 Posted April 5, 2008 I've had similar issues with the camera not being properly set for a newly joined player. The camera would just get stuck at 0, 0, 0 like you already mentioned. It has to do with the fact that a player is not fully spawned (or at least in my experience it is). The problem occurs only and only when a player joins for the fist time. I solved it by setting a timer (runs only once when a player joins the server) that loops for n times for the duration of n seconds positioning the camera in each tick event (10 recursions with an interval of 1000ms did the job for me). After that the camera works fine.
50p Posted April 5, 2008 Posted April 5, 2008 Can you post the entire code snippet? The code's in the 1st post. Sometimes setTimers do help.
Gothem Posted April 5, 2008 Author Posted April 5, 2008 function Inicio( res ) players = getElementsByType ( "player") for k,v in ipairs(players) do --Game start spawn outputChatBox("Bienvenido a Nuestro Servidor",v) spawnPlayer(v, -2026.5035, 156.7506, 29.0391, 269.1424, 0) setTimer(seleccion,3000,2,v) fadeCamera ( v, true ) end end function Muerte( ammo, attacker, weapon, bodypart ) setTimer ( seleccion, 3000, 1, source ) end function Conexion() outputChatBox("Bienvenido a Nuestro Servidor ",source) spawnPlayer(source, -2026.5035, 156.7506, 29.0391, 269.1424, 0) setTimer ( seleccion, 1000, 2, source ) fadeCamera ( source, true ) end function seleccion(player) spawnPlayer(player, -2026.5035, 156.7506, 29.0391, 269.1424, 0) setCameraMode ( player,"fixed") setTimer(setCameraPosition, 500, 2, player, -2010.5035, 156.7506, 29.0391) setTimer( setCameraLookAt, 550, 10, player, -2026.5035, 156.7506, 29.0391) bindKey(player,"enter","down",Aparecer) bindKey(player,"arrow_l","down",Cambiar) bindKey(player,"arrow_r","down",Cambiar) end function Cambiar( player, key ) local skin skin = getPlayerSkin(player) if(key == "arrow_l" and skin ~= 0) then setPlayerSkin(player,skin - 1) else setPlayerSkin(player,skin + 1) end setCameraLookAt( player, -2026.5035, 156.7506, 29.0391) end function Aparecer( player ) unbindKey ( player, "enter", "down", Aparecer ) unbindKey ( player, "arrow_l", "down", Cambiar ) unbindKey ( player, "arrow_r", "down", Cambiar ) setCameraMode ( player, "player" ) end addEventHandler("onPlayerWasted", getRootElement(),Muerte) addEventHandler("onResourceStart", getRootElement(),Inicio) addEventHandler("onPlayerJoin", getRootElement(),Conexion) here is the entire code it dont work now
50p Posted April 7, 2008 Posted April 7, 2008 Yesterday, I discovered that if you use the camera functions after some time you join the server they work. Try to call seleccion function using command.
Gothem Posted April 7, 2008 Author Posted April 7, 2008 Yesterday, I discovered that if you use the camera functions after some time you join the server they work. Try to call seleccion function using command. hmmm... but im like they appear when a player connect
50p Posted April 7, 2008 Posted April 7, 2008 You may spawn, but camera may not go there where you want. Try with a command and see if camera goes there. NOTE: If you have camera mode set to fixed and you will set it again to fixed it will be changed to "player" but getCameraMode is returns "fixed", that's a bug I think.
50p Posted April 8, 2008 Posted April 8, 2008 Server-side function selection( player ) setCameraPosition( ......) setTimer( setCameraLookAt, 100, 1, ....) end addCommandHandler( "test", selection )
Gothem Posted April 8, 2008 Author Posted April 8, 2008 thx 50p it works but im dont make it by command.. well now to fix the selection of skins
50p Posted April 9, 2008 Posted April 9, 2008 I haven't figured out how to fix the cameras when you join server, yet.
Ace_Gambit Posted April 9, 2008 Posted April 9, 2008 I've seen a possible solution posted by someone in the bugs forum a while ago. It seems that you can not set the camera position and make it look at something in the same frame. The solution posted (not sure if it is working) toggled to fixed/player mode and set a timer to either set the camera or make it look at a target after a short timeout.
tma Posted April 10, 2008 Posted April 10, 2008 I've seen a possible solution posted by someone in the bugs forum a while ago. It seems that you can not set the camera position and make it look at something in the same frame. The solution posted (not sure if it is working) toggled to fixed/player mode and set a timer to either set the camera or make it look at a target after a short timeout. Yeah you won't be able to do all your camera calls in sequence and do need timers. You might also need that change to player mode first before trying fixed. You end up with stuff like: setCameraMode(player,"player") setCameraMode(player,"fixed") setTimer(setCameraLookAt,100,1,player,....) setTimer(setCameraPosition,200,1,player,...) The order of LookAt/Position can also make a difference - the above is what I've had most success with.
Gothem Posted April 10, 2008 Author Posted April 10, 2008 the camera is already fixed now need to fix the skins selection
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