virgingod Posted March 20, 2020 Posted March 20, 2020 (edited) Estou tentando fazer um evento acontecer 2 minutos após ser chamado, mas percebi que não existe uma função de wait ou sleep nativa do Lua, o evento seria mais ou menos como esse. destruir = createMarker(2445.2878417969,-957.39611816406,80.04273223877 -2,"cylinder", 3.0, 128, 0, 0, 99) function destroi ( thePlayer ) outputChatBox("Seu veiculo será destruido em 2 minutos!", thePlayer) sleep(120000); destroyElement (thePlayer) outputChatBox("Veiculo destruido com sucesso!", thePlayer) end addEventHandler("onMarkerHit", destruir, destroi) Gostaria de saber como fazer algo parecido Edited March 20, 2020 by Breevz
Other Languages Moderators Lord Henry Posted March 20, 2020 Other Languages Moderators Posted March 20, 2020 (edited) Ta ae, amigo: destruir = createMarker (2445.2878417969, -957.39611816406, 80.04273223877 -2, "cylinder", 3.0, 128, 0, 0, 99) function destroi (thePlayer) outputChatBox ("Seu veiculo será destruido em 2 minutos!", thePlayer) setTimer (function () destroyElement (thePlayer) outputChatBox ("Veiculo destruido com sucesso!", thePlayer) end, 120000, 1) end addEventHandler ("onMarkerHit", destruir, destroi) Edited March 21, 2020 by Lord Henry Correção da minha burrice. 1 1
Angelo Pereira Posted March 20, 2020 Posted March 20, 2020 1 hour ago, Lord Henry said: Ta ae, amigo: destruir = createMarkerv (2445.2878417969, -957.39611816406, 80.04273223877 -2, "cylinder", 3.0, 128, 0, 0, 99) function destroi (thePlayer) outputChatBox ("Seu veiculo será destruido em 2 minutos!", thePlayer) setTimer (function () destroyElement (thePlayer) outputChatBox ("Veiculo destruido com sucesso!", thePlayer) end, 120000, 1) end addEventHandler ("onMarkerHit", destruir, destroi) Quando utilizar esse script, pra não acontece de da erro, e volta aqui, remova no final do createMarker o v (Caso não identifica o erro)
virgingod Posted March 20, 2020 Author Posted March 20, 2020 3 hours ago, Lord Henry said: Ta ae, amigo: destruir = createMarkerv (2445.2878417969, -957.39611816406, 80.04273223877 -2, "cylinder", 3.0, 128, 0, 0, 99) function destroi (thePlayer) outputChatBox ("Seu veiculo será destruido em 2 minutos!", thePlayer) setTimer (function () destroyElement (thePlayer) outputChatBox ("Veiculo destruido com sucesso!", thePlayer) end, 120000, 1) end addEventHandler ("onMarkerHit", destruir, destroi) Eita, bem fácil até, só acho que seria mais fácil se isso virasse uma função tipo sleepmta(1000), vlw ae
Other Languages Moderators androksi Posted March 20, 2020 Other Languages Moderators Posted March 20, 2020 Você mesmo pode criar uma função sleep(). Basta usar coroutines.
Other Languages Moderators Lord Henry Posted March 21, 2020 Other Languages Moderators Posted March 21, 2020 9 hours ago, Angelo Pereira said: remova no final do createMarker o v (Caso não identifica o erro) Corrigido. Perdão pelo vacilo.
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