Author Topic: Spawn at death location (Tag = Score +1)  (Read 1520 times)

I was trying to make like a player function that will spawn you were you died at, or count the damage by projectile as a Score-Point without actually killing the player.

Reason:
Paintball-like Deaths, when you get tagged, you have to return/walk to you team's base in order to re-spawn

Attempts:

I tried to make the player mark a position in which they took damage, then on death, they respawn at the location they last took damage.
1 Problem is, when you restart a mini or end a mini before you respawn, your player datablock will still be at your last damaged position and collide-able and never disappear, even if you restarted the mini and spawned at a brick.

Quote
function NPPLPlayer::onDamage(%this,%obj,%am)
{
   parent::onDamage(%this,%obj,%am);
   if(%obj.getdamagelevel() <= 200)
   {
      %client = %obj.client;
      $NPPL::Taged[%client.bl_id] = %client.player.position;
   }
}

package SpawnNPPL
{
   function GameConnection::createplayer(%a,%b)
   {
      Parent::createplayer(%a,%b);
      if(getWordCount($NPPL::Taged[%a.bl_id]) >= 1 && isObject(%minigame))
      {
         %obj.client.play2d(HitCallSound);
         %a.player.position = $NPPL::Taged[%a.bl_id];
         $NPPL::Taged[%a.bl_id] = "";
      }
      else
      {
         commandToClient(%obj.client,'centerPrint',"Minigame<br><color:FFFFFF>required for respawn");
      }
   }
};
activatePackage(SpawnNPPL);

Any suggestions or better approaches?
« Last Edit: February 20, 2013, 07:06:45 PM by ZLMods »

Package Armor::onDisabled and save the last position to the client. Then package Gameconnection::spawnPlayer to set the transform to that last position

Package Armor::onDisabled and save the last position to the client. Then package Gameconnection::spawnPlayer to set the transform to that last position
Like this?

Quote
package DeathNPPL
{
   function Armor::onDisable(%this,%obj)
   {
      %client = %obj.client;
      $NPPL::Taged[%client.bl_id] = %client.player.position;
    }
};
activatePackage(DeathNPPL);

package SpawnNPPL
{
   function GameConnection::spawnplayer(%a,%b)
   {
      Parent::spawnplayer(%a,%b);
      if(getWordCount($NPPL::Taged[%a.bl_id]) >= 1 && isObject(%minigame))
      {
         %obj.client.play2d(HitCallSound);
         %a.player.position = $NPPL::Taged[%a.bl_id];
         $NPPL::Taged[%a.bl_id] = "";
      }
      else
      {
         commandToClient(%obj.client,'centerPrint',"Minigame<br><color:FFFFFF>required for respawn");
      }
   }
};
activatePackage(SpawnNPPL);


package DeathNPPL
{
   function Armor::onDisable(%this,%obj) //You mispelled the function, you missed the last "d".
   {
      %client = %obj.client;
      $NPPL::Taged[%client.bl_id] = %client.player.position;
      //Replace this line with a parent!
   }
};
activatePackage(DeathNPPL);

package SpawnNPPL
{
   function GameConnection::spawnplayer(%a,%b)
   {
      Parent::spawnplayer(%a,%b);
      if(getWordCount($NPPL::Taged[%a.bl_id]) >= 1 && isObject(%minigame))
      {
         %obj.client.play2d(HitCallSound);
         %a.player.position = $NPPL::Taged[%a.bl_id];
         $NPPL::Taged[%a.bl_id] = "";
      }
      else
      {
         commandToClient(%obj.client,'centerPrint',"Minigame<br><color:FFFFFF>required for respawn");
      }
   }
};
activatePackage(SpawnNPPL);
« Last Edit: February 21, 2013, 02:11:08 AM by Honorabl3 »



I tryed, it still didnt work. It keeps sayin Backtrace: onimpact   or  BackTrace::ondamage and like 2 more other ones. :

Quote
package DeadNPPL
{
   function Armor::onDisabled(%this,%obj)
   {
        %client = %obj.client;
        $NPPL::Taged[%client.bl_id] = %client.player.position;
        parent::onDisabled(%this,%obj);
   }
};
activatePackage(DeadNPPL);

package SpawnNPPL
{
    function gameConnection::spawnPlayer(%client)
    {
      if(getWordCount($NPPL::Taged[%a.bl_id]) >= 1)
      {
         %obj.client.play2d(HitCallSound);
         %a.player.position = $NPPL::Taged[%a.bl_id];
         $NPPL::Taged[%a.bl_id] = "";
         %obj.setdatablock("PlayerNPPLTagedoutArmor");
         NPPLTagedLoop(%obj);
      }
      parent::spawnPlayer(%client);
    }
};
activatePackage(SpawnNPPL);

