forked from MadsLeander/hookers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.lua
More file actions
175 lines (143 loc) · 4.76 KB
/
Copy pathmenu.lua
File metadata and controls
175 lines (143 loc) · 4.76 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
local serviceSelected = nil
local servicesMenu = {
Title = "Services Available",
Buttons = {
{ service = "SERVICE_BLOWJOB", label = "Blow Job", price = Config.PaymentEnabled and Config.Prices.SERVICE_BLOWJOB or nil },
{ service = "SERVICE_SEX", label = "Sex", price = Config.PaymentEnabled and Config.Prices.SERVICE_SEX or nil },
{ service = "SERVICE_DECLINE", label = "Decline Service" },
},
OnButtonSelected = function(button)
serviceSelected = button.service
end
}
local colour = {
white = { 255, 255, 255 },
black = { 0, 0, 0 }
}
local menu = {
x = 0.24, y = 0.05, width = 0.225, height = 0.035
}
local function LoadStreamedTextureDict(textureDict)
RequestStreamedTextureDict(textureDict, false)
if not HasStreamedTextureDictLoaded(textureDict) then
Wait(100)
end
end
local function UnloadStreamedTextureDict(textureDict)
if HasStreamedTextureDictLoaded(textureDict) then
SetStreamedTextureDictAsNoLongerNeeded(textureDict)
end
end
local function DrawText(intFont, stirngText, floatScale, intPosX, intPosY, color)
SetTextFont(intFont)
SetTextScale(floatScale, floatScale)
SetTextColour(color[1], color[2], color[3], 255)
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(stirngText)
EndTextCommandDisplayText(intPosX, intPosY)
end
local function GetButtons()
local allButtons = servicesMenu.Buttons
if not allButtons then return {} end
servicesMenu.TempData = { allButtons, #allButtons }
return allButtons, #allButtons
end
local function DrawMenuButton(button, intX, intY, boolSelected, intW, intH)
local rectColour = boolSelected and colour.white or colour.black
local rectAlpha = boolSelected and 255 or 100
DrawRect(intX, intY, intW, intH, rectColour[1], rectColour[2], rectColour[3], rectAlpha)
local textColour = boolSelected and colour.black or colour.white
local text = button.price and string.format("%s ($%s)", button.label, button.price) or button.label
DrawText(0, text, 0.35, intX - intW / 2 + 0.005, intY - intH / 2 + 0.0025, textColour)
end
local function DrawTitle()
DrawRect(servicesMenu.Width - menu.width / 2, servicesMenu.Height - menu.height / 2, menu.width, menu.height, colour.black[1], colour.black[2], colour.black[3], 255)
servicesMenu.Height = servicesMenu.Height + 0.005
DrawText(0, servicesMenu.Title, 0.35, servicesMenu.Width - menu.width + 0.005, servicesMenu.Height - menu.height - 0.002, colour.white)
servicesMenu.Height = servicesMenu.Height + 0.01
end
local function DrawButtons()
for index, data in ipairs(servicesMenu.Buttons) do
local boolSelected = index == servicesMenu.Line.current
DrawMenuButton(data, servicesMenu.Width - menu.width / 2, servicesMenu.Height, boolSelected, menu.width, menu.height)
servicesMenu.Height = servicesMenu.Height + menu.height
end
end
local function DrawMenu()
servicesMenu.Height = menu.y
servicesMenu.Width = menu.x
DrawTitle()
DrawButtons()
end
local function HandleControls()
-- Move up/down
local moveUp, moveDown = IsControlPressed(1, 172), IsControlPressed(1, 173)
if moveUp or moveDown then
PlaySoundFrontend(-1, "NAV_UP_DOWN", "HUD_FREEMODE_SOUNDSET", true)
local newLine = servicesMenu.Line.current
if moveUp then
newLine = newLine - 1
if newLine < servicesMenu.Line.min then
newLine = servicesMenu.Line.max
end
elseif moveDown then
newLine = newLine + 1
if newLine > servicesMenu.Line.max then
newLine = servicesMenu.Line.min
end
end
servicesMenu.Line.current = newLine
Wait(150)
end
-- Selected current button
if IsControlJustPressed(1, 201) then
PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", true)
local currentButtons = table.unpack(servicesMenu.TempData)
servicesMenu.OnButtonSelected(currentButtons[servicesMenu.Line.current])
end
-- Exits the menu
if IsControlJustPressed(1, 202) then
serviceSelected = "SERVICE_DECLINE"
Wait(100)
end
end
local function MenuThreads()
CreateThread(function()
while servicesMenu.IsOpen do
DrawMenu()
Wait(0)
end
end)
CreateThread(function()
while servicesMenu.IsOpen do
HandleControls()
Wait(0)
end
end)
end
local function CloseMenu()
if servicesMenu.IsOpen then
servicesMenu.IsOpen = false
servicesMenu.TempData = {}
servicesMenu.Line = {}
UnloadStreamedTextureDict("CommonMenu")
end
end
local function OpenMenu()
LoadStreamedTextureDict("CommonMenu")
local newButtons, buttonsCount = GetButtons()
servicesMenu.Line = { min = 1, max = buttonsCount, current = 1 }
servicesMenu.TempData = { newButtons, buttonsCount }
servicesMenu.IsOpen = true
MenuThreads()
end
function OfferServices()
OpenMenu()
while not serviceSelected do
Wait(25)
end
CloseMenu()
local service = serviceSelected
serviceSelected = nil
return service
end