Skip to content

Commit 9888a58

Browse files
author
Aland Mariwan
committed
Shops for FiveM GTA RP
0 parents  commit 9888a58

File tree

8 files changed

+903
-0
lines changed

8 files changed

+903
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Aland Mariwan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
[ Info ]
4+
5+
- This is a shop/store script for ESX, this is different from the normal esx_shops as it is more interactive. You walk around in the store to grab stuff from the shelfs to put into your basket on L, then go to the cashier and be prompted with the choice to pay with cash or with your credit card. See video for better explanation
6+
7+
[ Features ]
8+
9+
- Customizable config file.
10+
11+
[ Installation ]
12+
13+
1. Download
14+
2. Put this resource into your resources
15+
3. Run the SQL file
16+
4. Put `start am-shops` into your server.cfg
17+
18+
- And change what you want.
19+
20+
[ Requirements ]
21+
22+
- ESX
23+
- esx_menu_default
24+
- pNotify
25+

__resource.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
2+
3+
client_scripts {
4+
'client/main.lua',
5+
'client/shop.lua',
6+
}
7+
8+
server_scripts {
9+
'server/main.lua',
10+
}
11+
12+
shared_script 'config.lua'

client/main.lua

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
Keys = {["E"] = 38, ["L"] = 182, ["G"] = 47}
2+
3+
payAmount = 0
4+
Basket = {}
5+
6+
--[[ Gets the ESX library ]]--
7+
ESX = nil
8+
Citizen.CreateThread(function()
9+
while ESX == nil do
10+
Citizen.Wait(10)
11+
12+
TriggerEvent("esx:getSharedObject", function(obj)
13+
ESX = obj
14+
end)
15+
end
16+
end)
17+
18+
DrawText3D = function(x, y, z, text)
19+
local onScreen,x,y = World3dToScreen2d(x, y, z)
20+
local factor = #text / 370
21+
22+
if onScreen then
23+
SetTextScale(0.35, 0.35)
24+
SetTextFont(4)
25+
SetTextProportional(1)
26+
SetTextColour(255, 255, 255, 215)
27+
SetTextEntry("STRING")
28+
SetTextCentre(1)
29+
AddTextComponentString(text)
30+
DrawText(x,y)
31+
DrawRect(x,y + 0.0125, 0.015 + factor, 0.03, 41, 11, 41, 120)
32+
end
33+
end
34+
35+
--[[ Requests specified model ]]--
36+
_RequestModel = function(hash)
37+
if type(hash) == "string" then hash = GetHashKey(hash) end
38+
RequestModel(hash)
39+
while not HasModelLoaded(hash) do
40+
Wait(0)
41+
end
42+
end
43+
44+
--[[ Deletes the cashiers ]]--
45+
DeleteCashier = function()
46+
for i=1, #Config.Locations do
47+
local cashier = Config.Locations[i]["cashier"]
48+
if DoesEntityExist(cashier["entity"]) then
49+
DeletePed(cashier["entity"])
50+
SetPedAsNoLongerNeeded(cashier["entity"])
51+
end
52+
end
53+
end
54+
55+
Citizen.CreateThread(function()
56+
local defaultHash = 416176080
57+
for i=1, #Config.Locations do
58+
local cashier = Config.Locations[i]["cashier"]
59+
if cashier then
60+
cashier["hash"] = cashier["hash"] or defaultHash
61+
_RequestModel(cashier["hash"])
62+
if not DoesEntityExist(cashier["entity"]) then
63+
cashier["entity"] = CreatePed(4, cashier["hash"], cashier["x"], cashier["y"], cashier["z"], cashier["h"])
64+
SetEntityAsMissionEntity(cashier["entity"])
65+
SetBlockingOfNonTemporaryEvents(cashier["entity"], true)
66+
FreezeEntityPosition(cashier["entity"], true)
67+
SetEntityInvincible(cashier["entity"], true)
68+
end
69+
SetModelAsNoLongerNeeded(cashier["hash"])
70+
end
71+
end
72+
end)
73+
74+
--[[ Creates cashiers and blips ]]--
75+
Citizen.CreateThread(function()
76+
for i=1, #Config.Locations do
77+
local blip = Config.Locations[i]["blip"]
78+
79+
if blip then
80+
if not DoesBlipExist(blip["id"]) then
81+
blip["id"] = AddBlipForCoord(blip["x"], blip["y"], blip["z"])
82+
SetBlipSprite(blip["id"], 52)
83+
SetBlipDisplay(blip["id"], 4)
84+
SetBlipScale(blip["id"], 1.0)
85+
SetBlipColour(blip["id"], 25)
86+
SetBlipAsShortRange(blip["id"], true)
87+
88+
BeginTextCommandSetBlipName("shopblip")
89+
AddTextEntry("shopblip", "Shop")
90+
EndTextCommandSetBlipName(blip["id"])
91+
end
92+
end
93+
end
94+
end)
95+
96+
--[[ Function to trigger pNotify event for easier use :) ]]--
97+
pNotify = function(message, messageType, messageTimeout)
98+
TriggerEvent("pNotify:SendNotification", {
99+
text = message,
100+
type = messageType,
101+
queue = "shopcl",
102+
timeout = messageTimeout,
103+
layout = "topRight"
104+
})
105+
end
106+
107+
Marker = function(pos)
108+
DrawMarker(25, pos["x"], pos["y"], pos["z"] - 0.98, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.75, 0.75, 200, 200, 200, 60, false, false, 2, false, nil, nil, false)
109+
DrawMarker(25, pos["x"], pos["y"], pos["z"] - 0.98, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.8, 0.8, 200, 200, 200, 60, false, false, 2, false, nil, nil, false)
110+
end
111+
112+
--[[ Deletes the peds when the resource stops ]]--
113+
AddEventHandler('onResourceStop', function(resourceName)
114+
if resourceName == GetCurrentResourceName() then
115+
TriggerServerEvent('esx:clientLog', "[am-shops]: Deleting peds...")
116+
DeleteCashier()
117+
end
118+
end)

0 commit comments

Comments
 (0)