Not Allowing Mayor to have guns

So basically I don’t want the mayor to be able to pick up any guns. I want them to be helpless, so its easier to hold them hostage or something, and encourage body guards.

I know that if I turn on rp_license then the mayor can’t pick up the gun, but I don’t want people to have to ask the mayor for a license.

One more thing, this one guy says hes good at lua coding. He said this was impossible

It’s not impossible.


if TEAM_MAYOR = True then

....

something to that effect

Yes it is possible. Of course it is. Well, they can pick up guns, but just make it do pl:RemoveWeapon or something

[lua]
function MayorRemoveGun()
if ply:Team() == TEAM_MAYOR and HasWeapon then
ply:RemoveWeapon(TEAM_CITIZEN, true)
ply:ChatPrint(“You have lost your weapon”)
end
end
hook.Add(MayorDemote)
[/lua]

I, dont really know if that will work, It’s untested, and im a newb at lua so it PROBABLY won’t. But eh, at least I tried :stuck_out_tongue:

darkrp/entities/entities/spawned_weapon/init.lua:

[LUA]function ENT:Use(activator,caller)
if activator:Team() == TEAM_MAYOR then return end
local class = self.Entity.weaponclass
local weapon = ents.Create(class)

if not weapon:IsValid() then return false end

local CanPickup = hook.Call("PlayerCanPickupWeapon", GAMEMODE, activator, weapon)
if not CanPickup then weapon:Remove() return end

weapon:SetAngles(self.Entity:GetAngles())
weapon:SetPos(self.Entity:GetPos())
weapon.ShareGravgun = true
weapon.nodupe = true
weapon:Spawn()
self.Entity:Remove()

end[/LUA]

Well that allow them to have the defaults like physgun, gravgun, keys, pocket, camera, and tool gun?

10x faster to test it for yourself, then wait 6+ hours for a reply with the information you are looking for.

It would take about 3 (give or take about 1) minutes to see if it worked. So the result (Based on the 6 hours you’ve given) will end up being 90 - 180 times faster.

[lua]
hook.Add(“PlayerCanPickupWeapon”, “MayorCantPickup”, function(ply, wep)
if (ply:Team() == TEAM_MAYOR) then return false end
end)
[/lua]
This will stop the mayor picking up weapons.

Didn’t work, I could still pick up guns. Does it help if I say the server uses mad cow weps

Edit: I’ll test yours sintwins

Sintwins when I become mayor, I dont have any weapons, not even the default ones like physgun and all that