vRP Module Paychecks/Payroll/Salary

@gta I just 2 reinstalls and it fixed most likely it was not an error from you but a human one from me!

Hi,

Nice to see an extension for vRP, just some advices:

  • you should create a new resource and not encourage to modify the vRP core files, that will lead to a mess for everyone
  • allow any kind of paycheck (a map of permissions -> salary in a config file)
  • you can use the Lang system to allow people to translate the messages
2 Likes

ya the files are fine for me i have a feeling its a group/permissions thing , maybe outline in your first post an example of the group to add with fill in the blanks for customization of job names to help out the people struggling to figure all the details of the framework out. thanks :smiley:

Hi Imagic, I’m trying to create a new resource for the paycheck but I had some trouble.
I added the paycheck permission for every job and a paycheck config to know how many money we need to give to the user.
This code give me this error, I tryied to understand what give me the error and I noticed that the problem is the “getUserId” function, any advice?

local Proxy = require("resources/vrp/lib/Proxy")
local groupscfg = require("resources/vRP/cfg/groups")

vRP = Proxy.getInterface("vRP")
vRPclient = Proxy.getInterface("vRPclient")

RegisterServerEvent('paycheck:salary')
AddEventHandler('paycheck:salary', function()
  	local user_id = vRP.getUserId(source)
  	print('salary ' .. user_id)
	if vRP.hasPermission(user_id,"paycheck") then
		local usergroup = vRP.getUserGroupByType(userid, "job")
		if not(usergroup == "") then
			print('groupscfg ' .. groupscfg)
			local groups = groupscfg.groups[usergroup]
			print('groups ' .. groups)
			local paycheck = groupscfg.groups[usergroup]._config["paycheck"]
			print('salary ok ' .. paycheck)
			vRP.giveMoney(user_id,paycheck)
			vRPclient.notify(source,{"PAYDAY: ~g~$~b~"..paycheck})
		end
	end																						
end)

Here’s an example of a server side only paycheck task. The only downside would be this pays everyone at the exact same time regardless of when they logged in.

local Proxy = require("resources/vRP/lib/Proxy")

function task_paychecks()
	for k,v in pairs(vRP.users) do
		local source = vRP.getUserSource(v)
		local user_id = v
		print("Paycheck for users "..k.." "..v) -- Debug
		if vRP.hasPermission(user_id, "player.paycheck") then
			vRP.giveMoney(v,1200)
			vRPclient.notify(source,{"PAYDAY: ~g~$~b~"..1200})
		end
	end
	SetTimeout(300000, task_paychecks)
end
task_paychecks()

I dont even have a clue how to do the permission in groups.lua PLEASE HELP!!

I discourage you to add anything to the way config files works (for a new resource), it’s already complicated to check vRP config update to also look at extensions updates. Just make a new resource, create you own cfg directory in it, add a cfg/paycheck.lua with a map of permission -> salary, use vRP.getUsersByPermission in a loop, give them the salary, etc… If you can make a github for this extensions with @gta, I could do some pull request to just make an example on how to use the API, so people will have a small example of an extension using vRP.

4 Likes

@Imagic see my problem that I wrote one day ago, I wanted to put it as external addition to vrp but I got an error

You don’t use the proxy correctly, check the documentation. Tunnel and proxy are similar, the only difference is that proxy don’t need a source parameter.

It is great to see a huge interest in this module to vrp. If anyone have a time then as I mention in the first post feel free to edit this code in any way you like as right now it is last term of my uni and there is so much studying before summer time. Once I’ve gonna have a bit more time I will adjust new important changes to the module by myself.

got this working finally and yea it was a groups issue i sorted out , thanks for the much needed addition , now ive just to add all the actual jobs lol

Hey,
The older version was working great, the new update doesnt seem to work @gta

Put this in, used the instructions with @Healshot and with paycheck turned on getting an exception on startup. Turn it off and server starts fine.

Installed module, deleted HTTP cache, i do have other mods and custom code setup, will try a re-install with just vRP and go from there.

@gta

Edit - Same problem loaded in, just vRP + Paycheck, and the server is getting an exception still. Added the following to the group config:

"police.cloakroom",
"police.pc",
"police.handcuff",
"police.putinveh",
"police.getoutveh",
"police.check",
"police.service",
"police.wanted",
"police.seize.weapons",
"police.seize.items",
"police.jail",
"police.fine",
"police.announce",
"police.paycheck", --Added for Police Pay check
-- negative permission, police can't seize itself, even if another group add the permission
"-police.store_weapons",
"-police.seizable"

Edit - Found the error. Make sure your groups and everything match up

still works fine for me.

