Author Topic: Parent::onSpawn(); Errors  (Read 1100 times)

I was fooling around hopelessly for ideas on an addon and there was an syntax error in my code, it must be a beginners mistake or something like that since I have no idea what is wrong...Here is the code



package NRPGMC
{
   function GameConnection::onSpawn(%client)
   {
      %this.hatColor = "5 0.633 0.456 2";
      %this.secondPackColor = "1 1 0 2";
      %this.chestColor = "2 0.125 0.233 2";
      %this.rArmColor = "5 0.1215 0.716 2";
      %this.lArmColor = "1 0.754 0.346 2";
      %this.hipColor = "2.01 0.12 0.125 2";
      %this.decalName = "NRPG Player";
   }

   Parent::onSpawn(%client);
};
activatePackage(NRPGMC);



The syntax error line is in Bold.

package NRPGMC
{
   function GameConnection::onSpawn(%client)
   {
      parent::onSpawn(%client);
      %this = %client.player;

      %this.hatColor = "5 0.633 0.456 2";
      %this.secondPackColor = "1 1 0 2";
      %this.chestColor = "2 0.125 0.233 2";
      %this.rArmColor = "5 0.1215 0.716 2";
      %this.lArmColor = "1 0.754 0.346 2";
      %this.hipColor = "2.01 0.12 0.125 2";
      %this.decalName = "NRPG Player";
   }

   Parent::onSpawn(%client);
};
activatePackage(NRPGMC);

edit: Why is there Parent::onSpawn() twice?

Remove the second copy of it in Otto's code and it should work fine.

Remove the second copy of it in Otto's code and it should work fine.
I didn't even notice that lol.

Anyways, isn't it gameConnection::spawnPlayer?

There's like three things that work:

::createPlayer
::spawnPlayer
::onSpawn
« Last Edit: October 14, 2011, 07:16:54 PM by Greek2me »

onSpawn didn't work for me.

onSpawn didn't work for me.
Never mind then, use spawnPlayer.

It says the bolded is a syntax error : /
Quote
   function GameConnection::spawnPlayer(%client);
{
   %this.setEnergyLevel(0);
   serverCmdDisplay(%this);
   schedule($DesertMod::Pref::ThirstRate, 0, Thirst, %client);
   %obj.changedatablock(DesertPlayerArmor);
   Parent::spawnPlayer(%client);
}

You have a ; at the end of function GameConnection::spawnPlayer(%client);
Remove it.

Also, that needs to be packaged.

Also, that needs to be packaged.
It is, I just did not include it.

EDIT: It still says the G is an error.

DOUBLE EDIT: Duh I forgot to open the package with a {

TRIPLE EDIT: Now it says the following is a syntax error:
Quote
//=========================================================================
// Spawning
//=========================================================================
function GameConnection::spawnPlayer(%client)
{
   %this.setEnergyLevel(0);
   serverCmdDisplay(%this);
   schedule($DesertMod::Pref::ThirstRate, 0, Thirst, %client);
   %obj.changedatablock(DesertPlayerArmor);
   Parent::spawnPlayer(%client);
}
//=========================================================================
// Raise thirst
//=========================================================================
function Thirst(%client,%Player)
{
   %client.addEnergy(-1);
   schedule($DesertMod::Pref::ThirstRate, 0, Thirst, %client);
    if(%client.player.getEnergyLevel() == 100)
      serverCmdSelf Delete(%client);
      messageAll('', "<color:FFFF00>" @ %client @ "<color:ffffff> Has died of thirst!);
}
« Last Edit: October 16, 2011, 04:21:37 PM by jes00 »

You're missing a quotation in the messageAll. I'm sure you could have found that by yourself.

Always check the line above when it puts syntax errors in random places.