[Talkaction] Dúvida Sobre Números Aleatórios.

masquente
em Scripts

masquente

ph
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 26/02/10Posts: 218

Olá galera do XTibia,

Não sei se postei no lugar errado, mas nesses dias me vi com a necessidade de criar uma talkaction que quando seria ativada, falasse numeros aleatórios de 1 a 250.

Porém, eu não tenho ideia de como fazer isso.

 

Obrigado desde já!

Banido por falta de respeito.

bloder

Lucas
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 22/04/10Posts: 30

voce queria que manda-se toda hora? ou uma vez só?

se for uma vez só

Tenta assim:

cria um arquivo lua em talkactions e cole isto dentro:

  function onSay(cid, words, param, channel)
   local rand = math.random(1,250)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"The random number is " .. rand .. "." )
return true
end

dps em talkactions.xml coloke isto

	<talkaction words="!number" hide="yes" event="script" value="number.lua"/>

e a seção está errada.o correto seria em pedidos de script.

23768_7.png

Ajudei ? Então clika ali no add.png E da um Rep+ pra mim!

masquente

ph
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 26/02/10Posts: 218

eu queria que mandasse toda hora... tem como? :/

Banido por falta de respeito.

bepokemon

Lo sono il accolito.
avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 23/02/08Posts: 273Char no Tibia: Foxx Rookslayer

Primeiro, crie um script chamado start.lua ou como preferir e coloque isso dentro:

 

function onSay(cid, words, param, channel)

function randSay(cid, words)
if isPlayer(cid) then
if getPlayerStorageValue(cid, "send") ~= -1 then
local rand = math.random(1,250)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"The random number is " .. rand .. "." )
addEvent(randSay,1000)
end
end
end

doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"You are now saying random numbers.")
setPlayerStorageValue(cid, "send", 1)
addEvent(randSay,1000)
return true
end

 

 

Depois cria um chamado stop.lua, ou outro que preferir e coloque isso dentro:

 

function onSay(cid, words)
if getPlayerStorageValue(cid, "send") ~= -1 then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"You stopped saying random numbers.")
setPlayerStorageValue(cid, "send", -1)
else
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"You are not saying random numbers." )
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
return TRUE
end

 

 

Depois so colocar as tags no talkactions.xml

<talkaction words="!number" hide="yes" event="script" value="start.lua"/>

<talkaction words="!stop" hide="yes" event="script" value="stop.lua"/>

 

Creditos: @LucasHere pela parte que eu fiquei com priguiça de fazer .. =D'

logo.png

Scripter

@MagicWorld

Ex: Colaborador de Scripting

Contato: bepokemon@hotmail.com

bloder

Lucas
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 22/04/10Posts: 30

Voce tbm pode usar esta modificação do script !AFK:

--[[ 
   Talking Tp/signs/tiles for TFS 0.2+
   70%shawak,30%Damadgerz
   Idea by Damadgerz
]]--
   local time = 5    -- 1 = 1 sec, 2 = 2 sec, ...

    local say_events = {}
local function SayText(cid)
   if isPlayer(cid) == TRUE then
        if say_events[getPlayerGUID(cid)] ~= nil then
            if isPlayer(cid) == TRUE then
local rand = math.random(1,250)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"The random number is " .. rand .. "." )
            end
            say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000 / 2, cid)       
        end                                                       
   end
   return TRUE
end
function onSay(cid, words, param, channel) 
   if(param == '') then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
    return true
    end
    if param == "on" then
       if isPlayer(cid) == TRUE then
           doSendAnimatedText(getPlayerPosition(cid),"Started!", math.random(01,255))
       end
       say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000, cid)
       doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"You are now saying random numbers.")
    elseif param == "off" then
           stopEvent(say_events[getPlayerGUID(cid)])
           say_events[getPlayerGUID(cid)] = nil
           doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"You stopped saying random numbers.")
   end
   return TRUE
end

<talkaction words="!number" hide="yes" event="script" value="script.lua"/>

para ativar é só vc falar !number on e para desativar !number off

23768_7.png

Ajudei ? Então clika ali no add.png E da um Rep+ pra mim!

masquente

ph
avatar
Barão
Barão

INFOS

Grupo: BarãoRegistrado: 26/02/10Posts: 218

Voce tbm pode usar esta modificação do script !AFK:

--[[ 
   Talking Tp/signs/tiles for TFS 0.2+
   70%shawak,30%Damadgerz
   Idea by Damadgerz
]]--
   local time = 5    -- 1 = 1 sec, 2 = 2 sec, ...

    local say_events = {}
local function SayText(cid)
   if isPlayer(cid) == TRUE then
        if say_events[getPlayerGUID(cid)] ~= nil then
            if isPlayer(cid) == TRUE then
local rand = math.random(1,250)
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"The random number is " .. rand .. "." )
            end
            say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000 / 2, cid)       
        end                                                       
   end
   return TRUE
end
function onSay(cid, words, param, channel) 
   if(param == '') then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
    return true
    end
    if param == "on" then
       if isPlayer(cid) == TRUE then
           doSendAnimatedText(getPlayerPosition(cid),"Started!", math.random(01,255))
       end
       say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000, cid)
       doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"You are now saying random numbers.")
    elseif param == "off" then
           stopEvent(say_events[getPlayerGUID(cid)])
           say_events[getPlayerGUID(cid)] = nil
           doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,"You stopped saying random numbers.")
   end
   return TRUE
end

<talkaction words="!number" hide="yes" event="script" value="script.lua"/>

para ativar é só vc falar !number on e para desativar !number off

 

OBRIGADO!

Amanhã darei rep+ pro Byerne também, que ajudou.

Valeu!

Banido por falta de respeito.

Demonbholder

avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 13/10/08Posts: 1551Char no Tibia: Demonbholder

Galera, quando o tópico estiver em seção incorreta reportem!

Oie :D