diff --git a/client/help.lua b/client/help.lua new file mode 100644 index 0000000..c180266 --- /dev/null +++ b/client/help.lua @@ -0,0 +1,31 @@ +-- Basic helper script for that helper script + +class 'Helper' + +function Helper:__init() + Events:Subscribe( "ModuleLoad", self, self.ModulesLoad ) + Events:Subscribe( "ModulesLoad", self, self.ModulesLoad ) + Events:Subscribe( "ModuleUnload", self, self.ModuleUnload ) +end + + +function Helper:ModulesLoad() + Events:Fire( "HelpAddItem", + { + name = "Runways", + text = + "This script allows you to view the runways while in a plane.\n" .. + "Use \"/runways\" to toggle viewing the runways." .. + "\n\n" .. + "Script made by Eraknelo on the forums" + }) +end + +function Helper:ModuleUnload() + Events:Fire( "HelpRemoveItem", + { + name = "Runways" + }) +end + +tester = Helper() diff --git a/client/vfr.lua b/client/vfr.lua index 7ddc0b5..014c0bb 100644 --- a/client/vfr.lua +++ b/client/vfr.lua @@ -5,6 +5,7 @@ function VFR:__init() self.runways = LoadRunways() self.inPlane = false + self.beVisible = true -- couldn't think of a better name but this is just whether or not the runways are visible self.planes = { [59] = true, @@ -21,6 +22,7 @@ function VFR:__init() Events:Subscribe("LocalPlayerEnterVehicle", self, self.LocalPlayerEnterVehicle) Events:Subscribe("LocalPlayerExitVehicle", function() self.inPlane = false end) Events:Subscribe("Render", self, self.Render) + Network:Subscribe("toggleVFR", self, self.ToggleVFR) end function VFR:LocalPlayerEnterVehicle(args) @@ -35,7 +37,7 @@ function VFR:LocalPlayerEnterVehicle(args) end function VFR:Render() - if not self.inPlane or Game:GetState() ~= GUIState.Game then return end + if not self.inPlane or Game:GetState() ~= GUIState.Game or not self.beVisible then return end -- Check all runways for index, data in pairs(self.runways) do @@ -54,6 +56,11 @@ function VFR:Render() end end +-- toggles if runways are visible or not +function VFR:ToggleVFR() + self.beVisible = not self.beVisible +end + Events:Subscribe("ModuleLoad", function() VFR() end) \ No newline at end of file diff --git a/server/server.lua b/server/server.lua new file mode 100644 index 0000000..eea2510 --- /dev/null +++ b/server/server.lua @@ -0,0 +1,10 @@ +-- No need for a class if it's only 1 function + +-- function checks for if someone says "/runways" +OnPlayerChat = function(args) + if args.text == "/runways" then + Network:Send(args.player, "toggleVFR") + end +end + +Events:Subscribe("PlayerChat", OnPlayerChat)