AD
action

Talkaction por vocação

Por Adriez, 18 de mar. de 2016 em Scripts

17
2.4k
AdriezA
18 de março de 2016 às 01:13

fala galera bom dia, gostaria de saber se tem como eu bloquear um comando de talkaction por vocação ??

FurabioF
19 de março de 2016 às 09:06

sim basta fazer a verificação no começo do script.

if getPlayerVocation(cid) == ID_VOCATION then
    mensagem de erro;
    return false
end

Tópico Movido
Este tópico foi movido de "OTServScriptingDownloads ScriptsActions, talkactions e moveevents"
para "OTServScriptingSuporte Scripting".

 

 

AdriezA
25 de março de 2016 às 15:08

esse seria o script, gostaria q todas essas vocação só elas pudessem usar o talktaction a 9,10,11 e 12, obrigado

 

function onSay(cid, words, param, channel)
if getPlayerVocation(cid) == ID_VOCATION then
mensagem de erro;
return false
end
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return true
end
local t = string.explode(param, ",")
t[1] = tonumber(t[1])
if(not t[1]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
return true
end
local failout = {"73","75","302","266","45","10"} -- outfits proibidas
for i = 1, #failout do
if string.find(tostring(param), failout) then
doPlayerSendCancel(cid,"Não pode usar estas outfit.")
return TRUE
end
end
if(t[1] <= 1 or t[1] == 135 or (t[1] > 160 and t[1] < 192) or t[1] > 351) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")
return true
end
local tmp = getCreatureOutfit(cid)
tmp.lookType = t[1]
doCreatureChangeOutfit(cid, tmp)
return true
end
DanihcvD
25 de março de 2016 às 15:32

Tenta ae:

local vocs = {9, 10, 11, 12} --vocacoes que podem usar a talkaction

function onSay(cid, words, param, channel)

if isInArray(vocs, getPlayerVocation(cid)) then
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
        end
 
        local t = string.explode(param, ",")
        t[1] = tonumber(t[1])
        if(not t[1]) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
                return true
        end
 
 
 
local failout = {"73","75","302","266","45","10"} -- outfits proibidas
       for i = 1, #failout do
       if string.find(tostring(param), failout[i]) then
        doPlayerSendCancel(cid,"Não pode usar estas outfit.")
        return TRUE
end 
end   
 
        if(t[1] <= 1 or t[1] == 135 or (t[1] > 160 and t[1] < 192) or t[1] > 351) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")
                return true
        end
 
        local tmp = getCreatureOutfit(cid)
        tmp.lookType = t[1]
 
        doCreatureChangeOutfit(cid, tmp)]
else
doPlayerSendCancel(cid,"Sua vocação não pode usar este comando.")
end
        return true
end
FurabioF
25 de março de 2016 às 18:10

^^ dani nesses casos é bom seguir a estrutura do script , que no caso é verificar se é a condição é falsa e cancelar a ação:

    if not isInArray(vocs, getPlayerVocation(cid)) then
        doPlayerSendCancel(cid,"Sua vocação não pode usar este comando.")
    end
DanihcvD
25 de março de 2016 às 19:09

 

^^ dani nesses casos é bom seguir a estrutura do script , que no caso é verificar se é a condição é falsa e cancelar a ação:

    if not isInArray(vocs, getPlayerVocation(cid)) then
        doPlayerSendCancel(cid,"Sua vocação não pode usar este comando.")
    end

 

Mas ainda seria necessário acrescentar o return false, ne isso?

FurabioF
25 de março de 2016 às 19:13

 

Mas ainda seria necessário acrescentar o return false, ne isso?

Não, pois o doPlayerSendCancel ja retorna false.

AdriezA
26 de março de 2016 às 12:11

eu dou o comando acontece nada, nem erro no console nem nada como se o script não existisse

DanihcvD
26 de março de 2016 às 16:13

Mande o script original. Sem nenhuma edição (de uma forma que ele esteja funcionando)

AdriezA
27 de março de 2016 às 23:33

esse seria o script, gostaria q todas essas vocação só elas pudessem usar o talktaction a 9,10,11 e 12, obrigado



