Skip to content

Instantly share code, notes, and snippets.

@MrBluePotato
Created January 6, 2014 03:54
Show Gist options
  • Save MrBluePotato/8277970 to your computer and use it in GitHub Desktop.
Save MrBluePotato/8277970 to your computer and use it in GitHub Desktop.
public static void CheckIdles(object sender, fCraft.Events.PlayerMovingEventArgs e)
{
if (e.Player.IdleTime.ToSeconds() % 5 == 0 && e.Player.IdleTime.ToSeconds() == 5 && !e.Player.isSolidBlock)
{
//Temp debug message
Server.Message("{0} is idle!", e.Player.ClassyName);
e.Player.Info.IsHidden = true;
e.Player.isSolidBlock = true;
//Gets the coords of the player
short x = (short)(e.Player.Position.X / 32 * 32 + 16);
short y = (short)(e.Player.Position.Y / 32 * 32 + 16);
short z = (short)(e.Player.Position.Z / 32 * 32);
Vector3I Pos = new Vector3I(e.Player.Position.X / 32, e.Player.Position.Y / 32, (e.Player.Position.Z - 32) / 32);
//Converts player's model block into Block.*blockname*
Block playerBlock = Map.GetBlockByName(e.Player.Model);
//Places the block at the players current location
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, playerBlock);
e.Player.World.Map.QueueUpdate(blockUpdate);
e.Player.WorldMap.SetBlock(Pos, playerBlock);
e.Player.Message("&cYou are now a solid block. Don't move!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment