forked from aymannajim/esx_ladders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
78 lines (67 loc) · 3.61 KB
/
server.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
-- Copyright (c) 2019-2020, Christopher M, Inferno Collection. All rights reserved.
--
-- This project is licensed under the following:
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to use, copy, modify, and merge the software, under the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE MAY NOT BE SOLD.
--
-- This script is an edited version of Inferno Collection Ladders
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
-- xPlayer.removeInventoryItem('ladder', 1)
-- xPlayer.addInventoryItem('ladder', 1)
local Ladders = {}
local usingLadder = false
ESX.RegisterUsableItem('ladder', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if usingLadder == false then
xPlayer.removeInventoryItem('ladder', 1)
TriggerClientEvent('Ladders:Client:Local:Add', -1, source)
usingLadder = true
else
TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'error', text = Strings[Lang]['already_carrying'], length = 3000})
end
end)
RegisterServerEvent('Ladders:Server:GiveItem')
AddEventHandler('Ladders:Server:GiveItem', function()
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addInventoryItem('ladder', 1)
TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'success', text = Strings[Lang]['put_inv_ladder'], length = 4000})
end)
RegisterServerEvent('Ladders:Server:Ladders')
AddEventHandler('Ladders:Server:Ladders', function(Action, LadderNetID, Key, Value)
if Action == 'store' and not Ladders[LadderNetID] then
Ladders[LadderNetID] = {}
Ladders[LadderNetID].ID = LadderNetID
elseif Ladders[LadderNetID] then
if Action == 'update' then
Ladders[LadderNetID][Key] = Value
elseif Action == 'pickup' then
if not Ladders[LadderNetID].BeingCarried and not Ladders[LadderNetID].BeingClimbed then
TriggerClientEvent('Ladders:Client:Pickup', source, LadderNetID)
end
elseif Action == 'climb' then
if Ladders[LadderNetID].Placed and not Ladders[LadderNetID].BeingClimbed then
TriggerClientEvent('Ladders:Client:Climb', source, LadderNetID, Key)
end
elseif Action == 'delete' then
Ladders[LadderNetID] = nil
-- deletes the ladder from the ground and everything
end
end
TriggerClientEvent('Ladders:Bounce:ServerValues', -1, Ladders)
end)
RegisterServerEvent('Ladders:Server:Ladders:Local')
AddEventHandler('Ladders:Server:Ladders:Local', function(Action)
if Action == "add" then
TriggerClientEvent('Ladders:Client:Local:Add', -1, source)
usingLadder = true
else
TriggerClientEvent('Ladders:Client:Local:Remove', -1, source)
usingLadder = false
end
end)
RegisterServerEvent('Ladders:Server:PersonalRequest')
AddEventHandler('Ladders:Server:PersonalRequest', function()
TriggerClientEvent('Ladders:Bounce:ServerValues', -1, Ladders)
end)