-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsatchel.lua
159 lines (115 loc) · 5.77 KB
/
satchel.lua
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
-- Ref: https://github.com/aaron1a12/wild/blob/9235aaa39696691ff26977ff1d2c18fe67971ef5/wild-satchel/client/cl_satchel_native_research.lua
function OpenSatchel()
--TASK::TASK_PLAY_ANIM(Global_34, func_3189(bParam0->f_61), func_3190(bParam0->f_61), 8f, -8f, -1, 67108880, 0f, false, 4096, false, "Satchel_Only_filter", false);
--LaunchUiappByHash(`satchel`)
LaunchUiappByHashWithEntry(`satchel`, `INGAME`)
-- Get or create the data container for the ui app, in this case, Satchel
local satchelData = DatabindingGetDataContainerFromPath("Satchel")
if satchelData == 0 then
print("creating satchel")
satchelData = DatabindingAddDataContainerFromPath("", "Satchel")
end
DatabindingAddDataBool(satchelData, "FolderEmpty", false)
local selectedData = DatabindingAddDataContainer(satchelData, "Selected")
DatabindingAddDataHash(selectedData, "Name", 0)
DatabindingAddDataHash(selectedData, "Category", 0)
DatabindingAddDataInt(selectedData, "DefaultCategoryIndex", 0)
DatabindingAddDataInt(selectedData, "CategoryIndex", 0)
DatabindingAddDataInt(selectedData, "CategoryCount", 0) -- enables category switch if > 1
DatabindingAddDataString(selectedData, "IndexDescription", "[1 of ???]")
DatabindingAddDataString(selectedData, "Tip", "[tip]")
N_0x9d21b185abc2dbc4(selectedData, "effects", 0, 0)
DatabindingAddDataHash(selectedData, "Folder", 0)
-- Exists before we make it??
local satchelCategoryItemsData = DatabindingGetDataContainerFromPath("satchel_category_items")
local satchelMenuItemsData = DatabindingGetDataContainerFromPath("satchel_menu_items")
local satchelListItemsData = DatabindingGetDataContainerFromPath("satchel_list_items")
DatabindingSetTemplatedUiItemListSize(satchelListItemsData, 3)
DatabindingSetTemplatedUiItemListSize(satchelMenuItemsData, 3)
local collectionsList = DatabindingAddUiItemList(satchelData, "Collections")
local playerDat = DatabindingAddDataContainer(collectionsList, "player")
DatabindingAddDataHash(playerDat, "label", `SATCHEL_TITLE`)
DatabindingInsertUiItemToListFromContextHashAlias(collectionsList, -1, -1287062382, playerDat)
local menuList = DatabindingAddUiItemList(satchelMenuItemsData, "List")
local item = DatabindingAddDataContainer(satchelData, "fooba2r")
DatabindingInsertUiItemToListFromContextStringAlias(menuList, -1, "ft_dynamic_text_and_price", item)
Citizen.CreateThread(function()
while IsUiappRunningByHash(`satchel`) == 1 do
-- Listen for ui events
while EventsUiIsPending(`satchel`) do
local msg = DataView.ArrayBuffer(8 * 4)
msg:SetInt32(0, 0)
msg:SetInt32(8, 0)
msg:SetInt32(16, 0)
msg:SetInt32(24, 0) -- item data container
if (Citizen.InvokeNative(0x90237103F27F7937, `satchel`, msg:Buffer()) ~= 0) then -- EVENTS_UI_PEEK_MESSAGE
if msg:GetInt32(0) == `ITEM_FOCUSED` then
ShowText("Focus")
end
if msg:GetInt32(0) == `ITEM_SELECTED` then
ShowText("Select")
end
if msg:GetInt32(16) == `SATCHEL_UI_EVENT_EXIT` then
end
if msg:GetInt32(16) == `SATCHEL_UI_EVENT_FILTER` then
ShowText("Filter")
end
end
EventsUiPopMessage(`satchel`)
end
Citizen.Wait(0)
end
DatabindingRemoveDataEntry(satchelData)
DatabindingRemoveDataEntry(selectedData)
DatabindingRemoveDataEntry(collectionsList)
DatabindingRemoveDataEntry(menuList)
end)
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(0, "INPUT_OPEN_SATCHEL_MENU") and not bOutfitLock then
local prompt = 0
-- Create prompt
if prompt == 0 then
prompt = PromptRegisterBegin()
PromptSetControlAction(prompt, GetHashKey("INPUT_OPEN_SATCHEL_MENU")) -- L key
PromptSetText(prompt, CreateVarString(10, "LITERAL_STRING", "Satchel"))
UiPromptSetHoldMode(prompt, 750)
UiPromptSetAttribute(prompt, 2, true)
UiPromptSetAttribute(prompt, 4, true)
UiPromptSetAttribute(prompt, 9, true)
UiPromptSetAttribute(prompt, 10, true) -- kPromptAttrib_NoButtonReleaseCheck. Immediately becomes pressed
UiPromptSetAttribute(prompt, 17, true) -- kPromptAttrib_NoGroupCheck. Allows to appear in any active group
PromptRegisterEnd(prompt)
Citizen.CreateThread(function()
Citizen.Wait(100)
while UiPromptGetProgress(prompt) ~= 0.0 and UiPromptGetProgress(prompt) ~= 1.0 do
Citizen.Wait(0)
end
if UiPromptGetProgress(prompt) == 1.0 then
OpenSatchel()
end
PromptDelete(prompt)
prompt = 0
Citizen.Wait(1000)
end)
end
end
end
end)
RegisterCommand('iguana', function()
local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(PlayerId()), false))
local model = `A_C_Iguana_01`
RequestModel(model)
while not HasModelLoaded(model) do
RequestModel(model)
Citizen.Wait(0)
end
local ped = CreatePed(model, x, y+1.0, z, 45.0, true, true, true)
SetEntityInvincible(ped, true)
SetPedKeepTask(ped)
SetPedAsNoLongerNeeded(ped)
SetRandomOutfitVariation(ped)
SetEntityHealth(ped, 0)
end, false)