# Help - Value Chat Commands

**URL:** https://discussions.unity.com/t/help-value-chat-commands/591775
**Category:** Scripting
**Tags:** Scripting
**Created:** [July 31, 2015, 6:17pm UTC](https://discussions.unity.com/t/help-value-chat-commands/591775 "2015-07-31T18:17:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nevaran\_1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/nevaran_1/32/494812_2.png) [@nevaran\_1](https://discussions.unity.com/u/nevaran_1)
#### Post date: [July 31, 2015, 6:17pm UTC](https://discussions.unity.com/t/help-value-chat-commands/591775/1 "2015-07-31T18:17:06Z")

</div>

Does anyone have any idea how to make chat commands with values?

For example: /spawn box 5 – to spawns 5 boxes

All posts and videos i have seen have only /spawn box - or just /spawn, which is sadly not what i require 😕

---

<div class="post-metadata">

### Author: ![GroZZleR](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/grozzler/32/316385_2.png) [@GroZZleR](https://discussions.unity.com/u/GroZZleR)
#### Post date: [July 31, 2015, 6:33pm UTC](https://discussions.unity.com/t/help-value-chat-commands/591775/2 "2015-07-31T18:33:23Z")

</div>

Split the string by space into an array and treat each element as an argument.

```auto
String[] command = chatText.split(' ');

// [0] = /spawn, [1] = box, [2] = 5
if(command[0] == "/spawn")
{
    if(command.Length == 3)
    {
        if(command[1] == "box")
        {
            int boxCount = 1;
            int.TryParse(command[2], out boxCount);

            spawnBox(boxCount);
        }
    }
    else if(command.Length == 2)
    {
        if(command[1] == "box")
             spawnBox(1); // spawn 1 box as default if you don't specify a number
    }
    else
    {
        Debug.Log("Invalid arguments");
    }
}

```

---

<div class="post-metadata">

### Author: ![nevaran\_1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/nevaran_1/32/494812_2.png) [@nevaran\_1](https://discussions.unity.com/u/nevaran_1)
#### Post date: [August 1, 2015, 3:10pm UTC](https://discussions.unity.com/t/help-value-chat-commands/591775/3 "2015-08-01T15:10:03Z")

</div>

Thanks, ill try it out now!
