tenta assim:
if msgcontains(msg, "apostar") then
selfSay("Você deseja apostar que numero no jogo 21?", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if getNumber(msg) <= 21 then
n = getNumber(msg)
if n ~= 0 then
selfSay('Você quer apostar {'..n..'} no jogo 21? {yes}?', cid)
talkState[talkUser] = 2
else
selfSay('Escolha um numero maior que 0.', cid)
talkState[talkUser] = 0
end
else
selfSay('Você não pode apostar esté numero.', cid)
talkState[talkUser] = 0
end
end
function getNumber(txt)
x = string.gsub(txt,"%a","")
x = tonumber(x)
if x ~= nill and x > 0 then
return x
else
return 0
end
end


info
Grupo: Campones
Registrado: 05/01/12
Posts: 12
Reputação: 0
Bom pessoal...
Preciso verificar se o msg de um player e do tipo number...
Mas sempre que eu tento da erro...
Como eu posso usar a função type dentro do callback function creatureSayCallback(cid, type, msg)?
Tentei deste jeito:
local valor = string.match(msg, "%d+") if type(valor) == "number" then selfSay('Você quer apostar '.. valor ..' no jogo 21?',cid) else selfSay('Por favor, digite o valor de sua aposta?',cid) endAlguem sabe como corrigir?
Vlw...