Reputation: 4520
I am trying to make several chatcommands in my new server modification for Crysis Wars that requires numbers and strings. To get the player input, I do this:
local name, time, reason = string.match(chatMsg, "^!punish (.*) (%d+) (.*)");
For some reason, it's not working properly (gets the number value as a string). The number value is the second variable in the string.match. Am I doing something wrong here? I've also tried to find a solution to this, but have not found any. Perhaps I should be using a different method to get the number?
Upvotes: 3
Views: 2265
Reputation: 10502
It's actually quite simple, just add the following line after the line you posted in your question.
time = tonumber(time);
As mentioned in the comments below, you can achieve the same with
time = time + 0
Upvotes: 7