Team Spartan Cookies & Milk Forums
Release Scifi door - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: Release Scifi door (/thread-556.html)



Scifi door - LocInt - 25-10-2014

Here is my first release. Newest version can always be found in my shared folder.
Code:
--@name Scifi_door --@author LocInt --@model models/lt_c/sci_fi/door_airlock_96x192x16_frame.mdl if SERVER then local HoloLib = loadLibrary("holograms") local FindLib = loadLibrary("find") local EntLib = loadLibrary("ents") local PropLib = loadLibrary("props") local Entity = EntLib.self() local TimeLib = loadLibrary("time") local SoundLib = loadLibrary("sounds") local TableLib = loadLibrary("table") local GlobalLib= loadLibrary("globaltables") local Close = 0 local Open = 0 local function IsValid( Ent ) return Ent and Ent.isValid and Ent:isValid() end local function Filter( Ent ) -- check rank here. if Ent:isPlayer() then return true else return false end end function doorClose() DoorHolo:setAnim(3) TimeLib.timer( "BackToThink", 5, 1, function() DoorHolo:remove() DoorProp:setAlpha(1000) DoorProp:setMaterial("") DoorProp:setNotSolid(false) Open=0 end) end function doorOpen() DoorProp:setAlpha(1) DoorProp:setMaterial("models/props_canal/metalwall005b") DoorProp:setNotSolid(true) if(not IsValid(DoorHolo)) then DoorHolo = HoloLib.create( Entity:getPos(), Entity:ang(), "models/lt_c/sci_fi/door_airlock_96x192x16.mdl", 1 ) end DoorHolo:setAnim(2) DoorHolo:setSkin(2) TimeLib.timer( "DoorClose", 5, 1, function() doorClose() end) end local function think() local Players = find.inSphere(Entity:pos(), 100, Filter) if Players != nil then if #Players > 0 then for i,v in pairs(Players) do if v and IsValid(v) then if(Close == 0 and Open == 0) then Open=1 TimeLib.timer( "DoorOpen", 0.1, 1, function() doorOpen() end) break end end end end end end local function createDoor() DoorProp=FindLib.inSphere( ents.self():pos(), 100, function( Ent ) return Ent:model():lower()=="models/lt_c/sci_fi/door_airlock_96x192x16_static.mdl" end ) if(not IsValid(DoorProp[1])) then DoorProp = PropLib.create("models/lt_c/sci_fi/door_airlock_96x192x16_static.mdl",Entity:getPos(),Entity:ang()) DoorProp:setFrozen(true) DoorProp:parentTo(Entity) DoorProp:setSkin(1) Entity:setSkin(1) end TimeLib.timer( "Think", 1,0, function() think() end) end TimeLib.timer( "CreateDoor", 1,1, function() createDoor() end) end