-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.lua
72 lines (56 loc) · 2.5 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
local function GetAmmoutBoates( Player_ID, Character_ID )
local HasBoates = MySQL.Sync.fetchAll( "SELECT * FROM boates WHERE identifier = @identifier AND charid = @charid ", {
['identifier'] = Player_ID,
['charid'] = Character_ID
} )
if #HasBoates > 0 then return true end
return false
end
RegisterServerEvent('elrp:buyboat')
AddEventHandler( 'elrp:buyboat', function ( args )
local _src = source
local _price = args['Price']
local _level = args['Level']
local _model = args['Model']
TriggerEvent('redemrp:getPlayerFromId', _src, function(user)
u_identifier = user.getIdentifier()
u_level = user.getLevel()
u_charid = user.getSessionVar("charid")
u_money = user.getMoney()
end)
local _resul = GetAmmoutBoates( u_identifier, u_charid )
if u_money <= _price then
TriggerClientEvent( 'UI:DrawNotification', _src, Config.NoMoney )
return
end
if u_level <= _level then
TriggerClientEvent( 'UI:DrawNotification', _src, Config.LevelMissing )
return
end
TriggerEvent('redemrp:getPlayerFromId', _src, function(user)
user.removeMoney(_price)
end)
if _resul ~= true then
local Parameters = { ['identifier'] = u_identifier, ['charid'] = u_charid, ['boat'] = _model }
MySQL.Async.execute("INSERT INTO boates ( `identifier`, `charid`, `boat` ) VALUES ( @identifier, @charid, @boat )", Parameters)
TriggerClientEvent( 'UI:DrawNotification', _src, 'You Rented a new Boat !' )
else
local Parameters = { ['identifier'] = u_identifier, ['charid'] = u_charid, ['boat'] = _model }
MySQL.Async.execute(" UPDATE boates SET boat = @boat WHERE identifier = @identifier AND charid = @charid ", Parameters)
TriggerClientEvent( 'UI:DrawNotification', _src, '' )
end
end)
RegisterServerEvent( 'elrp:dropboat' )
AddEventHandler( 'elrp:dropboat', function ( )
local _src = source
TriggerEvent('redemrp:getPlayerFromId', _src, function(user)
u_identifier = user.getIdentifier()
u_charid = user.getSessionVar("charid")
end)
local Parameters = { ['identifier'] = u_identifier, ['charid'] = u_charid }
local HasBoates = MySQL.Sync.fetchAll( "SELECT * FROM Boates WHERE identifier = @identifier AND charid = @charid ", Parameters )
if HasBoates[1] then
local boat = HasBoates[1].boat
TriggerClientEvent("elrp:spawnBoat", _src, boat)
end
end )