I tryed, it still didnt work. It keeps sayin Backtrace: onimpact   or  BackTrace::ondamage and like 2 more other ones. :
Code: [Select]
package DeadNPPL
{
   function Armor::onDisabled(%this,%obj)
   {
        %client = %obj.client;
        $NPPL::Taged[%client.bl_id] = %client.player.position;
        parent::onDisabled(%this,%obj);
   }
};
activatePackage(DeadNPPL);

package SpawnNPPL
{
    function gameConnection::spawnPlayer(%client)
    {
      if(getWordCount($NPPL::Taged[%a.bl_id]) >= 1)
      {
         %obj.client.play2d(HitCallSound);
         %a.player.position = $NPPL::Taged[%a.bl_id];
         $NPPL::Taged[%a.bl_id] = "";
         %obj.setdatablock("PlayerNPPLTagedoutArmor");
         NPPLTagedLoop(%obj);
      }
      parent::spawnPlayer(%client);
    }
};
activatePackage(SpawnNPPL);
Packages: Why not just put it all in one package?
Line 5: Don't use %client.player.position, just use %obj.position.
In .spawnPlayer where are you getting %a and %obj from?

Packages: Why not just put it all in one package?
Line 5: Don't use %client.player.position, just use %obj.position.
In .spawnPlayer where are you getting %a and %obj from?
Can you show me the correct way to do this?

Can you show me the correct way to do this?
-_-
Code: [Select]
package DeadNPPL
{
function armor::onDisabled(%this, %obj)
{
$NPPL::Tagged[%obj.client.bl_id] = getWords(%obj.getTransform(), 0, 2);

parent::onDisabled(%this, %obj);
}

function gameConnection::spawnPlayer(%client)
{
if(getWordCount($NPPL::Tagged[%client.bl_id]) >= 1)
{
%client.play2D(HitCallSound);
%client.player.setTransform($NPPL::Tagged[%client.bl_id]);
$NPPL::Tagged[%client.bl_id] = "";

%client.player.setDatablock(PlayerNPPLTaggedOutArmor);

NPPLTagedLoop(%client.player);
}

parent::spawnPlayer(%client);
}
};
activatePackage(DeadNPPL);

-_-
Code: [Select]
package DeadNPPL
{
function armor::onDisabled(%this, %obj)
{
$NPPL::Tagged[%obj.client.bl_id] = getWords(%obj.getTransform(), 0, 2);

parent::onDisabled(%this, %obj);
}

function gameConnection::spawnPlayer(%client)
{
if(getWordCount($NPPL::Tagged[%client.bl_id]) >= 1)
{
%client.play2D(HitCallSound);
%client.player.setTransform($NPPL::Tagged[%client.bl_id]);
$NPPL::Tagged[%client.bl_id] = "";

%client.player.setDatablock(PlayerNPPLTaggedOutArmor);

NPPLTagedLoop(%client.player);
}

parent::spawnPlayer(%client);
}
};
activatePackage(DeadNPPL);

It didnt work

It didnt work

Wow thanks so much for the wonderful information! With this information we can totally fix everything you are having issues with and then can make sure no other user experiences this problem!

package spawnAtDeath
{
   function GameConnection::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
   {
      %r = parent::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);
      %client.deathpos = %client.player.getPosition();
                 return %r;

   }
   function GameConnection::CreatePlayer(%client,%spawnPoint)
   {
      if(%client.deathpos !$= "")
      {
         %spawnPoint = %client.deathpos;
         %client.deathPos = "";
      }
      return parent::CreatePlayer(%client,%spawnPoint);

   }
};activatepackage(SpawnAtDeath);


This is a better way to do it.
« Last Edit: February 22, 2013, 06:16:51 PM by Perlin Noise »

Wow thanks so much for the wonderful information! With this information we can totally fix everything you are having issues with and then can make sure no other user experiences this problem!

package spawnAtDeath
{
   function GameConnection::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
   {
      %r = parent::OnDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);
      %client.deathpos = %client.player.getPosition();
   }
   function GameConnection::CreatePlayer(%client,%spawnPoint)
   {
      if(%client.deathpos !$= "")
      {
         %spawnPoint = %client.deathpos;
         %client.deathPos = "";
      }
      parent::CreatePlayer(%client,%spawnPoint);

   }
};activatepackage(SpawnAtDeath);


This is a better way to do it.
Um. . .
return %r; ?

You should return the parents in both of those functions.

You should return the parents in both of those functions.
Fixed.

Ah man, I suck at this scripting thing.

Um. . .
return %r; ?
You should return the parents in both of those functions.

Lol, what do I do? I also tryed to return the parents on both functions. It keeps sayin: Backtrace: onimpact or CMDSelf Delete or damage.