ULX

Author Topic: Want a small addon.  (Read 5165 times)

0 Members and 1 Guest are viewing this topic.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Want a small addon.
« on: July 28, 2011, 01:11:00 AM »
Could someone make me a ulx command which gives the player a weapon_twitch_m249 with 1000 ammo when they type !gun.
I want it to be so that it IS a ulx addon like slay (you can allow and deny it from people and groups)
also, it needs to be for the svn version.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Want a small addon.
« Reply #1 on: July 28, 2011, 07:10:45 AM »
Could someone make me a ulx command which gives the player a weapon_twitch_m249 with 1000 ammo when they type !gun.
I want it to be so that it IS a ulx addon like slay (you can allow and deny it from people and groups)
also, it needs to be for the svn version.

Assuming that weapon_twitch_m249 is a weapon that is installed on your server... I can make you that LUA if you would like.

Let me also add a suggestion instead of giving them the one weapon why not have a random weapon selected for them?

Also I assume that you want a time delay between the time they use the command so they cant just keep giving them 1000 ammo...
I cry every time I see that I am not a respected member of this community.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Want a small addon.
« Reply #2 on: July 28, 2011, 01:14:56 PM »
I already have one that I whipped up a while ago.  (ulx give & ulx giveammo)  It's simple and straight to the point.  If you want I could post that as well.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Re: Want a small addon.
« Reply #3 on: July 28, 2011, 03:04:34 PM »
its for certian ranked people.
Aaron, could you post that as well because i have wanted that type of a command.
Hellfox, that would be appreciated, and I could like that, but can you make it so there is a editable list of guns?
Thanks in advance,
blackfire

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Want a small addon.
« Reply #4 on: August 01, 2011, 08:13:48 PM »
its for certian ranked people.
Aaron, could you post that as well because i have wanted that type of a command.
Hellfox, that would be appreciated, and I could like that, but can you make it so there is a editable list of guns?
Thanks in advance,
blackfire

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.
I cry every time I see that I am not a respected member of this community.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Want a small addon.
« Reply #5 on: August 02, 2011, 09:40:31 AM »
Code: [Select]
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" )
Well, here it is.  Sorry it's late, been a tad busy.

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.
I'm actually doing something like this in URS.  I could pop it into this once I finish.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Want a small addon.
« Reply #6 on: August 02, 2011, 11:14:07 AM »
looks like Aaron beat me to it, well I remain with 0 karma. :P  :'(
I cry every time I see that I am not a respected member of this community.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Want a small addon.
« Reply #7 on: August 02, 2011, 11:20:07 AM »
I actually made this months ago.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Want a small addon.
« Reply #8 on: August 02, 2011, 11:39:50 AM »
I actually made this months ago.

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: [Select]
-- 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)." )

Some thing tells me that that's wrong, but I am new to coding Lua.
I cry every time I see that I am not a respected member of this community.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Want a small addon.
« Reply #9 on: August 02, 2011, 12:43:36 PM »
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" )

  • 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
    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
    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 )

  • Quote
    function ulx.ccarm( calling_ply, target_plys, command )
    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: [Select]
-- 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)." )


Sorry for going to town on you.  :P

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Want a small addon.
« Reply #10 on: August 02, 2011, 01:26:02 PM »
Several problems.

  • Your function in this line is wrong.
  • 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...But the bold will become a nil value once you get down to here...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...
  • 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: [Select]
-- 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)." )


Sorry for going to town on you.  :P

Its OK, reading this actually made me laugh at my self and made my day. I miss-typed on the "ccarm" part and I don't know what possessed me to put the "command" part in there.

Ps: I would like you to help me with my game-mode, because the idea I have is simply complicated here it is here...
http://forums.ulyssesmod.net/index.php/topic,5361.0.html
I cry every time I see that I am not a respected member of this community.