Forum

> > CS2D > Scripts > About say hook
Forums overviewCS2D overview Scripts overviewLog in to reply

English About say hook

2 replies
To the start Previous 1 Next To the start

old About say hook

Devil-Thanh
GAME BANNED Off Offline

Quote
i know that when we say a text like "123", it can be changed to number by tonumber(text) but i don't know if we can set a number to 0 if it cant be changed to number.

1
2
3
4
5
6
7
8
9
addhook("say","say")
function say(id,txt)
local number
--if its cant be changed to number such as "123a" or "asd154"
	number = 0
else
	number = tonumber(txt)
end
end

old Re: About say hook

MikuAuahDark
User Off Offline

Quote
this is the code to complete your script
1
if tonumber(txt)==nil then	-- It's cannot changed to number

Re-written code:
1
2
3
4
addhook("say","say")
function say(id,txt)
	local number=tonumber(txt) or 0	-- It gonna try to convert "txt" to number, and if it's not possible, it sets the value to 0
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview