Game Development Community

How to add weekly events?

by Varun Choudhry · in Torque 3D Beginner · 06/29/2015 (3:13 am) · 6 replies

I have started developing a multiplayer game. I want to add weekly events. I've gone through every book and some threads but still can't find how to do it. Please help me

#1
06/29/2015 (5:15 am)
Can you give us an example of weekly events from other games that you're wanting to do? I'm not sure I understand what you're trying to do.
#2
06/29/2015 (5:21 am)
I don't about other games but
for example
the game has team deathmatch, hostage rescue and capture the flag(ctf) and I want that CTF can only be played on weekends so how do I do it
Also how do I create teams.
#3
06/29/2015 (6:10 am)
"Teams" is the (relatively) easier portion of this - just assign a team to the client when they log in, and then spawn them in the area assigned to that team. You can just use a number, literally. Then check that number wherever relevant - The player object has the client "attached", so you just check %player.client.team.

Periodic community events is more complex. Are you hosting the only servers? Easier if you are - just take the server down and start it using a new flag, or use a different set of missions. If you're not, then the whole player-base will need to somehow be coordinated - that means you're going to have to maybe set up a web site and host some sort of document or something, then build systems to check this on client start-up. Of course, you could probably make this more complicated than that if you really wanted, but it seems that checking a single document online would be fairly straightforward using an HTTPObject.
#4
06/29/2015 (6:14 am)
Can you give some sample code for teams portion and Thank you for your help
#5
06/29/2015 (6:19 pm)
Do you want them to be able to pick a team? Or just get dropped on one randomly?

In scripts/server/commands.cs:
function serverCmdgetTeam(%client)
   %count = ClientGroup.getCount();
   %team1Count = 0;
   %team2Count = 0;
   for(%i = 0; %i < %count; %i++)
   {
      %obj = ClientGroup.getObject(%i);
      if( %obj.team == 1 )
         %team1Count++;
      if( %obj.team == 2 )
         %team2Count++;
   }
   if(%team1Count > %team2Count)
   {
      commandToClient(%client, 'setTeam', 2);
      return;
   }
   if(%team2Count > %team1Count)
   {
      commandToClient(%client, 'setTeam', 1);
      return;
   }
   %team = getRandom(1, 2);
   commandToClient(%client, 'setTeam', %team);
}

In scripts/client/client.cs:
function clientCmdsetTeam(%team)
{
   $tempTeam = %team;
}

In scripts/server/gameCore.cs AT THE END OF GameCore::spawnPlayer():
// --- after the if(%Server::LoadingGame) {} block ----
   commandToServer('getTeam');
   %client.team = %tempTeam;
   %client.player.team = %client.team;
   // and this next line should be the closing brace of the function:
}

Now, random and semi-balanced teams should ensue. If you want them to be able to pick teams it gets a bit more involved. NOTE! I have not tested that code even once.. That being said, it should be pretty close even if it doesn't work out of the box.
#6
07/11/2015 (5:18 pm)
For "events" that occur over a time duration, you'll need a persistent web server to manage the event durations in terms of start and end, and then use a HTTPObject or a TCPObject on the game client to handle the connection and processing.