battle309 Posted September 25, 2012 Share Posted September 25, 2012 hey i made this script but it doesnt work its meant to wait until someone reaches five minutes then they win and the map changes. but if they die there time is reset is this script made right or have i mad any errors of any sort. function winGame() local count = 0 setTimer ( winGame, 1000, 1 ) if count== 300 then givePlayerMoney ( player, 25000 ) outputChatBox("You have won!") else count = count + 1 end end addEventHandler ( "onPlayerSpawn", getRootElement(), winGame ) Link to comment
Renkon Posted September 25, 2012 Share Posted September 25, 2012 You should use a timer. In this case function will be executed only ONCE, and count will be ALWAYS resetted every time the function initializes since it says: local count = 0. It will always be 0 or 1 Link to comment
battle309 Posted September 25, 2012 Author Share Posted September 25, 2012 you mean it wont count up to five minutes Link to comment
Renkon Posted September 25, 2012 Share Posted September 25, 2012 It wont because you defined count = 0. It will always be resetted. You should write OVER function: local count = 0 and then inside the function, remove the localCount. and then, if count == 300 then, you can also set count = 0 Link to comment
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