-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.lua
45 lines (39 loc) · 1.84 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
TriggerEvent("getCore",function(core)
VorpCore = core
end)
VorpInv = exports.vorp_inventory:vorp_inventoryApi()
RegisterServerEvent("syn_construction:gettrustserver")
AddEventHandler("syn_construction:gettrustserver", function()
local _source = source
local User = VorpCore.getUser(source)
local Character = User.getUsedCharacter
local u_identifier = Character.identifier
local u_charid = Character.charIdentifier
exports.ghmattimysql:execute('SELECT trust FROM characters WHERE identifier=@identifier AND charidentifier = @charidentifier', {['identifier'] = u_identifier, ['charidentifier'] = u_charid}, function(result)
if result[1] ~= nil then
local trust = result[1].trust
TriggerClientEvent("syn_construction:gettrustclient",_source,trust)
end
end)
end)
RegisterServerEvent("syn_construction:reward")
AddEventHandler("syn_construction:reward", function(quality,tasksdone,reward,totaltasks)
local _source = source
if 10 > quality then
quality = 10
end
if tasksdone > totaltasks/2 then
local mult1 = tasksdone/totaltasks
local mult2 = quality * 0.01
local pay = (reward * mult1) * mult2
local Character = VorpCore.getUser(_source).getUsedCharacter
local identifier = Character.identifier
local charidentifier = Character.charIdentifier
Character.addCurrency(0, pay)
TriggerClientEvent("vorp:TipRight", _source, Config.CleanLanguage.paid..pay, 5000)
local trust = 1
exports.ghmattimysql:execute("UPDATE characters Set trust=trust+@trust WHERE identifier=@identifier AND charidentifier = @charidentifier", {['trust'] = trust,['identifier'] = identifier, ['charidentifier'] = charidentifier})
else
TriggerClientEvent("vorp:TipRight", _source, Config.CleanLanguage.nowork, 5000)
end
end)