Author Topic: /buyjets  (Read 2322 times)

It needs to be packaged and call the parent function.

Can there be a package within a package?

Can there be a package within a package?
You sure do ask many questions when you could easily test it your self.

It needs to be packaged and call the parent function.

I don't know how to do this.

Look, I found in Kalphiter's infinite mining mod, the /buylight datablock. I wanted to add a  /buyJets datablock.
Code: [Select]
function serverCmdBuyLight(%client)
{
    if(%client.mineLight)
commandToClient(%client, 'centerPrint', "You already bought a light!", 3);

    else if(%client.mineMoney >= 25)
    {
%client.mineLight = 1;
commandToClient(%client, 'centerPrint', "You have bought a light for \c3$25", 3);
%client.mineMoney -= 25;
serverCmdLight(%client);
    }

    else
commandToClient(%client, 'centerPrint', "You cannot afford a light for \c3$25", 3);
    %client.sendMiningStatus();
}

function serverCmdBuyJets(%client)
{
    if(%client.mineJets)
commandToClient(%client, 'centerPrint', "You already bought some jets!", 3);

    else if(%client.mineMoney >= 50)
    {
%client.mineJets = 1;
commandToClient(%client, 'centerPrint', "You have bought some Jets for \c3$50", 3);
        if(isObject(%client.player))
        %client.player.changeDataBlock(PlayerStandardArmor);
    }

    else
commandToClient(%client, 'centerPrint', "You cannot afford Jets for \c3$50", 3);
    %client.sendMiningStatus();
}

function GameConnection::spawnPlayer(%client)
{
        if(%client.minejets)
        %client.player.schedule(100,changeDataBlock,StandardPlayer);
}

If that won;t work, please explain why!

Can't you just test the above code yourself (unless you already did and you're asking us to fix it)?


Can't you just test the above code yourself (unless you already did and you're asking us to fix it)?

I did test it, the first time it didn't give me jets, when I added the "function GameConnection::spawnPlayer(%client)" I didn't spawn. The bar that says loading objects get full and stays on the screen, I do not spawn.

EDIT: I tested it again, I don't spawn if I have gamemode_mining enabled. Please show me how to parent.
« Last Edit: April 26, 2010, 09:18:00 AM by Butler »



try this and see what you get:

Code: [Select]
package MiningJets
  {
function serverCmdBuyJets(%client)
  {
   if (%client.mineJets == 1)
     {
      commandToClient(%client, 'centerPrint', "You already bought some jets!", 3);
     }
   else
     {
      if (%client.mineMoney >= 50)
        {
         %client.mineJets = 1;
         commandToClient(%client, 'centerPrint', "You have bought some Jets for \c3$50", 3);
         if(isObject(%client.player))
         %client.player.changeDataBlock(PlayerStandardArmor);
        }
      else
        {
         commandToClient(%client, 'centerPrint', "You cannot afford Jets for \c3$50", 3);
        }
     }
   %client.sendMiningStatus();
  }

function GameConnection::spawnPlayer(%client)
   {
    Parent::spawnPlayer(%client);

    if (%client.minejets == 1)
      {
       %client.player.schedule(100,changeDataBlock,StandardPlayer);
      }
  }
};

I put Parent::spawnPlayer - first so that you setup to change the datablock only AFTER the player has been setup and put in game.  Just in case the player datablock gets changed during the spawn process.

This should also fix the problem where you cant spawn.

Can there be a package in a package?

nvm.
« Last Edit: April 26, 2010, 06:46:16 PM by Butler »

try this and see what you get:

Code: [Select]
package MiningJets
  {
function serverCmdBuyJets(%client)
  {
   if (%client.mineJets == 1)
     {
      commandToClient(%client, 'centerPrint', "You already bought some jets!", 3);
     }
   else
     {
      if (%client.mineMoney >= 50)
        {
         %client.mineJets = 1;
         commandToClient(%client, 'centerPrint', "You have bought some Jets for \c3$50", 3);
         if(isObject(%client.player))
         %client.player.changeDataBlock(PlayerStandardArmor);
        }
      else
        {
         commandToClient(%client, 'centerPrint', "You cannot afford Jets for \c3$50", 3);
        }
     }
   %client.sendMiningStatus();
  }

function GameConnection::spawnPlayer(%client)
   {
    Parent::spawnPlayer(%client);

    if (%client.minejets == 1)
      {
       %client.player.schedule(100,changeDataBlock,StandardPlayer);
      }
  }
};

I put Parent::spawnPlayer - first so that you setup to change the datablock only AFTER the player has been setup and put in game.  Just in case the player datablock gets changed during the spawn process.

This should also fix the problem where you cant spawn.

This works, thanks Red. But, the only problem, is it always checks if the client has mineJets when he spawns, even if I havn't typed /startdig.

EXAMPLE: I tested it yesterday, it worked, "Yayzers!" I said. Then, an hour later, I hosted a trenchwar, the playertype was Player_No_Jet. I started a No_Jet trenchwar, and I accidentally right clicked and... I jetted.

well the respawn method doesnt do anything other than set the mineJets flag.  So it sounds like something else is interfearing with your TDM.

But try this:
 - quit blockland
 - disable your miningJets addon
 - start a server & create your no_jets minigame.
If you can still jet -- then the problem is elsewhere

next, try this:
 - quit blockland
 - ENable your miningJets addon
 - start a server & create your no_jets minigame
DO NOT use /startDig
DO NOT use /buyJets
Just check to see if you can jet.  If you can -- then the problem is outside MiningJets mod.

Lastly, start a new game and use /startDig, but DO NOT use /buyJets

I created a No_Jet minigame with "Gamemode_Mining" disabled, I couldn't jet.

I created a No_Jet minigame with "Gamemode_Mining" enabled, I could jet.

not at all what I expected.

Edit your mod and change:
Code: [Select]
function GameConnection::spawnPlayer(%client)
   {
    Parent::spawnPlayer(%client);

    if (%client.minejets == 1)
      {
       %client.player.schedule(100,changeDataBlock,StandardPlayer);
      }
  }

to this:
Code: [Select]
function GameConnection::spawnPlayer(%client)
   {
    Parent::spawnPlayer(%client);

    if (%client.minejets == 1)
      {
       echo("Setting standard datablock for player " @ %client.player.getName() );
       %client.player.schedule(100,changeDataBlock,StandardPlayer);
      }
  }

Then launch bockland with the mining mod enabled.  Look carefully at the console log right after you spawn.

If you see the message above - then something else is setting and using the minejets variable, and you will need to pick a different variable name to use.