Skip to content

Instantly share code, notes, and snippets.

@MrBluePotato
Created January 5, 2014 21:55
Show Gist options
  • Save MrBluePotato/8274464 to your computer and use it in GitHub Desktop.
Save MrBluePotato/8274464 to your computer and use it in GitHub Desktop.
public static void PlayerMovedSolid(object var, fCraft.Events.PlayerMovingEventArgs e)
{
if (e.Player.Info.isSolidBlock == false)
{
TimeSpan idle = e.Player.IdleTime;
if (idle.TotalSeconds > 5)
{
e.Player.Info.IsHidden = true;
e.Player.Info.isSolidBlock = true;
//Somehow place a block at the players current pos. block number is e.Player.Model (string)
e.Player.Message("You are now a solid block!");
}
}
else
{
// We need to have block positions, so we divide by 32
Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32);
Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32);
// Check if the player actually moved and not just rotated
if ((oldPos.X != newPos.X) || (oldPos.Y != newPos.Y) || (oldPos.Z != newPos.Z))
{
e.Player.Message("You are no longer a solid block!");
e.Player.Info.isSolidBlock = false;
e.Player.Info.IsHidden = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment