gadead Posted April 14, 2017 Posted April 14, 2017 (edited) Buenas, Estoy teniendo un error al momento de usar spawnPlayer, En el argumento uno no logro hacer que reconozca al jugador para spawnear. function deathspawn () fadeCamera ( getRootElement(), false, 2 ) setTimer( function() fadeCamera ( getRootElement(), true, 2 ) setCameraMatrix ( getRootElement(), 0, 0, 33, 100, 100, 3 ) spawnPlayer ( source, math.random (0,100), math.random (0,100), 10 ) -- Aqui esta el problema, no funciona con source, player o getrootelement end, 4000, 1) end addEventHandler ("onPlayerWasted", getRootElement(), deathspawn) Estaría muy agradecido de que me ayuden a encontrar el error, aun soy bastante novato. Edited April 14, 2017 by gadead
aka Blue Posted April 14, 2017 Posted April 14, 2017 Es que si te fijas, al crear un setTimer, creas otra función, por lo que el source cambia. Luego te paso el código fixeado.
#Dv^ Posted April 14, 2017 Posted April 14, 2017 (edited) addEventHandler( "onPlayerWasted", root, function( ) setTimer( respawn, 1800, 1, source ) end ) function respawn (thePlayer) local x, y, z = 0, 0, 5 spawnPlayer (thePlayer, x, y, z, 90.0 , 0) fadeCamera(thePlayer, true) end Edited April 14, 2017 by #Dv^
gadead Posted April 15, 2017 Author Posted April 15, 2017 On 14/4/2017 at 10:14, #Dv^ said: addEventHandler( "onPlayerWasted", root, function( ) setTimer( respawn, 1800, 1, source ) end ) function respawn (thePlayer) local x, y, z = 0, 0, 5 spawnPlayer (thePlayer, x, y, z, 90.0 , 0) fadeCamera(thePlayer, true) end Ya logre hacer que funcione, muchísimas gracias! On 14/4/2017 at 06:31, aka Blue said: Es que si te fijas, al crear un setTimer, creas otra función, por lo que el source cambia. Luego te paso el código fixeado. Oh, ya veo, ahora entiendo por que solo funcionaba sin el setTimer.
MTA Team 0xCiBeR Posted April 16, 2017 MTA Team Posted April 16, 2017 En ese caso con poner source = source antes del timer es suficiente, no hace falta hacer toda una función desde 0 por 1 variable.
aka Blue Posted April 16, 2017 Posted April 16, 2017 (edited) @.:CiBeR:. Fue lo que iba a sugerirle pero pensé que no serviría porque envias source igual De todos modos ahora que lo pienso, está en una función distinta. Eso sí... source = source no interferiría con el source del timer? Debería ser algo como player = source u otra cosa que no sea source. Edited April 16, 2017 by aka Blue
MTA Team 0xCiBeR Posted April 17, 2017 MTA Team Posted April 17, 2017 Para que queres el source del timer?
aka Blue Posted April 17, 2017 Posted April 17, 2017 @.:CiBeR:. Digo que provoca interferencias si no se coloca una variable antes. Y si la variable es source = source, supongo que también hará interferencia. PD: Corrígeme si me equivoco, llevo tiempo sin usar timers en mis códigos pero hace tiempo tuve un problema parecido.
Bc# Posted April 17, 2017 Posted April 17, 2017 Esto seria mas efectivo que usar source = source, es preferible crear variables a usar variables "reservadas". Solo por convención function deathspawn () fadeCamera ( getRootElement(), false, 2 ) Local thePlayer = source --Nueva variable setTimer( function() fadeCamera ( getRootElement(), true, 2 ) setCameraMatrix ( getRootElement(), 0, 0, 33, 100, 100, 3 ) spawnPlayer ( thePlayer, math.random (0,100), math.random (0,100), 10 ) end, 4000, 1) end addEventHandler ("onPlayerWasted", getRootElement(), deathspawn)
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