Ulysses Stuff > Suggestions
Want a small addon.
Aaron113:
--- Code: ---local CATEGORY_NAME = "Fun"
local Sweps = { "manhack_welder", "weapon_ak47", "weapon_deagle", "weapon_fiveseven", "weapon_glock", "weapon_m4", "weapon_mac10","weapon_tmp","weapon_pumpshotgun","weapon_para","weapon_mp5","harpooncannon","flechette_gun","weapon_crowbar","weapon_stunstick","weapon_physcannon","weapon_physgun","weapon_pistol","weapon_357","weapon_smg1","weapon_ar2","weapon_shotgun","weapon_crossbow", "weapon_frag", "weapon_rpg", "weapon_slam", "weapon_bugbait", "item_ml_grenade", "item_ar2_grenade", "item_ammo_ar2_altfire", "gmod_camera", "gmod_tool"
}
function ulx.giveswep( ply, targs, wep )
for k,v in pairs(targs) do
v:Give( wep )
end
ulx.fancyLogAdmin( ply, "#A gave #T a(n) #s", targs, wep )
end
local giveswep = ulx.command( CATEGORY_NAME, "ulx give", ulx.giveswep, "!give" )
giveswep:addParam{ type=ULib.cmds.PlayersArg, hint="player" }
giveswep:addParam{ type=ULib.cmds.StringArg, hint="weapon", completes=Sweps }
giveswep:defaultAccess( ULib.ACCESS_ADMIN )
giveswep:help( "Give a player a weapon" )
local SwepAmmo = { "ar2", "alyxgun", "pistol", "smg1", "357", "xbowbolt", "buckshot", "rpg_round", "smg1_grenade", "sniperround", "sniperpenetratedround", "grenade", "thumper", "gravity", "battery", "gaussenergy", "combinecannon", "airboatgun", "striderminigun", "helicoptergun", "ar2altfire", "slam" }
function ulx.giveammo( ply, targs, wep, amount )
for k,v in pairs(targs) do
v:GiveAmmo( amount, wep )
end
ulx.fancyLogAdmin( ply, "#A gave #T #s ammo", targs, wep )
end
local giveammo = ulx.command( CATEGORY_NAME, "ulx giveammo", ulx.giveammo, "!giveammo" )
giveammo:addParam{ type=ULib.cmds.PlayersArg, hint="<user(s)>" }
giveammo:addParam{ type=ULib.cmds.StringArg, completes=SwepAmmo, hint="<ammo type>" }
giveammo:addParam{ type = ULib.cmds.NumArg, hint="<amount of ammo>", min=1, max=900, default=100 }
giveammo:defaultAccess( ULib.ACCESS_ADMIN )
giveammo:help( "Give a player ammo for a weapon" )
--- End code ---
Well, here it is. Sorry it's late, been a tad busy.
--- Quote from: HeLLFox_15 on August 01, 2011, 08:13:48 PM ---I can make an editable list of guns but I am not good with live editing, So you would have to go into a file change the list and restart the server, but if Aaron where to help me I can try to make one that excepts live editing, and I will start on making that right away.
--- End quote ---
I'm actually doing something like this in URS. I could pop it into this once I finish.
LuaTenshi:
looks like Aaron beat me to it, well I remain with 0 karma. :P :'(
Aaron113:
I actually made this months ago.
LuaTenshi:
--- Quote from: Aaron113 on August 02, 2011, 11:20:07 AM ---I actually made this months ago.
--- End quote ---
Mine is probably bugged or some thing, because my idea was to make a loop within a loop one would be for giving the weapon and one for specifying what weapon to give.
Here it is any way may be you can fix it up or some thing... (Also if URS blocks weapons completely like blocks them from being given to people who don't have the permission to use them it can be a simple command to give them every weapon with certain amounts of ammo.)
--- Code: ----- ULX Carm for ULX SVN/ULib SVN by HeLLFox_15
function ulx.ccarm( calling_ply, target_plys, command )
WeaponList = {
"weapon_crowbar",
"weapon_stunstick",
"weapon_pistol",
"weapon_smg1",
"weapon_ar2",
"weapon_shotgun",
"weapon_crossbow",
"weapon_frag",
"weapon_rpg",
"weapon_slam",
"weapon_bugbait",
"item_ml_grenade",
"item_ar2_grenade",
"item_ammo_ar2_altfire"
}
for _, k in ipairs( WeaponList ) do
local ListWeap = WeaponList[k]
end
for _, v in ipairs( target_plys ) do
v:Give(ListWeap)
end
ulx.fancyLogAdmin( calling_ply, "#A carmed #T", target_plys )
end
local carm = ulx.command( "Utility", "ulx carm", ulx.carm, "!carm" )
carm:addParam{ type=ULib.cmds.PlayersArg }
carm:defaultAccess( ULib.ACCESS_SUPERADMIN )
carm:help( "carm a target(s)." )
--- End code ---
Some thing tells me that that's wrong, but I am new to coding Lua.
Aaron113:
Several problems.
* Your function in this line is wrong.
--- Quote ---function ulx.ccarm( calling_ply, target_plys, command )
-------------------------------------------------------------------------------------
local carm = ulx.command( "Utility", "ulx carm", ulx.carm, "!carm" )
--- End quote ---
* Your weapon list should not be in the function. There's no need to set it each time you run the function.
* I'm not even sure what you're trying to do here...
--- Quote --- for _, k in ipairs( WeaponList ) do
local ListWeap = WeaponList[k]
end
--- End quote ---
But the bold will become a nil value once you get down to here...
--- Quote --- for _, v in ipairs( target_plys ) do
v:Give(ListWeap)
end
--- End quote ---
It'll become a nil value because you ended the first loop, but there is no need for it if you combine them. You can just do this instead...
--- Quote ---v:Give( k )
--- End quote ---
*
--- Quote ---function ulx.ccarm( calling_ply, target_plys, command )
--- End quote ---
Is there really a extra argument that tells the command? I never knew ULX/ULib did this if so.
Finished product should look like this...
--- Code: ----- ULX Carm for ULX SVN/ULib SVN by HeLLFox_15
local WeaponList = {
"weapon_crowbar",
"weapon_stunstick",
"weapon_pistol",
"weapon_smg1",
"weapon_ar2",
"weapon_shotgun",
"weapon_crossbow",
"weapon_frag",
"weapon_rpg",
"weapon_slam",
"weapon_bugbait",
"item_ml_grenade",
"item_ar2_grenade",
"item_ammo_ar2_altfire"
}
function ulx.carm( calling_ply, target_plys, command )
for _, k in ipairs( WeaponList ) do
for _, v in ipairs( target_plys ) do
v:Give(k)
end
end
ulx.fancyLogAdmin( calling_ply, "#A carmed #T", target_plys )
end
local carm = ulx.command( "Utility", "ulx carm", ulx.carm, "!carm" )
carm:addParam{ type=ULib.cmds.PlayersArg }
carm:defaultAccess( ULib.ACCESS_SUPERADMIN )
carm:help( "carm a target(s)." )
--- End code ---
Sorry for going to town on you. :P
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version