I don't know what VBS looks like but it's very simple in general. You firstly need a tokenization function.
What are tokens?
Tokens are strings of anything separated by something. For example, the sentence "Hello World" has two tokens - "Hello" and "World", split by a single space (" "). The weapon command will go the same way. You will have an ID token and an ammo token.
Here's the tokenization function:
function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}
(Credits go to Force)
All that is left now is to make a weapon command.
else if( command == "wep" || command == "weapon" )
{
if( !text ) MessagePlayer( "Error - the syntax is /we(a)p(on) <ID> <Ammo>", player );
else
{
local
ID = GetTok( text, " ", 1 ), // The first token which comes after the command's name, separated by a space (" ")
ammo = GetTok( text, " ", 2 ); // The second token which comes after the ID, again separated by a space (" " )
if( IsNum( ID ) ) // Assuming you only want IDs to be used in your command, we will only accept digits
{
ID = ID.tointeger(); // Convert to an integer
ammo = ammo.tointeger(); // Convert to an integer
player.SetWeapon( ID, ammo ); // Success
local msg = format( "Successfully given a %s with %d ammo.", GetWeaponName( ID ), ammo ); // Pre-formatting messages is always nice.
MessagePlayer( msg, player );
}
else MessagePlayer( "The first parameter needs to be a digit.", player );
}
Have a nice day.