Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PLUGIN = nil
- function Initialize(Plugin)
- Plugin:SetName("Minigames")
- Plugin:SetVersion(1)
- PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that
- -- Hooks
- cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USED_BLOCK, OnPlayerUsedBlock)
- -- Command Bindings
- -- All done
- LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
- return true
- end
- function OnDisable()
- LOG(PLUGIN:GetName() .. " is shutting down...")
- end
- function OnPlayerUsedBlock(Player,
- BlockX, BlockY, BlockZ, BlockFace,
- CursorX, CursorY, CursorZ,
- BlockType, BlockMeta)
- if BlockType == E_BLOCK_STONE_BUTTON or BlockType == E_BLOCK_WOODEN_BUTTON then
- local ToX, ToY, ToZ
- -- Find the sign with the teleport coordinates (using block meta)
- -- Callback function for when sign entity is found
- local SignX = BlockX
- local SignY = BlockY
- local SignZ = BlockZ
- if BlockMeta > 5 then
- BlockMeta = BlockMeta - 8
- end
- if BlockMeta == 0 then
- SignY = SignY + 2
- elseif BlockMeta == 1 then
- SignX = SignX + 2
- elseif BlockMeta == 2 then
- SignX = SignX - 2
- elseif BlockMeta == 3 then
- SignZ = SignZ - 2
- elseif BlockMeta == 4 then
- SignZ = SignZ + 2
- elseif BlockMeta == 5 then
- SignY = SignY - 2
- else
- LOG("Button metadata not recognized: " .. BlockMeta)
- return
- end
- -- Get Sign data from world
- local Success, Line = Player:GetWorld():GetSignLines(SignX, SignY, SignZ)
- if Success then
- LOG(Line)
- LOG(Line:match("%[%s*(%d+)%s+(%d+)%s+(%d+)%s*%]"))
- local GoX, GoY, GoZ = Line:match("[%s*(%d+)%s+(%d+)%s+(%d+)%s*]")
- LOG(GoX)
- LOG(GoY)
- LOG(GoZ)
- LOG("Teleporting player to " .. GoX .. ", " .. GoY .. ", " .. GoZ)
- Player:TeleportToCoords(GoX, GoY, GoZ)
- end
- if not Success then
- LOG("Could not teleport player. Is the player supposed to teleport? If so, is there a sign with coords?")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment