Hello dear people of the MTA Forum,
This is my first post, should I have overlooked a sticky or something explaining rules of posting, please be kind.
I've been scripting for 12 days straight since I first started learning lua. Having some experience with other programming languages helped me a great deal and I've been able to figure everything out up until now.
I cannot for the life of me understand one thing:
Let's say I have a function that makes the player sit down and do some other stuff while sitting. I don't have a particular example on hand so I'll just make one up.
condition = false
function sitAndDo(player)
setPedAnimation(player,"BEACH","ParkSit_M_loop",0,false,false,true,true)
theTimer = setTimer(function()
if condition == true then
killTimer(theTimer)
end
end,10000,0)
end
This doesn't seem particularly clean, also it doesn't work. I want to continuously check if something happened yet and then of course make the timer stop. How do I accomplish this? I've been searching for days. Should i trigger a custom event as soon as the condition is true that kills the timer? Can someone please give me an example on finding the cleanest way?
Also on an unrelated note: how do I check if the player/an element has moved. I cannot seem to find a suitable Event for that.