dont extract _resource of paycheck, keep original and paste only client paycheck and module paycheck archive…
2 - open you original vrp _resource and add manually in server script add the line

add this
“modules/paycheck.lua” ----- without " , " at last line of servescripts _resources

client script add

“client/paycheck.lua” ----- without " , " at last line of clientcripts _resources

--------done now go to the vrp/modules/paycheck.lua and replace with this to add sallary for emergency job too

local Proxy = require(“resources/vrp/lib/Proxy”)

RegisterServerEvent(‘paycheck:salary’)
AddEventHandler(‘paycheck:salary’, function()
local user_id = vRP.getUserId(source)
if vRP.hasPermission(user_id,“police.paycheck”) then
vRP.giveMoney(user_id,1200)
vRPclient.notify(source,{“PAYDAY: $1200”})
end
if vRP.hasPermission(user_id,“emergency.paycheck”) then
vRP.giveMoney(user_id,1200)
vRPclient.notify(source,{“PAYDAY: $1200”})
end
end)

------- now go to vrp/cfg/groups.lua and replace police colum

[“police”] = {
_config = {
gtype = “job”,
onjoin = function(player) vRPclient.setCop(player,{true}) end,
onspawn = function(player) vRPclient.setCop(player,{true}) end,
onleave = function(player) vRPclient.setCop(player,{false}) end
},
“police.cloakroom”,
“police.pc”,
“police.handcuff”,
“police.putinveh”,
“police.getoutveh”,
“police.check”,
“police.service”,
“police.wanted”,
“police.seize.weapons”,
“police.seize.items”,
“police.jail”,
“police.fine”,
“police.announce”,
“-police.store_weapons”,
“-police.seizable”, – negative permission, police can’t seize itself, even if another group add the permission
“police.paycheck” },

----- now replace emergency colum

[“emergency”] = {
_config = { gtype = “job” },
“emergency.revive”,
“emergency.shop”,
“emergency.service”,
“emergency.paycheck”
},

and finish save all and start your server

i has mod the resource police garage to spawn police car in police station and emergency garage in emergency station
download : https://www.sendspace.com/file/c1mjvz

3 - config the police and medic and cloackrooms

vrp/cfg/police.lua

replace

– PCs positions
cfg.pcs = {
{1853.21, 3689.51, 34.2671},
{442.030609130859, -978.72705078125, 30.6896057128906}

}

4 - replace

cfg.cloakrooms = {
{“police”, 1848.21, 3688.51, 34.2671},
{“police”, 444.743347167969, -975.502624511719, 30.6895961761475},
{“surgery”,1849.7425,3686.5759,34.2670},
– {“surgery”,358.404418945313,-588.177612304688,28.8007564544678}
}

---- in vrp/cfg/blips_markers.lua replace

cfg.blips = {
{-1202.96252441406,-1566.14086914063,4.61040639877319,311,17,“Body training”},
{460.190338134766,-993.888488769531,24.914867401123,60,17,“Police Station”},
{358.404418945313,-588.177612304688,28.8007564544678,61,17,“Hospital Station”}
}

2 Likes

Getting "error loading script modules/paycheck.lua in resource vrp: modules/paycheck.lua:1ua:1: attempt to call a nil value (global ‘require’)

Not quite sure what I’ve done wrong.

i really dont know on this one… everything seem to be in place (followed Psychorustle) and i get that also…


Error loading script modules/paycheck.lua in resource vrp: modules/paycheck.lua:1: attempt to call a nil value (global ‘require’)
stack traceback:
modules/paycheck.lua:1: in main chunk
Failed to load script modules/paycheck.lua.


nil value ?
local Proxy = require(“resources/vRP/lib/Proxy”)
if i take a look at Psycho’s… he start with


local Proxy = module(“vrp”, “lib/Proxy”)

require is no longer used in fx server go look at the documentation or find a proxy call example the vrp to see how it is done now…

I don’t understand what you mean. Is there an easy fix for this?

How do i put animation in, item transformers

Animation of a person doing bodybuilding

name=“Treinamento corporal”, – menu name
r=255,g=125,b=0, – color
max_units=1000,
units_per_minute=500,
x=-1202.96252441406,y=-1566.14086914063,z=4.61040639877319,
radius=7.5, height=1.5, – area
recipes = {
[“forca”] = { – action name
description=“Aumente sua forca.”, – action description
in_money=0, – money taken per unit
out_money=0, – money earned per unit
reagents={}, – items taken per unit
products={}, – items given per unit
aptitudes={ – optional
[“physical.strength”] = 1 – “group.aptitude”, give 1 exp per unit
}
}
}
},
{