Jump to content

Ajuda com Tempo no Script


Recommended Posts

Então, em breve quero criar um script, só que tipo assim, eu quero que quando o player que estiver no trabalho e chegue em um determinado Marker, ele só possa executar a outra função depois de um certo tempo...

mk1 = createMarker (x, y, z, "cylinder", 1.5, 255, 255, 255, 255)
mk2 = createMarker (x, y, z, "cylinder", 1.5, 255, 255, 255, 255)

function trab () --função que vou desenvolver 
end
addEventHandller ("onMarkerHit", mk1, trab)

function trab2 () --Quero que essa função seja executada 5 minutos dps da primeira função
end
addEventHandller ("onMarkerHit", mk2, trab2)

 

Link to comment
  • Moderators

@danblemes1 Sempre que postar algo que não seja da linguagem inglesa, poste do subfórum Other Languages, no caso deve ser no sub-fórum Portuguese / Português > Programação em Lua

Sobre a sua pergunta, é só usar setTimer chamando a função (no caso "trab2") dentro da primeira função, exemplo:

mk1 = createMarker (x, y, z, "cylinder", 1.5, 255, 255, 255, 255)
mk2 = createMarker (x, y, z, "cylinder", 1.5, 255, 255, 255, 255)

function trab () --função que vou desenvolver
	setTimer(trab2, 5000, 1)
end
addEventHandler ("onMarkerHit", mk1, trab)

function trab2 () --Quero que essa função seja executada 5 minutos dps da primeira função
end

 

Edited by DNL291
Link to comment

Só esclarecendo uma dúvida que ficou, sobre outro script, tipo se for para setar uma animação em um player por determinado tempo, e depois "resetar" a animação,  posso fazer o seguinte?:

function makePed ()
  local thePed = createPed (infos)
  setPedAnimation (info)
      setTimer (thePed, 5000, 1)
end

 

Link to comment
  • Other Languages Moderators
50 minutes ago, danblemes1 said:

Só esclarecendo uma dúvida que ficou, sobre outro script, tipo se for para setar uma animação em um player por determinado tempo, e depois "resetar" a animação,  posso fazer o seguinte?:


function makePed ()
  local thePed = createPed (infos)
  setPedAnimation (info)
      setTimer (thePed, 5000, 1)
end

 

Não dessa forma. thePed é uma variável que está guardando um elemento (ped) e não uma função.

Faça dessa forma:

function makePed ()
	local thePed = createPed (infos)
	setPedAnimation (thePed, info)
	setTimer (setPedAnimation, 5000, 1, thePed, info)
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...