Forum

> > CS2D > Scripts > Only numeric type (lua)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Only numeric type (lua)

4 replies
To the start Previous 1 Next To the start

moved Only numeric type (lua)

limonata
User Off Offline

Quote
Hello , how I can do this in lua?

I have a lua like this.
-------
me: !res
limonata restarted the round
me !res 2
limonata restarted for 2 second
me !res asd
limonata restarted for asd second --> Here. I dont want this I want to enter just numeric type. when I write:

!res addas --> there should be msg like

Error: You must enter a number.

Thanks.

Admin/mod comment

Please post in the right subforum next time! Moved! /DC

old Re: Only numeric type (lua)

Avo
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
addhook("say","OnSay")
function OnSay(id,txt)
	if txt:sub(1,4)=="!res" then
		local t=tonumber(txt:sub(5,#txt))
		if t~=nil then 
			parse("restart "..t) msg("Restarting round in "..t.." seconds (by"..player(id,"name")..")") 
		else 
			msg2(id,"[Error]: you must enter a number.") 
		end
		return 1
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview