DarkRP Custom Mayor Entity Problem

I’m having a complete mental collapse and just generally cannot think of an answer to this. I’m trying to have a buyable F4 menu entity for the mayor only, but instead of paying for it via his own wallet, I have an economy system and I want it to buy it via the city wallet.

[lua]local function MayorCustomCheck(key)
return function(ply)
if CLIENT then return true end --Client can always see item in F4 menu

	local entTable = DarkRPEntities[key]
	
	if entTable and DarkRPEconomy.GetController():GetCityWallet() >= entTable.price then
		return true
	end
	
	else
		return false
end

end

AddEntity(“Armor Dispenser”, {
ent = “dispenser_armor”,
model = “models/props_combine/suit_charger001.mdl”,
price = 7000,
max = 1,
cmd = “buyarmordispenser”,
allowed = TEAM_MAYOR,
customCheck = MayorCustomCheck(2),
CustomCheckFailMsg = “The city does not have enough money for this item”,
ownEntity = true,
mayorEntity = true,
ignorePrice = true,
})

AddEntity(“Health Dispenser”, {
ent = “dispenser_health”,
model = “models/props_combine/health_charger001.mdl”,
price = 7000,
max = 1,
cmd = “buyhealthdispenser”,
allowed = TEAM_MAYOR,
customCheck = MayorCustomCheck(3),
CustomCheckFailMsg = “The city does not have enough money for this item”,
ownEntity = true,
mayorEntity = true,
ignorePrice = true,
})

AddEntity(“Rifle Ammo Box”, {
ent = “dispenser_ammo_rifle”,
model = “models/Items/ammocrate_smg1.mdl”,
price = 8000,
max = 1,
cmd = “buyrifleammobox”,
allowed = TEAM_MAYOR,
customCheck = MayorCustomCheck(4),
CustomCheckFailMsg = “The city does not have enough money for this item”,
ownEntity = true,
mayorEntity = true,
ignorePrice = true,
})

AddEntity(“Pistol Ammo Box”, {
ent = “dispenser_ammo_pistol”,
model = “models/Items/ammocrate_ar2.mdl”,
price = 6000,
max = 1,
cmd = “buypistolammobox”,
allowed = TEAM_MAYOR,
customCheck = MayorCustomCheck(5),
CustomCheckFailMsg = “The city does not have enough money for this item”,
ownEntity = true,
mayorEntity = true,
ignorePrice = true,
})

AddEntity(“Soda Machine”, {
ent = “dispenser_soda”,
model = “models/props_interiors/VendingMachineSoda01a.mdl”,
price = 5000,
max = 3,
cmd = “buysodamachine”,
allowed = TEAM_MAYOR,
customCheck = MayorCustomCheck(6),
CustomCheckFailMsg = “The city does not have enough money for this item”,
ownEntity = true,
mayorEntity = true,
ignorePrice = true,
})[/lua]

Not really sure if this is the correct way to do it or not. Currently it is still making the mayor pay for it out of his own pocket. Any help is appreciated because I am trying to learn how to get better as a coder. Thanks!

  1. The ply argument isn’t provided in your function you put there.
  2. The price will still pull from the mayor’s pocket instead of the city’s.
  1. You are calling the function in the CustomCheck, instead of setting it as a member.

What do you mean by number 2? How do you suggest I change that? I know what the problems are mostly, I just don’t know what I need to change exactly.

You would have to change the price function (not familiar with where that is – don’t code for DarkRP) to do a job check and pull from the city’s wallet when it’s a mayor buying.

So I don’t need to any of that custom check stuff in the entity then?

No. You just need to reroute where the payment function goes to for mayor.

Could anyone tell me where the price function is?