Multiple Arguements.

May someone please explain how I can go about this?

For instance, if referring to DarkRP and I wanted to buy a shipment with a custom amount of weapons. How would I allow for multiple arguments to be used?

Thank you in advance.

are you talking about something like this?
[lua]
function test(Player,Command,args)
print(args[1])
print(args[2])
end
concommand.Add(“test”,test)
[/lua]

I think you may be talking about variadic arguments. Variadic arguments allow you to pass any number of arguments to a function. For example:
[lua]local function GiveWeapons(ply, …) – … is the syntax to allow any number of arguments to be passed into a function.
local arg = {…} – put all the arguments inside the table arg.
for _, c in ipairs(arg) do
ply:Give©
end
end[/lua]

With this, we can now pass as many weapon classes as we want to give to a player.

[lua]GiveWeapons(ply, “weapon_rpg”, “weapon_shotgun”, “weapon_mp5”)[/lua]

Thank you very much KF and Maker,
I think what I wanted is as you said Maker, “Variadic Arguments”.
Will give this a go tonight.

Fixed for correct words and optimization.

Instead of creating the table only once, you create it multiple times. How does that optimize anything?

Fixed.

If you don’t understand how for i saves tremendously over every other way of iterating a table in lua then you missed the posts about optimizations in Lua.

What do you mean “correct words”?

[editline]10:25AM[/editline]

You obviously don’t know what you are talking about, your way is over four times as slow as mine. Don’t post unless you know what you are talking about please.

http://img203.imageshack.us/img203/6720/lolyourwrong.png

Sorry about the large image.

You clearly know nothing about Lua.

Even doing this:
[lua]local function b(…)
local arg = {…}
local c = #arg
for i=1, c do
local d = arg*+1
end
end[/lua]

Gives very little optimisation, unless you are doing it thousands of times (in a loop).