Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Weather system serverside
- //#define SERVER_ONLY
- enum Weather
- {
- Sunny,
- Rainy,
- Snowy,
- Cloudy,
- Stormy
- }
- void onInit( CRules@ this )
- {
- this.set_u8("weather", Weather::Rainy);
- this.set_u16("weather stable time", 8);
- this.Sync("weather", false);
- }
- void onTick( CRules@ this )
- {
- int weather = this.get_u8("weather");
- if(getNet().isServer())
- {
- int timer = this.get_u16("weather stable time");
- if(timer > 0)
- {
- print("not yet");
- timer--;
- this.set_u16("weather stable time", timer);
- return;
- }
- this.set_u16("weather stable time", 128 + XORRandom(32));
- //int weather = this.get_u8("weather");
- weather = 1 - weather;
- print("weather is " + weather);
- this.set_u8("weather", weather);
- this.Sync("weather", false);
- }//isServer
- else
- {
- print(" ");
- print("weather is " + weather);
- if(weather == Weather::Sunny)
- {
- print("its sunny");
- return;
- }
- else if(weather == Weather::Rainy)
- {
- print("its rainy");
- }
- else if(weather == Weather::Snowy)
- {
- print("its snowy");
- }
- else if(weather == Weather::Cloudy)
- {
- print("its cloudy");
- }
- else if(weather == Weather::Stormy)
- {
- print("its stormy");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement