Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _G.GetUser = {
- users = {},
- users_group = {},
- userSource = {},
- userData = {},
- phoneSource = {},
- CurrentCharacter = {}
- }
- _G.GetUserMethods = {}
- GetUserMethods.__call = function(self, source)
- local o = setmetatable({}, {
- __index = self
- })
- o.src = source
- o.id = self.users[o.src]
- o.rank = self.users_group[o.src]
- o.identifier = GetPlayerIdentifiers(o.src)[1]
- return o
- end
- GetUserMethods.__index = {
- getCurrentCharacter = function(self)
- self.character = {}
- self.character.id = self.CurrentCharacter[self.id]
- local shared_bank
- local data_mt = {
- __index =
- function(t, k)
- if k == "bank" then
- return shared_bank
- end
- end,
- __newindex =
- function(t, k, v)
- if k == "bank" then
- shared_bank = v
- else
- rawset(t, k, v)
- end
- end,
- }
- self.character.data = function()
- local d = self.userData[self.character.id]
- if d and getmetatable(d) ~= data_mt then
- d.bank = nil
- setmetatable(d, data_mt)
- end
- return d
- end
- self.character.getCash = function()
- if self.character.data() then
- return self.character.data().cash
- end
- return nil
- end
- self.character.giveCash = function(value)
- if self.character.data() then
- self.character.data().cash = self.character.data().cash + value
- end
- end
- self.character.giveBank = function(value)
- if self.character.data() then
- self.character.data().bank = self.character.data().bank + value
- end
- end
- self.character.getBank = function()
- if self.character.data() then
- return self.character.data().bank
- end
- return 0
- end
- self.character.tryPayment = function(type,amount)
- if type == "cash" then
- if self.character.data().cash >= amount then
- self.character.data().cash = self.character.data().cash - amount
- return true
- else
- return false
- end
- elseif type == "bank" then
- if self.character.data().bank >= amount then
- self.character.data().bank = self.character.data().bank - amount
- return true
- else
- return false
- end
- end
- end
- self.character.getHunger = function()
- if self.character.data() then
- return self.character.data().hunger
- end
- return 0
- end
- self.character.getThirst = function()
- if self.character.data() then
- return self.character.data().thirst
- end
- return 0
- end
- self.character.getStress = function()
- if self.character.data() then
- return self.character.data().stress
- end
- return 0
- end
- self.character.addStress = function(value)
- if self.character.data() then
- self.character.data().stress = self.character.data().stress + value
- if self.character.data().stress <= 0 then
- self.character.data().stress = 0
- elseif self.character.data().stress >= 100 then
- self.character.data().stress = 100
- end
- end
- end
- self.character.addThirst = function(value)
- if self.character.data() then
- self.character.data().thirst = self.character.data().thirst + value
- if self.character.data().thirst <= 0 then
- self.character.data().thirst = 0
- elseif self.character.data().thirst >= 100 then
- self.character.data().thirst = 100
- end
- end
- end
- self.character.addHunger = function(value)
- if self.character.data() then
- self.character.data().hunger = self.character.data().hunger + value
- if self.character.data().hunger <= 0 then
- self.character.data().hunger = 0
- elseif self.character.data().hunger >= 100 then
- self.character.data().hunger = 100
- end
- end
- end
- return self.character
- end
- }
- setmetatable(GetUser, GetUserMethods)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement