add_command currently only supports commands.
I'd like to have access to parameters.
eg. /slap someplayername
add_command name + Parameters
Re: add_command name + Parameters
It already supports parameters. You get the parameters in the event callback as "parameter".
Each command callback gets:
Each command callback gets:
- name
- tick
- player_index (optional)
- parameter (optional)
If you want to get ahold of me I'm almost always on Discord.
Re: add_command name + Parameters
thank you
example for who is looking:
example for who is looking:
Code: Select all
----------------------------------------
-- Custom commands
----------------------------------------
commands.add_command("slap", "Slap a player. (usage: /slap somePlayerName)", function(param)
local player = game.players[param.player_index]
if param.parameter then
local victim = game.players[param.parameter]
if victim then
if victim.connected then
startSlapping(victim, player, SLAP_DEFAULT_AMOUNT)
else
slSays(player, victim.name .. " is not online")
end
else
slSays(player, "Player not found: (" .. param.parameter .. ")")
end
else
slSays(player, "Player name needed. (usage: /slap somePlayerName)")
end
end)