Jump to content

24 hour script


JkKILER

Recommended Posts

Hello all! I would like to make a script where when a player presses a barrell full of water, they get some purified waters. I would like to make this once every 24 hours though, and with my scripting knowledge, have no idea how to do that. The only thing i know i have to do is declare a variable like (Short Timer) Or some thing like that. If anyone can help, it would be very much appreciated.
Link to comment
Share on other sites

I put this together for you, I have not tested it myself so tell me if it gives you trouble.

 

ScriptName WaterScript
float fTime

BEGIN OnActivate Player
If GameDaysPassed >= fTime + 1 || fTime == 0
	Player.AddItem WaterPurified 3
	Set fTime to GameDaysPassed
Else
	ShowMessage NoWaterMsg
EndIf
END

Notes:

  • fTime is a floating point value variable that will be updated each time the player gets water and used to control the script.
  • The OnActivate block will run when the scripted reference is activated by the player only.
  • GameDaysPassed is a special variable that is controlled by the game engine, and it holds a floating point value signifying how many days has passed ingame.
  • If GameDaysPassed is greater than or equals to fTime plus one (24 hours have passed), the player will get water and fTime will be updated with a new value.
  • If fTime equals zero, ie. it in uninitialized, then the reference has never been activated and the player will get water and fTime will be initialized.
    • I do this because, if GameDaysPassed equals 0.5 (The first day has not passed), and fTime has not been initialized, then the condition "GameDaysPassed >= fTime + 1" will always be false, effectively preventing the player from getting water the first 24 hours of the game.

    [*]If none of these conditions are true, the player will be shown a message telling it to wait.

Link to comment
Share on other sites

Ok! Timers confuse the Hell out of me. But with practiacally any other type of scripting, i know whats going on and understand! Ill test in mod now, thanks for your help. Ill let you know how it works, but i think it will.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...