Author Topic: Auto Creating A Minigame  (Read 1113 times)

How would you make a script that auto creates a minigame when you start a server?




I know Iban has made this in his CityRPG mod.
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 = 0;
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;
}

minigames are literally scriptobjects with a special class and set of functions, all the minigame prefs are variables in the SO.

Code: [Select]
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 = 0;
selfDamage = true;

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

numMembers = 0;

// Special:
vehicleRunOverDamage = false;
};

that bit right there makes the minigame, you can change the prefs in it

minigames are literally scriptobjects with a special class and set of functions, all the minigame prefs are variables in the SO.

Code: [Select]
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 = 0;
selfDamage = true;

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

numMembers = 0;

// Special:
vehicleRunOverDamage = false;
};

that bit right there makes the minigame, you can change the prefs in it
So if I just did
Code: [Select]
new scriptObject(MedievalRPGMini)
{
class = miniGameSO;

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

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

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

playerDatablock = RPGplayer;
respawnTime = 15;
selfDamage = true;

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

numMembers = 0;

// Special:
vehicleRunOverDamage = false;
};
Then it would create a minigame with the desired prefs when I start a server?

of course, that would have to be packaged to when you start the server.

of course, that would have to be packaged to when you start the server.
Like this?
Code: [Select]
   function gameconnection::OnClientEnterGame(%this,%obj,%a,%b,%c,%d,%e)
{

new scriptObject(MedievalRPGMini)
{
class = miniGameSO;

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

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

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

playerDatablock = RPGplayer;
respawnTime = 15;
selfDamage = true;

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

numMembers = 0;

// Special:
vehicleRunOverDamage = false;
};
Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e);
};

Code: [Select]
package myMinigame {
    function gameconnection::OnClientEnterGame(%this,%obj,%a,%b,%c,%d,%e)
    {
        Parent::OnClientEnterGame(%this,%a,%b,%c,%d,%e);
        if(isObject(MedievalRPGMini)) {
            //i forget how to add a player to a minigame but you should do it to %this here
            return; //leave the function before we create another minigame
        }
        if(%this.name == $pref::player::netName && $myMinigame $="1") { //if the minigame doesn't exist and your mod is toggled
    new scriptObject(MedievalRPGMini)
    {
class = miniGameSO;

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

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

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

playerDatablock = RPGplayer;
respawnTime = 15;
selfDamage = true;

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

numMembers = 0;

// Special:
vehicleRunOverDamage = false;
};
    }
};
activatepackage(myMinigame);
should work. i'm not 100% sure that %this is the client, but i'm pretty damn sure.

should work. i'm not 100% sure that %this is the client, but i'm pretty damn sure.

This is the client because game connection is a client.

gameConnection::something the first arg will be gameConnection which is %this.


player::something(%This,%something,%somethingelse)

%this is Player, do you get it?

So now how do you add a player to the minigame?

So now how do you add a player to the minigame?
MedievalRPGMini.addMember(%this);


Or you could avoid bumping a solved coding help topic with a non helpful response. Default minigame does almost nothing that the OP is asking.