Travian early warning via SMS - code sample

Early Warning of Enemies via SMS for Travian

Long time ago there was lots of us playing Travian when it came out in 2004. It was one of the first online real-time games we used to play via browser (apparently it’s still a thing!).

What was Travian?

The game was simple online strategy. Every player starts with a small undeveloped village that they improve and develop over time. The development is hindered by resources or rather how much you can improve (build, level up etc.) your village and units in one time block. Of course there was an option to speed up development by micropayments. But most of us never really paid and just tried to build our villages and armies with limited resources.

The important factor of such online game is that once a player decided to invade their neighboring territory, the other player would get notified and they would get a couple of hour to react before the invasion began. But imagine since every day was split into a couple of time blocks, you could easily miss this notification during course of your day working or even sleeping (if the attack was happening at night). And without proper countermeasures taken, your village would be likely plundered.

Early Warning System in PHP

So my friend asked me, if it was possible to have them notified once an enemy army started to march onto their territory? Travian was written in PHP and as such used standard login to enter the game. Open source libraries were at that time limited (just imagine, no Github or Stack Overflow to go to to save time!).

So I developed a small scraper script in PHP that would login under my friend’s username and check if there were any notifications regarding enemy invasion waiting. If there were, my script would use an API to relay early warning message through a connected SMS gateway to their mobile phone. Yep, no Whatsapp or other options to notify your mobile phone, it was that era of basic mobile phones. You would call them dumb phones these days. Standard physical buttons, small displays and SMS used as the main communication method among people.

From now on they would get their early warning for an upcoming attack of enemies in Travian and they could react with moving resources to their army or speedily building more units in that time frame. It worked and my friend’s village was saved. Until it got destroyed by someone much stronger using micropayments to boost their resources and production. We didn’t stand a chance against players like this.

Have a comment? Join discussion on Mastodon as a reply to: