forked from FiveM-Scripts/fs_taxi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.lua
55 lines (47 loc) · 2.04 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
--[[
fs_taxi - Taxi service for FiveM Servers
Copyright (C) 2018 FiveM-Scripts
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program in the file "LICENSE". If not, see <http://www.gnu.org/licenses/>.
]]
PerformHttpRequest("https://raw.githubusercontent.com/FiveM-Scripts/fs_taxi/master/__resource.lua", function(errorCode, result, headers)
local version = GetResourceMetadata(GetCurrentResourceName(), 'resource_version', 0)
if string.find(tostring(result), version) == nil then
print("\n\r[fs_taxi] The version on this server is not up to date. Please update now.\n\r")
end
end, "GET", "", "")
RegisterServerEvent('fs_taxi:payCab')
AddEventHandler('fs_taxi:payCab', function(meters)
local src = source
local totalPrice = meters / 40.0
local price = math.floor(totalPrice)
if optional.use_essentialmode then
TriggerEvent('es:getPlayerFromId', src, function(user)
if user.getMoney() >= tonumber(price) then
user.removeMoney(tonumber(price))
TriggerClientEvent('fs_taxi:payment-status', src, true)
else
TriggerClientEvent('fs_taxi:payment-status', src, false)
end
end)
elseif optional.use_venomous then
TriggerEvent('vf_base:FindPlayer', src, function(user)
if user.cash >= tonumber(price) then
TriggerEvent('vf_base:ClearCash', src, tonumber(price))
TriggerClientEvent('fs_taxi:payment-status', src, true)
else
TriggerClientEvent('fs_taxi:payment-status', src, false)
end
end)
else
TriggerClientEvent('fs_taxi:payment-status', src, true)
end
end)