Guest User

MCServer Error Code

a guest
Feb 19th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. PLUGIN = nil
  2.  
  3. function Initialize(Plugin)
  4.     Plugin:SetName("Minigames")
  5.     Plugin:SetVersion(1)
  6.    
  7.     PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that
  8.     -- Hooks
  9.     cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USED_BLOCK, OnPlayerUsedBlock)
  10.    
  11.     -- Command Bindings
  12.    
  13.     -- All done
  14.    
  15.     LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
  16.     return true
  17. end
  18.  
  19. function OnDisable()
  20.     LOG(PLUGIN:GetName() .. " is shutting down...")
  21. end
  22.  
  23. function OnPlayerUsedBlock(Player,
  24.                             BlockX, BlockY, BlockZ, BlockFace,
  25.                             CursorX, CursorY, CursorZ,
  26.                             BlockType, BlockMeta)
  27.     if BlockType == E_BLOCK_STONE_BUTTON or BlockType == E_BLOCK_WOODEN_BUTTON then
  28.         local ToX, ToY, ToZ
  29.         -- Find the sign with the teleport coordinates (using block meta)
  30.         -- Callback function for when sign entity is found
  31.        
  32.         local SignX = BlockX
  33.         local SignY = BlockY
  34.         local SignZ = BlockZ
  35.        
  36.         if BlockMeta > 5 then
  37.             BlockMeta = BlockMeta - 8
  38.         end
  39.        
  40.         if BlockMeta == 0 then
  41.             SignY = SignY + 2
  42.         elseif BlockMeta == 1 then
  43.             SignX = SignX + 2
  44.         elseif BlockMeta == 2 then
  45.             SignX = SignX - 2
  46.         elseif BlockMeta == 3 then
  47.             SignZ = SignZ - 2
  48.         elseif BlockMeta == 4 then
  49.             SignZ = SignZ + 2
  50.         elseif BlockMeta == 5 then
  51.             SignY = SignY - 2
  52.         else
  53.             LOG("Button metadata not recognized: " .. BlockMeta)
  54.             return
  55.         end
  56.                
  57.         -- Get Sign data from world
  58.         local Success, Line = Player:GetWorld():GetSignLines(SignX, SignY, SignZ)
  59.         if Success then
  60.             LOG(Line)
  61.             LOG(Line:match("%[%s*(%d+)%s+(%d+)%s+(%d+)%s*%]"))
  62.             local GoX, GoY, GoZ = Line:match("[%s*(%d+)%s+(%d+)%s+(%d+)%s*]")
  63.             LOG(GoX)
  64.             LOG(GoY)
  65.             LOG(GoZ)
  66.             LOG("Teleporting player to " .. GoX .. ", " .. GoY .. ", " .. GoZ)
  67.             Player:TeleportToCoords(GoX, GoY, GoZ)
  68.         end
  69.        
  70.         if not Success then
  71.             LOG("Could not teleport player. Is the player supposed to teleport? If so, is there a sign with coords?")
  72.         end
  73.     end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment