aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/sh_quests.lua
blob: ace050a0fa59984c32b93d4fb3683af70aa5a521 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--[[
    Details how quests are handeled
]]

local pmeta = FindMetaTable("Player")

if SERVER then
    util.AddNetworkString("synchquest")
end

function pmeta:SynchronizeQuest(name)
    net.Start("synchquest")
    net.WriteString(name)
    net.WriteUInt(self.Quests[name],16)
    net.Send(self)
end

if CLIENT then
    net.Receive("synchquest",function()
        LocalPlayer().Quests = LocalPlayer().Quests or {}
        print("Got quest status")
        local questname,queststatus = net.ReadString(), net.ReadUInt(16)
        LocalPlayer().Quests[questname] = queststatus
    end)

    ART.Quests = ART.Quests or {}
    function ART.RegisterQuest(tbl)
        assert(ART.Quests[tbl.Name] == nil,"Tried to register two quests with the same name:" .. tbl.Name)
        ART.Quests[tbl.Name] = tbl
    end

    function ART.GetQuest(name)
        return ART.Quests[name]
    end
end