-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc-submain.lua
148 lines (129 loc) · 4.11 KB
/
c-submain.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
HelpText = function(text, sound, duration)
BeginTextCommandDisplayHelp('STRING')
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayHelp(0, false, sound, duration)
end
function OpenShopMenu(zone)
local elements = {}
ShopOpen = true
for k,v in ipairs(Config.Weapons) do
table.insert(elements, {
label = ('%s - <span style="color:green;">$%s</span>'):format(v.label, ESX.Math.GroupDigits(v.price)),
name = v.label,
model = v.model,
price = v.price,
identifier = v.id
})
end
ESX.UI.Menu.CloseAll()
PlaySoundFrontend(-1, 'BACK', 'HUD_AMMO_SHOP_SOUNDSET', false)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', {
title = _U('shop_menu_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
ESX.TriggerServerCallback('dk-weaponshop:buyWeapon', function(bought)
if bought then
DisplayBoughtScaleform(data.current.model, data.current.price)
else
PlaySoundFrontend(-1, 'ERROR', 'HUD_AMMO_SHOP_SOUNDSET', false)
end
end, data.current.model,data.current.identifier)
end, function(data, menu)
PlaySoundFrontend(-1, 'BACK', 'HUD_AMMO_SHOP_SOUNDSET', false)
ShopOpen = false
menu.close()
CurrentAction = 'shop_menu'
CurrentActionMsg = _U('shop_menu_prompt')
CurrentActionData = { zone = zone }
end, function(data, menu)
PlaySoundFrontend(-1, 'NAV', 'HUD_AMMO_SHOP_SOUNDSET', false)
end)
end
function DisplayBoughtScaleform(weaponName, price)
local scaleform = ESX.Scaleform.Utils.RequestScaleformMovie('MP_BIG_MESSAGE_FREEMODE')
local sec = 4
BeginScaleformMovieMethod(scaleform, 'SHOW_WEAPON_PURCHASED')
PushScaleformMovieMethodParameterString(_U('weapon_bought', ESX.Math.GroupDigits(price)))
PushScaleformMovieMethodParameterString(ESX.GetWeaponLabel(weaponName))
PushScaleformMovieMethodParameterInt(GetHashKey(weaponName))
PushScaleformMovieMethodParameterString('')
PushScaleformMovieMethodParameterInt(100)
EndScaleformMovieMethod()
PlaySoundFrontend(-1, 'WEAPON_PURCHASE', 'HUD_AMMO_SHOP_SOUNDSET', false)
Citizen.CreateThread(function()
while sec > 0 do
Citizen.Wait(0)
sec = sec - 0.01
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
end
end)
end
function OpenBuyLicenseMenu(zone)
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_license', {
title = _U('buy_license'),
align = 'top-left',
elements = {
{label = _U('no'), value = 'no'},
{label = _U('yes', ('<span style="color: green;">%s</span>'):format((_U('shop_menu_item', ESX.Math.GroupDigits(Config.LicensePrice))))), value = 'yes'},
}
}, function(data, menu)
if data.current.value == 'yes' then
ESX.TriggerServerCallback('dk-weaponshop:buyLicense', function(bought)
if bought then
menu.close()
OpenShopMenu(zone)
end
end)
end
end, function(data, menu)
menu.close()
end)
end
DrawText3D = function(x,y,z,textInput,fontId,scaleX,scaleY,opacity)
local px,py,pz=table.unpack(GetGameplayCamCoords())
local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
local scale = (1/dist)*8
local fov = (1/GetGameplayCamFov())*100
local scale = scale*fov
SetTextScale(scaleX*scale, scaleY*scale)
SetTextFont(fontId)
SetTextProportional(1)
SetTextColour(250, 250, 250, opacity)
SetTextDropshadow(1, 1, 1, 1, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(textInput)
SetDrawOrigin(x,y,z+2, 0)
DrawText(0.0, 0.0)
ClearDrawOrigin()
end
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
if ShopOpen then
ESX.UI.Menu.CloseAll()
end
end
end)
-- Create Blips
Citizen.CreateThread(function()
for k,v in pairs(Config.Zones) do
if v.Legal then
for i = 1, #v.Locations, 1 do
local blip = AddBlipForCoord(v.Locations[i])
SetBlipSprite (blip, 110)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 0.7)
SetBlipColour (blip, 81)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName(_U('map_blip'))
EndTextCommandSetBlipName(blip)
end
end
end
end)