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!