├── vrp_basic_mission
├── server.lua
├── fxmanifest.lua
├── __resource.lua
├── cfg
│ ├── lang
│ │ ├── en.lua
│ │ ├── fr.lua
│ │ └── pt-pt.lua
│ └── missions.lua
└── server_vrp.lua
├── README.adoc
└── LICENSE
/vrp_basic_mission/server.lua:
--------------------------------------------------------------------------------
1 | local Proxy = module("vrp", "lib/Proxy")
2 |
3 | local vRP = Proxy.getInterface("vRP")
4 |
5 | async(function()
6 | vRP.loadScript("vrp_basic_mission", "server_vrp")
7 | end)
8 |
--------------------------------------------------------------------------------
/vrp_basic_mission/fxmanifest.lua:
--------------------------------------------------------------------------------
1 | fx_version "adamant"
2 | games {"gta5"}
3 |
4 | description "vRP basic mission"
5 | --ui_page "ui/index.html"
6 |
7 | dependency "vrp"
8 |
9 | server_script "@vrp/lib/utils.lua"
10 | server_script "server.lua"
11 |
--------------------------------------------------------------------------------
/vrp_basic_mission/__resource.lua:
--------------------------------------------------------------------------------
1 | resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"
2 |
3 | description "vRP basic mission"
4 | --ui_page "ui/index.html"
5 |
6 | dependency "vrp"
7 |
8 | server_script "@vrp/lib/utils.lua"
9 | server_script "server.lua"
10 |
--------------------------------------------------------------------------------
/vrp_basic_mission/cfg/lang/en.lua:
--------------------------------------------------------------------------------
1 |
2 | local lang = {
3 | repair = "Repair {1}.",
4 | reward = "Reward: {1} $.",
5 | delivery = {
6 | title = "Delivery",
7 | item = "- {2} {1}"
8 | },
9 | paycheck = {
10 | title = "Paycheck",
11 | text = "Get paycheck of {1} $."
12 | }
13 | }
14 |
15 | return lang
16 |
--------------------------------------------------------------------------------
/vrp_basic_mission/cfg/lang/fr.lua:
--------------------------------------------------------------------------------
1 |
2 | local lang = {
3 | repair = "Réparer {1}.",
4 | reward = "Récompense: {1} $.",
5 | delivery = {
6 | title = "Livraison",
7 | item = "- {2} {1}"
8 | },
9 | paycheck = {
10 | title = "Paie",
11 | text = "Récupérer sa paie de {1} $."
12 | }
13 | }
14 |
15 | return lang
16 |
--------------------------------------------------------------------------------
/vrp_basic_mission/cfg/lang/pt-pt.lua:
--------------------------------------------------------------------------------
1 | local lang = {
2 | repair = "Reparar {1}.",
3 | reward = "Recompensa: {1} $.",
4 | delivery = {
5 | title = "Entregar",
6 | item = "- {2} {1}"
7 | },
8 | paycheck = {
9 | title = "Pagamento",
10 | text = "Receba o pagamento de {1} $."
11 | }
12 | }
13 |
14 | return lang
15 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = vRP-basic-mission
2 | vRP Extension - some basic missions
3 |
4 | Adds delivery and repair missions.
5 |
6 | Give sometimes a mission to players with the repair/delivery permissions. Good as side task for utility jobs relying on services (drugs delivery for EMS,etc).
7 |
8 | == Setup
9 |
10 | Missions are assigned using the permissions set in `cfg/missions.lua` by a rate of one minute.
11 |
12 | Paycheck:: Triggered at a specific rate (interval).
13 |
14 | Repair:: Triggered sometimes, following the chance option. A chance of 3 will be triggered every 3 minutes (average). For this reason, you can have multiple repair permissions for one player.
15 |
16 | Delivery:: Continuous missions triggered every minute, if not already on a mission. For this reason, only one delivery permission should be used.
17 | What needs to be delivered is randomly generated using the configuration.
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Imagic
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.
22 |
--------------------------------------------------------------------------------
/vrp_basic_mission/cfg/missions.lua:
--------------------------------------------------------------------------------
1 |
2 | local cfg = {}
3 |
4 | -- REPAIR
5 |
6 | -- map of permission -> repair config
7 | -- (multiple repair permissions can work)
8 | --- chance: chance factor per minute (1 => everytime, 10 => 1/10)
9 | --- title
10 | --- positions
11 | --- reward: money reward
12 | --- steps: number of things to fix
13 | cfg.repair = {
14 | ["mission.repair.satellite_dishes"] = {
15 | chance = 5,
16 | title = "satellite dishes",
17 | steps = 3,
18 | positions = {
19 | {1985.55017089844,2929.42211914063,46.5480003356934},
20 | {1965.38012695313,2917.47241210938,56.1684608459473},
21 | {1963.78540039063,2923.09497070313,58.674430847168},
22 | {2000.7314453125,2930.4404296875,56.9706687927246},
23 | {2008.03125,2933.06591796875,59.4772453308105},
24 | {2021.29052734375,2945.23486328125,47.3697547912598},
25 | {2046.88366699219,2944.65673828125,51.0216827392578},
26 | {2048.24487304688,2950.81567382813,57.5155029296875},
27 | {2049.64965820313,2945.82641601563,57.5173225402832},
28 | {2043.96203613281,2945.04541015625,60.0233764648438},
29 | {2063.26318359375,2954.65551757813,47.1244201660156},
30 | {2078.7734375,2945.44653320313,56.4166870117188},
31 | {2084.89599609375,2949.8955078125,58.922477722168},
32 | {2075.71948242188,2950.55688476563,58.9233741760254},
33 | {2098.6142578125,2939.935546875,47.3400077819824},
34 | {2106.00659179688,2926.54125976563,50.9320068359375},
35 | {2106.63671875,2923.71069335938,57.4270858764648},
36 | {2106.38110351563,2929.37817382813,59.9300575256348},
37 | {2114.44677734375,2924.77514648438,59.933162689209},
38 | {2127.35888671875,2918.94116210938,47.7327079772949},
39 | {2137.28881835938,2900.53442382813,57.263298034668},
40 | {2137.61767578125,2906.61645507813,59.770336151123},
41 | {2144.6728515625,2900.85595703125,59.7593727111816}
42 | },
43 | reward = 5000
44 | },
45 | ["mission.repair.wind_turbines"] = {
46 | chance = 3,
47 | steps = 3,
48 | title = "wind turbines",
49 | positions = {
50 | {2363.77880859375,2288.63891601563,94.252693176269},
51 | {2347.873046875,2237.5771484375,99.3171691894531},
52 | {2330.4150390625,2114.89965820313,108.288673400879},
53 | {2331.23291015625,2054.52392578125,103.90625},
54 | {2287.10668945313,2075.57153320313,122.888381958008},
55 | {2271.43725585938,1996.4248046875,132.123352050781},
56 | {2307.3681640625,1972.44323730469,131.318496704102},
57 | {2267.27758789063,1917.859375,123.269912719727},
58 | {2299.90209960938,1857.3779296875,106.976081848145},
59 | {2356.48413085938,1836.69982910156,102.337211608887}
60 | },
61 | reward = 2500
62 | }
63 | }
64 |
65 | -- DELIVERY
66 |
67 | local common_delivery_positions = {
68 | {-1087.20959472656,479.4970703125,81.5277786254883},
69 | {-1215.48083496094,457.809478759766,91.9756546020508},
70 | {-1277.36901855469,496.794769287109,97.8074340820313},
71 | {-1380.82360839844,474.517272949219,105.052627563477},
72 | {-1063.642578125,-1054.95007324219,2.15036153793335},
73 | {-1113.640625,-1068.970703125,2.15036201477051},
74 | {-1161.85144042969,-1099.05871582031,2.17665767669678}
75 | }
76 |
77 | -- map of permission => delivery config
78 | --- items: map of idname => {min_amount,max_amount,reward_per_item}
79 | --- positions
80 | -- only one delivery permission can be used per player (no permission selection, only one will work)
81 | cfg.delivery = {
82 | ["mission.delivery.food"] = {
83 | positions = common_delivery_positions,
84 | items = {
85 | ["edible|tacos"] = {0,8,50},
86 | ["edible|water"] = {0,8,40}
87 | }
88 | }
89 | }
90 |
91 | -- PAYCHECK
92 |
93 | -- map of permission => paycheck config
94 | --- position: paycheck position
95 | --- reward: paycheck amount
96 | --- interval: number of minutes between paychecks
97 | cfg.paycheck = {
98 | ["mission.paycheck.police"] = {
99 | position = {447.12612915039,-975.64959716797,30.689586639404},
100 | reward = 3500,
101 | interval = 30
102 | }
103 | }
104 |
105 | return cfg
106 |
--------------------------------------------------------------------------------
/vrp_basic_mission/server_vrp.lua:
--------------------------------------------------------------------------------
1 | local lang = vRP.lang
2 | local Luang = module("vrp", "lib/Luang")
3 |
4 | local basic_mission = class("basic_mission", vRP.Extension)
5 |
6 | function basic_mission:__construct()
7 | vRP.Extension.__construct(self)
8 |
9 | self.cfg = module("vrp_basic_mission", "cfg/missions")
10 |
11 | -- load lang
12 | self.luang = Luang()
13 | self.luang:loadLocale(vRP.cfg.lang, module("vrp_basic_mission", "cfg/lang/"..vRP.cfg.lang))
14 | self.lang = self.luang.lang[vRP.cfg.lang]
15 |
16 | self.paychecks_elapsed = {} -- map of paycheck permission => elapsed mission ticks
17 |
18 | -- task: mission
19 | local function task_mission()
20 | SetTimeout(60000,task_mission)
21 | self:taskMission()
22 | end
23 | async(function()
24 | task_mission()
25 | end)
26 | end
27 |
28 | function basic_mission:taskMission()
29 | -- PAYCHECK
30 | for perm,mission in pairs(self.cfg.paycheck) do -- each repair perm def
31 | local ticks = (self.paychecks_elapsed[perm] or 0)+1
32 | if ticks >= mission.interval then
33 | ticks = 0
34 | -- add missions to users
35 | local users = vRP.EXT.Group:getUsersByPermission(perm)
36 | for _,user in pairs(users) do
37 | if user.spawns > 0 and not user:hasMission() then
38 | -- build mission
39 | local mdata = {}
40 | mdata.name = self.lang.paycheck.title()
41 |
42 | local step = {
43 | text = self.lang.paycheck.text({mission.reward}),
44 | onenter = function(user)
45 | user:giveWallet(mission.reward)
46 | vRP.EXT.Base.remote._notify(user.source,lang.money.received({mission.reward}))
47 | user:nextMissionStep()
48 | end,
49 | position = mission.position
50 | }
51 |
52 | mdata.steps = {step}
53 |
54 | user:startMission(mdata)
55 | end
56 | end
57 | end
58 |
59 | self.paychecks_elapsed[perm] = ticks
60 | end
61 |
62 | -- REPAIR
63 | for perm,mission in pairs(self.cfg.repair) do -- each repair perm def
64 | -- add missions to users
65 | local users = vRP.EXT.Group:getUsersByPermission(perm)
66 | for _, user in pairs(users) do
67 | if user.spawns > 0 and not user:hasMission() then -- check spawned without mission
68 | if math.random(1,mission.chance) == 1 then -- chance check
69 | -- build mission
70 | local mdata = {}
71 | mdata.name = self.lang.repair({mission.title})
72 | mdata.steps = {}
73 |
74 | -- build steps
75 | for i=1,mission.steps do
76 | local step = {
77 | text = self.lang.repair({mission.title}).."
"..self.lang.reward({mission.reward}),
78 | onenter = function(user)
79 | if user:tryTakeItem("repairkit",1) then
80 | vRP.EXT.Base.remote._playAnim(user.source,false,{task="WORLD_HUMAN_WELDING"},false)
81 | SetTimeout(15000, function()
82 | user:nextMissionStep()
83 | vRP.EXT.Base.remote._stopAnim(user.source,false)
84 |
85 | -- last step
86 | if i == mission.steps then
87 | user:giveWallet(mission.reward)
88 | vRP.EXT.Base.remote._notify(user.source, lang.money.received({mission.reward}))
89 | end
90 | end)
91 | end
92 | end,
93 | position = mission.positions[math.random(1,#mission.positions)]
94 | }
95 |
96 | table.insert(mdata.steps, step)
97 | end
98 |
99 | user:startMission(mdata)
100 | end
101 | end
102 | end
103 | end
104 |
105 | -- DELIVERY
106 | for perm,mission in pairs(self.cfg.delivery) do -- each repair perm def
107 | -- add missions to users
108 | local users = vRP.EXT.Group:getUsersByPermission(perm)
109 | for _,user in pairs(users) do
110 | if user.spawns > 0 and not user:hasMission() then
111 | -- build mission
112 | local mdata = {}
113 | mdata.name = self.lang.delivery.title()
114 |
115 | -- generate items
116 | local todo = 0
117 | local delivery_items = {}
118 | for fullid,data in pairs(mission.items) do
119 | local amount = math.random(data[1],data[2])
120 | if amount > 0 then
121 | delivery_items[fullid] = amount
122 | todo = todo+1
123 | end
124 | end
125 |
126 | local step = {
127 | text = "",
128 | onenter = function(user)
129 | for fullid,amount in pairs(delivery_items) do
130 | if amount > 0 then -- check if not done
131 | if user:tryTakeItem(fullid,amount) then
132 | local reward = mission.items[fullid][3]*amount
133 | user:giveWallet(reward)
134 | vRP.EXT.Base.remote._notify(user.source,lang.money.received({reward}))
135 | todo = todo-1
136 | delivery_items[fullid] = 0
137 | if todo == 0 then -- all received, finish mission
138 | user:nextMissionStep()
139 | end
140 | end
141 | end
142 | end
143 | end,
144 | position = mission.positions[math.random(1,#mission.positions)]
145 | }
146 |
147 | -- mission display
148 | for fullid,amount in pairs(delivery_items) do
149 | local citem = vRP.EXT.Inventory:computeItem(fullid)
150 | if citem then
151 | step.text = step.text..self.lang.delivery.item({citem.name,amount}).."
"
152 | end
153 | end
154 |
155 | mdata.steps = {step}
156 |
157 | if todo > 0 then
158 | user:startMission(mdata)
159 | end
160 | end
161 | end
162 | end
163 |
164 | end
165 |
166 | vRP:registerExtension(basic_mission)
167 |
--------------------------------------------------------------------------------