Funcionou, obrigado.
Mas enquanto em lua, nenhum resultado o monster ainda ataca o jogador com vocation id diferente da adicionada no script.
mano poderia dizer qual sua idéia com esses script.
By AdilsonHacker, 18 de jun. de 2015 in Scripts
Funcionou, obrigado.
Mas enquanto em lua, nenhum resultado o monster ainda ataca o jogador com vocation id diferente da adicionada no script.
mano poderia dizer qual sua idéia com esses script.
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino

Obrigado a todos que tentaram de todo jeito me ajudar, principalmente Bruno e Zipter98.
Grato.
mano poderia dizer qual sua idéia com esses script.
Creatserv, meu servidor possui raças com esse script criarei guardas para cada centro da cidade.
@EDIT
Zipter, achei um pequeno erro outra vocation sem o id configurado consegue matar o bixo, sendo que apenas os id configurado poderia matar, queria que quando jogadores sem o vocation id configurado aparece um doPlayerSendCancel dizendo "você não pode atacar esta criatura." (OBS: tinha esquecido deste detalhe)
Edited Junho 22 by AdilsonTsunami
Ops, é mesmo.
local config = {
name = "xxx", --nome do monstro
vocId = xxx, --vocation id
}
function onTarget(cid, target)
local player = isMonster(cid) and isPlayer(target) and target or isPlayer(cid) and isMonster(target) and getCreatureName(target) == config.name and cid or false
if player then
if getPlayerVocation(player) ~= config.vocId then
if isPlayer(cid) then
doPlayerSendCancel(cid, "você não pode atacar esta criatura.")
end
return false
end
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
local player = isMonster(attacker) and isPlayer(cid) and cid or isPlayer(attacker) and isMonster(cid) and getCreatureName(cid) == config.name and attacker or false
if player then
return getPlayerVocation(player) == config.vocId
end
return true
end
PS: O diretório na tag de ambos os creatureevents deve ser o mesmo.
Edited Junho 22 by zipter98
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino

Zipter, infelizmente nada aconteceu, o jogador sem a vocation id adicionada no script ainda consegue atacar o monstro.
E o monstro, ele foca apenas os jogadores com a vocation id configurada?
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino

Sim, e era para apenas os jogadores que ele foca poder atacar ele, quando outro vocation id não configurado atacar falar aquela mensagem que citei acima.
OK, tenta assim:
local config = {
name = "xxx", --nome do monstro
vocId = xxx, --vocation id
}
function onTarget(cid, target)
if isMonster(cid) and isPlayer(target) then
if getPlayerVocation(target) ~= config.vocId then
return false
end
elseif isPlayer(cid) and isMonster(target) then
if getCreatureName(target) == config.name and getPlayerVocation(cid) ~= config.vocId then
return doPlayerSendCancel(cid, "você não pode atacar esta criatura.") and false
end
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(attacker) and isPlayer(cid) then
if getPlayerVocation(cid) ~= config.vocId then
return false
end
elseif isPlayer(attacker) and isMonster(cid) then
if getCreatureName(cid) == config.name and getPlayerVocation(attacker) ~= config.vocId then
return doPlayerSendCancel(attacker, "você não pode atacar esta criatura.") and false
end
end
return true
end
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino

Mesma coisa, não da erros no console mais também não pega. Continua outra vocation id atacando o monstro.
Como ficaram as tags e o registro em login.lua?
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino

<event type="target" name="guarda" event="script" value="guarda.lua"/> <event type="StatsChange" name="guarda" event="script" value="guarda.lua"/>
Edited Junho 23 by AdilsonTsunami
Tags:
<event type="statschange" name="guardaStatsChange" event="script" value="guarda.lua"/> <event type="target" name="guardaTarget" event="script" value="guarda.lua"/>
registerCreatureEvent(cid, "guardaStatsChange") registerCreatureEvent(cid, "guardaTarget")
<script>
<event name="guardaStatsChange"/>
<event name="guardaTarget"/>
</script>Edited Junho 23 by zipter98
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino

Mesma coisa, nada acontece.
@up
Use este código e informe tudo que for imprimido no console.
local config = {
name = "xxx", --nome do monstro
vocId = xxx, --vocation id
}
function onTarget(cid, target)
if isMonster(cid) and isPlayer(target) then
if getPlayerVocation(target) ~= config.vocId then
return false
end
elseif isPlayer(cid) and isMonster(target) then
print("[Target] - "..getCreatureName(cid))
print("[Target] - Vocation ID: [configurada: "..config.vocId.."] / [cid: "..getPlayerVocation(cid).."]")
if getCreatureName(target) == config.name and getPlayerVocation(cid) ~= config.vocId then
print("[Target] Cid can't target monster.")
return doPlayerSendCancel(cid, "você não pode atacar esta criatura.") and false
end
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(attacker) and isPlayer(cid) then
if getPlayerVocation(cid) ~= config.vocId then
return false
end
elseif isPlayer(attacker) and isMonster(cid) and type == STATSCHANGE_HEALTHLOSS then
print("[StatsChange] - "..getCreatureName(attacker))
print("[StatsChange] - Vocation ID: [configurada: "..config.vocId.."] / [cid: "..getPlayerVocation(attacker).."]")
if getCreatureName(cid) == config.name and getPlayerVocation(attacker) ~= config.vocId then
print("[StatsChange] Cid can't damage monster.")
return doPlayerSendCancel(attacker, "você não pode atacar esta criatura.") and false
end
end
return true
end
Edited Junho 24 by zipter98
info
Group: Visconde
Joined: 24/11/12
Posts: 474
Reputation: +98
Gender: Masculino


info
Group: Herói
Joined: 20/09/12
Posts: 2.6k
Reputation: +1.1k
Gender: Masculino
Foi mal, é o sono. Códigos corrigidos.
Edited Junho 21 by zipter98