Skip to content

Commit 9decaaa

Browse files
authored
Merge pull request #13 from Project-Sloth:dom-messedup
- `moved` export handler to shared
2 parents 9c4a66b + 7e15895 commit 9decaaa

File tree

6 files changed

+464
-3
lines changed

6 files changed

+464
-3
lines changed

bridge/framework/esx/client.lua

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
2+
ps.citizenid = nil
3+
ps.charinfo = nil
4+
ps.ped = nil
5+
ps.name = nil
6+
CreateThread(function()
7+
ps.citizenid = ESX.PlayerData.identifier
8+
ps.charinfo = {
9+
firstname = ESX.PlayerData.firstname,
10+
lastname = ESX.PlayerData.lastname,
11+
age = ESX.PlayerData.dateofbirth,
12+
genfer = ESX.PlayerData.sex,
13+
}
14+
ps.ped = PlayerPedId()
15+
ps.name = ESX.PlayerData.firstname .. " " .. ESX.PlayerData.lastname
16+
end)
17+
18+
19+
20+
---@return: table
21+
---@DESCRIPTION: Returns the player's data, including job, gang, and metadata.
22+
function ps.getPlayerData()
23+
return ESX.PlayerData
24+
end
25+
26+
--- @return: string
27+
--- @DESCRIPTION: Returns the player's citizen ID.
28+
--- @example: ps.getIdentifier()
29+
function ps.getIdentifier()
30+
return ps.citizenid
31+
end
32+
33+
--- @PARAM: meta: string
34+
--- @return: any
35+
--- @DESCRIPTION: Returns specific metadata for the player.
36+
--- @example: ps.getMetadata('isdead')
37+
function ps.getMetadata(meta)
38+
return ps.getPlayerData().metadata[meta]
39+
end
40+
41+
--- @PARAM: info: string
42+
--- @return: any
43+
--- @DESCRIPTION: Returns specific character information based on the provided key.
44+
--- @example: ps.getCharInfo('age')
45+
function ps.getCharInfo(info)
46+
return ps.charinfo[info]
47+
end
48+
49+
--- @return: string
50+
--- @DESCRIPTION: Returns the player's full name.
51+
function ps.getPlayerName()
52+
return ps.name
53+
end
54+
55+
--- @return: number
56+
--- @DESCRIPTION: Returns the player's ped ID.
57+
function ps.getPlayer()
58+
return ps.ped
59+
end
60+
61+
--- @PARAM: model: number | string
62+
--- @RETURN: string
63+
--- @DESCRIPTION: Returns the vehicle label for the given model.
64+
function ps.getVehicleLabel(model)
65+
local vehicle = ps.callback('ps_lib:esx:getVehicleLabel', model)
66+
return vehicle or GetDisplayNameFromVehicleModel(model)
67+
end
68+
69+
70+
--- @DESCRIPTION: Checks if the player is dead or in last stand.
71+
--- @return boolean
72+
--- @example if ps.isDead() then Revive end
73+
function ps.isDead()
74+
return ESX.PlayerData.dead
75+
end
76+
77+
--- @return: table
78+
--- @DESCRIPTION: Returns the player's job information, including name, type, and duty status.
79+
function ps.getJob()
80+
return ESX.PlayerData.job
81+
end
82+
83+
--- @RETURN: string
84+
--- @DESCRIPTION: Returns the name of the player's job.
85+
--- @example: ps.getJobName()
86+
function ps.getJobName()
87+
return ps.getJob().name
88+
end
89+
90+
--- @RETURN: string
91+
--- @DESCRIPTION: Returns the type of the player's job.
92+
--- @example: ps.getJobType()
93+
function ps.getJobType()
94+
return ps.getJob().name
95+
end
96+
97+
--- @RETURN: boolean
98+
--- @DESCRIPTION: Checks if the player's job is a boss job.
99+
--- @example: if ps.isBoss() then TriggerEvent('qb-bossmenu:client:openMenu') end
100+
function ps.isBoss()
101+
return ps.getJob().name == 'boss'
102+
end
103+
104+
--- @RETURN: boolean
105+
--- @DESCRIPTION: Checks if the player is on duty for their job.
106+
--- @example: if ps.getJobDuty() then TriggerEvent('qb-phone:client:openJobPhone') end
107+
function ps.getJobDuty()
108+
return true
109+
end
110+
111+
--- @PARAM: data: string
112+
--- @RETURN: any
113+
--- @DESCRIPTION: Returns the job data for the specified key.
114+
function ps.getJobData(data)
115+
local job = ps.getJob()
116+
return job[data]
117+
end
118+
119+
--- @return: table
120+
--- @DESCRIPTION: Returns the player's gang information, including name, type, and duty status.
121+
--- @example: ps.getGang()
122+
123+
function ps.getGang()
124+
local player = ps.getPlayerData()
125+
return player.job
126+
end
127+
128+
--- @RETURN: string
129+
--- @DESCRIPTION: Returns the name of the player's gang.
130+
--- @example: ps.getGangName()
131+
--- @
132+
--- @-- Does esx support Gangs?
133+
--function ps.getGangName()
134+
-- local job = ps.getGang()
135+
-- return job.name
136+
--end
137+
138+
--- @RETURN: string
139+
--- @DESCRIPTION: Returns if the player is a gang boss.
140+
--- @example: ps.isLeader()
141+
--function ps.isLeader()
142+
-- local Gang = ps.getGang()
143+
-- return Gang.isboss
144+
--end
145+
146+
147+
--- @PARAM: data: string
148+
--- @RETURN: any
149+
--- @DESCRIPTION: Returns specific data from the gang information.
150+
--function ps.getGangData(data)
151+
-- local Gang = ps.getGang()
152+
-- return Gang[data]
153+
--end
154+
155+
--- @RETURN: boolean
156+
--- @DESCRIPTION: Checks the coords of the player.
157+
--- @example: if ps.getCoords() then end
158+
function ps.getCoords()
159+
return GetEntityCoords(ps.ped)
160+
end
161+
162+
function ps.getMoneyData()
163+
local money = {
164+
cash = ESX.PlayerData.money,
165+
bank = ESX.GetAccount('bank'),
166+
}
167+
return money
168+
end
169+
function ps.getMoney(type)
170+
return ps.getMoneyData()[type] or 0
171+
end
172+
173+
function ps.getAllMoney()
174+
local money = ps.getMoneyData()
175+
local moneyData = {}
176+
for k, v in pairs(money) do
177+
table.insert(moneyData, {
178+
amount = v,
179+
name = k
180+
})
181+
end
182+
return moneyData
183+
end

0 commit comments

Comments
 (0)