Author Topic: Need some help with this GameMode script.  (Read 675 times)

Alright, so I've been thinking about replicating WarioWare/TF2Ware in blockland and calling it BlockoWare. So far, this is the script:

Code: [Select]
// Rocket Jump :D
new ScriptObject(rocketJump) {
// msg is the text it'll show when the game is about to start.
msg = "Rocket Jump!";

// time is how long the game lasts from it's starting action to it's end.
time = 5;
};
function rocketJump::action() {
// give all players WEPONS
}
function rocketJump::end() {
// remove all players' WEPONS after 7 seconds
}

// Ceiling Rain :D
new ScriptObject(ceilingRain) {
msg = "Heads up!";
time = 3;
};
function ceilingRain::action() {
// spawn a bunch of arrows on the ceiling
}
function ceilingRain::end() {
// not really needed, nothing happens at the end.
}

//insert our game(s) into the games table
%games[1] = rocketJump;
%games[2] = ceilingRain;

// fun stuff starts here
package bwGameLoop {
function bwGameLoop() {
// choose a random game from the game table
// display it onscreen as a center print for two seconds
// after two seconds, execute the randomly chosen game's action function (if it exists)

// this area is where the game is happening
// when you die, you lose points and respawn at the game's end.

// after the amount of time set as the game's length, execute the game's end function (again, if it exists)
// wait a little bit, then go back to the top
// hopefully looping this shouldn't prevent package deactivation.
}
};

function serverCmdBWReload() {
echo("BlockoWare reloading...");
exec("Add-Ons/GameMode_BlockoWare/server.cs");
}

function serverCmdBWStart() {
echo("BlockoWare starting...");
activatePackage(bwGameLoop);
}

function serverCmdBWStop() {
echo("BlockoWare stopping...");
deactivatePackage(bwGameLoop);
}

Most of it is a proof of concept, and I've put comments in the "bwGameLoop" area of what I'm unsure of how to actually do. It does work but nothing functional yet. I need to know some things:

  • Is there a sort of "sleep()" command that waits a certain amount of time to execute the next command? Or is there a function that I can send another function and a set amount of time to run it after? Such as "delay( %myFunctionThatDoesStuffAfterFiveSeconds, 5)".
  • How would I go about getting an array of all of the players in the game? To give them their rockets in the rocket jump game, that is.
  • How can I get a brick by it's ID, and are it's methods in correspondence to the events that can be applied to it ingame? (dissappear, fakeKillBrick, etc.)
  • Similar to the brick question, are player methods in correspondence to events ingame as well?

Thanks in advance, please be advised I started learning all of this three hours ago and I'm sort of a newbie :P

We can answer all of your questions and we can fix all of the errors with your script, but you really need a better and more basic grounding in this stuff before you truly understand what's going on

  • Is there a sort of "sleep()" command that waits a certain amount of time to execute the next command? Or is there a function that I can send another function and a set amount of time to run it after? Such as "delay( %myFunctionThatDoesStuffAfterFiveSeconds, 5)". Yes. Use schedule(delay,0,commandName,argument0,argument1,etc);
  • How would I go about getting an array of all of the players in the game? To give them their rockets in the rocket jump game, that is. By array, I assume you mean a list. To loop through all players, use a for loop like such:
Code: [Select]
%count = clientGroup.getCount();
for(%i=0;%i<%count;%i++)
{
    %client = clientGroup.getObject(%i);
    //Do checks and actions here
}
    You should perform if checks to see if the player is alive and is in the minigame and whatever else.
    • How can I get a brick by it's ID, and are it's methods in correspondence to the events that can be applied to it ingame? (dissappear, fakeKillBrick, etc.) This one is super easy. The handle for the brick is its ID. So if a brick has the ID of 22222, using 22222.delete(); will delete the actual brick. This also answers your second question. I'm pretty sure all of the event methods for bricks can be called using %brick.function(possibleArguments);
    • Similar to the brick question, are player methods in correspondence to events ingame as well? Yes, an example would be %player.kill();