Author Topic: Minigame Editing  (Read 757 times)

Hello. I am currently working on Annihilation, a teambased conquering game. I am a noob to coding but it is my project so I took it under myself to do it as I want to not rely completely on others to get my dirty work done.

Basically, I'm trying to get a way for my code to edit a minigame on a event. I was making it so each nexus on destroy to make that team have 1 life left. The add-on is already the kind of gamemode where it is not automated. Example: /startanni starts the game. This is because the add-on needs so and so players to make it fun so the sessions are planned out. However, I would like to make the minigame editing automated as that seems to make the code seem lazy.

Code: [Select]
function serverCmdStartAnni(%client)
{
    if(%client.isAdmin)
    {
     %count = ClientGroup.getCount();
   for(%cl = 0; %cl < %count; %cl++)
   {
    %clientB = ClientGroup.getObject(%cl);
    %clientB.centerPrint("<font:impact:50><color:f420eb>Annihilation round begins in 30 seconds! Prepare yourself!",5);
   }
%time = 30;
serTimer(%time);
    }

    else
    {
messageClient(%client, '', '\c6Only Admins can Start Annihilation!');
    }
}

function serTimer(%time)
{
if (%time <= 0)
{
%count = ClientGroup.getCount();
   for(%cl = 0; %cl < %count; %cl++)
   {
    %clientB = ClientGroup.getObject(%cl);
    %clientB.centerPrint("<font:impact:50><color:f420eb>This Annihilation round has begun!",5);
%clientB.bottomPrint("<color:f420eb>Phase: <color:ffffff>1 <color:1818ba>Team: <color:ffff00>Yellow");
   }
}
else
{
%time--;

$TimerSchedule = schedule(1000, 0, "serTimer", %time);
}
}

That is my code so far. I also want the minigame to force people on to teams when they spawn too. They can choose there team though. If I can get problems done like this, I can be a better coder in the long run. Thanks!
« Last Edit: December 23, 2014, 02:25:27 PM by rggbnnnnn »

This may not help you to the fullest, but I thought I'd post this mechanism from Iban's crpg mod. I suggest you brown townyze it anyways, because this helped me some in understanding how creating minigames works.

Code: [Select]
function CityRPG_BuildMinigame()
{
if(isObject(CityRPGMini))
{
for(%i = 0;%i < ClientGroup.getCount();%i++)
{
%subClient = ClientGroup.getObject(%i);
CityRPGMini.removeMember(%subClient);
}

CityRPGMini.delete();
}
else
{
for(%i = 0;%i < ClientGroup.getCount();%i++)
{
%subClient = ClientGroup.getObject(%i);
%subClient.minigame = NULL;
}
}

new scriptObject(CityRPGMini)
{
class = miniGameSO;

brickDamage = true;
brickRespawnTime = 10000;
colorIdx = -1;

enableBuilding = true;
enablePainting = true;
enableWand = true;
fallingDamage = true;
inviteOnly = false;

points_plantBrick = 0;
points_breakBrick = 0;
points_die = -1;
points_killPlayer = 1;
points_killSelf = -1;

playerDatablock = playerNoJet;
respawnTime = 5000;
selfDamage = true;

playersUseOwnBricks = false;
useAllPlayersBricks = true;
useSpawnBricks = false;
VehicleDamage = true;
vehicleRespawnTime = 10000;
weaponDamage = true;

numMembers = 0;

// Special:
vehicleRunOverDamage = false;
};

for(%i = 0;%i < ClientGroup.getCount();%i++)
{
%subClient = ClientGroup.getObject(%i);
CityRPGMini.addMember(%subClient);
}

CityRPGMini.playerDatablock.maxTools = 7;
}

If you'd like to change minigame settings using events, you can enable a hidden feature in Slayer.

Open the "config/server/Slayer" folder and create a blank file called ".advancedEvents.txt" (note the "." at the beginning). Then restart Blockland and you'll see a new minigame event called "Slayer_SetPref".

edit: Just keep in mind that this event is disabled for a reason. You'll see a lot of warnings from Slayer in the console about security risks. It'll be fine in a controlled environment like a TDM, though.
« Last Edit: December 23, 2014, 03:01:01 PM by Greek2me »

Once again, Greek MVP.

If you'd like to change minigame settings using events, you can enable a hidden feature in Slayer.

Open the "config/server/Slayer" folder and create a blank file called ".advancedEvents.txt" (note the "." at the beginning). Then restart Blockland and you'll see a new minigame event called "Slayer_SetPref".

edit: Just keep in mind that this event is disabled for a reason. You'll see a lot of warnings from Slayer in the console about security risks. It'll be fine in a controlled environment like a TDM, though.
Just what I needed. Greek always delivers the goods. Well I'm going to lock this now.

Unlocking. I just want to know, is there a way to edit the preferences of slayer via scripting as well. I just need to know the syntax.

Unlocking. I just want to know, is there a way to edit the preferences of slayer via scripting as well. I just need to know the syntax.

This will show you all you need to know. Create a Slayer minigame and then type this:
Code: [Select]
Slayer.minigames.getObject(0).dump();