function onSay(cid, words, param, channel)

if getPlayerVocation(cid) == ID_VOCATION then

mensagem de erro;

return false

end

if(param == '') then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")

return true

end


local t = string.explode(param, ",")

t[1] = tonumber(t[1])

if(not t[1]) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")

return true

end




local failout = {"73","75","302","266","45","10"} -- outfits proibidas

for i = 1, #failout do

if string.find(tostring(param), failout) then

doPlayerSendCancel(cid,"Não pode usar estas outfit.")

return TRUE

end

end


if(t[1] <= 1 or t[1] == 135 or (t[1] > 160 and t[1] < 192) or t[1] > 351) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")

return true

end


local tmp = getCreatureOutfit(cid)

tmp.lookType = t[1]


doCreatureChangeOutfit(cid, tmp)

return true

end

DanihcvD
28 de março de 2016 às 00:21


local vocs = {9, 10, 11, 12}

 

function onSay(cid, words, param, channel)

if not isInArray(vocs, getPlayerVocation(cid)) then

doPlayerSendCancel(cid,"Sua vocação não pode usar este comando.")

end

if(param == '') then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")

return true

end

 

local t = string.explode(param, ",")

t[1] = tonumber(t[1])

if(not t[1]) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")

return true

end

 

 

 

local failout = {"73","75","302","266","45","10"} -- outfits proibidas

for i = 1, #failout do

if string.find(tostring(param), failout) then

doPlayerSendCancel(cid,"Não pode usar estas outfit.")

return TRUE

end

end

 

if(t[1] <= 1 or t[1] == 135 or (t[1] > 160 and t[1] < 192) or t[1] > 351) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")

return true

end

 

local tmp = getCreatureOutfit(cid)

tmp.lookType = t[1]

 

doCreatureChangeOutfit(cid, tmp)

return true

end

AdriezA
28 de março de 2016 às 10:11

fala sua vocação não pode usar, mais consegue usar

DanihcvD
28 de março de 2016 às 15:22

Tenta agr:

local vocs = {9, 10, 11, 12}
local can = "yes"

function onSay(cid, words, param, channel)
if not isInArray(vocs, getPlayerVocation(cid)) then
doPlayerSendCancel(cid,"Sua vocação não pode usar este comando.")
can = "no"
end
if can == "yes" then
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
        end
 
        local t = string.explode(param, ",")
        t[1] = tonumber(t[1])
        if(not t[1]) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
                return true
        end
 
 
 
local failout = {"73","75","302","266","45","10"} -- outfits proibidas
       for i = 1, #failout do
       if string.find(tostring(param), failout[i]) then
        doPlayerSendCancel(cid,"Não pode usar estas outfit.")
        return TRUE
end 
end   
 
        if(t[1] <= 1 or t[1] == 135 or (t[1] > 160 and t[1] < 192) or t[1] > 351) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")
                return true
        end
 
        local tmp = getCreatureOutfit(cid)
        tmp.lookType = t[1]
 
        doCreatureChangeOutfit(cid, tmp)
end
        return true
end
AdriezA
29 de março de 2016 às 09:17

agora ta assim a classe q não pode usar não usa,mais a q pode usa e não muda outfit e nem da erro

PoccnnP
29 de março de 2016 às 10:19

Usa isso:

 

--- script

local vocs = {9, 10, 11, 12}

local failout = {73,75,302,266,45,10} -- outfits proibidas

 

function onSay(cid, words, param, channel)

local t = string.explode(param, ",")

t[1] = tonumber(t[1])

if not isInArray(vocs, getPlayerVocation(cid)) then

doPlayerSendCancel(cid,"Sua vocação não pode usar este comando.")

elseif(param == '') then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")

elseif not(t[1]) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")

elseif isInArray(failout, t[1]) then

doPlayerSendCancel(cid,"Não pode usar estas outfit.")

elseif(t[1] <= 1 or t[1] == 135 or (t[1] > 160 and t[1] < 192) or t[1] > 351) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")

else

local tmp = getCreatureOutfit(cid)

tmp.lookType = t[1]

doCreatureChangeOutfit(cid, tmp)

end

return true

end