Jump to content

Weapons for Groups only


Xabache

Recommended Posts

From Freeroam:

--------------------------- 
-- Weapon window 
--------------------------- 
  
function addWeapon(leaf, amount) 
    if type(leaf) ~= 'table' then 
        leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist') 
        amount = getControlNumber(wndWeapon, 'amount') 
        if not amount or not leaf then 
            return 
        end 
    end 
    server.giveMeWeapon(leaf.id, amount) 
end 
  
wndWeapon = { 
    'wnd', 
    text = 'Give weapon', 
    width = 250, 
    controls = { 
        { 
            'lst', 
            id='weaplist', 
            width=230, 
            height=280, 
            columns={ 
                {text='Weapon', attr='name'} 
            }, 
            rows={xml='weapons.xml', attrs={'id', 'name'}}, 
            onitemdoubleclick=function(leaf) addWeapon(leaf, 500) end 
        }, 
        {'br'}, 
        {'txt', id='amount', text='500', width=60}, 
        {'btn', id='add', onclick=addWeapon}, 
        {'btn', id='close', closeswindow=true} 
    } 
} 
  
function giveWeaponCommand(cmd, weapon, amount) 
    weapon = tonumber(weapon) or getWeaponIDFromName(weapon) 
    if not weapon then 
        return 
    end 
    amount = amount and tonumber(amount) or 500 
    server.giveMeWeapon(math.floor(weapon), amount) 
end 
addCommandHandler('give', giveWeaponCommand) 
addCommandHandler('wp', giveWeaponCommand) 

I've divided my weapons .xml into categories

<catalog type="weapon"> 
    <group name="Hand"> 
        <weapon id="1" name="Brass knuckles" /> 
        <weapon id="5" name="Baseball bat" /> 
        <weapon id="15" name="Cane" /> 
        <weapon id="9" name="Chainsaw" /> 
        <weapon id="2" name="Golf club" /> 
        <weapon id="7" name="Pool cue" /> 
        <weapon id="8" name="Katana" /> 
        <weapon id="4" name="Knife" /> 
        <weapon id="3" name="Nightstick" /> 
        <weapon id="6" name="Shovel" /> 
    </group> 
    <group name="Special"> 
        <weapon id="14" name="Flowers" /> 
        <weapon id="43" name="Camera" /> 
        <weapon id="42" name="Fire extinguisher" /> 
        <weapon id="45" name="Infrared goggles" /> 
        <weapon id="44" name="Night vision goggles" /> 
        <weapon id="46" name="Parachute" /> 
    </group> 
    <group name="Everyone"> 
        <weapon id="24" name="Desert eagle" /> 
        <weapon id="22" name="Pistol" /> 
        <weapon id="23" name="Silenced" /> 
        <weapon id="32" name="TEC-9" /> 
        <weapon id="17" name="Tear gas" /> 
    </group> 
    <group name="Members"> 
        <weapon id="26" name="Sawn-off shotgun" /> 
        <weapon id="25" name="Shotgun" /> 
        <weapon id="28" name="Uzi" /> 
        <weapon id="30" name="AK47" /> 
        <weapon id="33" name="Country sniper" /> 
        <weapon id="37" name="Flame thrower" /> 
        <weapon id="18" name="Molotov" /> 
    </group> 
    <group name="Supporters"> 
        <weapon id="27" name="SPAZ-12" /> 
        <weapon id="29" name="MP5" /> 
        <weapon id="31" name="M4" /> 
        <weapon id="34" name="Sniper" /> 
        <weapon id="16" name="Grenade" /> 
    </group> 
    <group name="Moderators"> 
        <weapon id="35" name="Rocket launcher" /> 
        <weapon id="36" name="Heat seeking RPG" /> 
        <weapon id="38" name="Minigun" /> 
        <weapon id="39" name="Satchel" /> 
        <weapon id="40" name="Satchel detonator" /> 
    </group> 
</catalog> 

And the server:

function giveMeWeapon(weapon, amount) 
    if weapon and weapon > 50 then 
        return 
    end 
    if table.find(getOption('weapons.disallowed'), weapon) then 
        errMsg((getWeaponNameFromID(weapon) or tostring(weapon)) .. 's are not allowed', source) 
    else 
        giveWeapon(source, weapon, amount, true) 
    end 
end 

...which delivers all weapons to everyone despite my notations that some weapons only go to some groups.

I added an acl list for Members but do not know what function to allow. The weapons groups Hand, Special and Everyone are for all. How do I limit the last three groups to the preferred player's groups: Members, Supporters and Moderators?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...