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.
Por AdilsonHacker, 18 de jun. de 2015 em 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
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: 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)
Editado Junho 22 por 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.
Editado Junho 22 por zipter98
info
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: 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
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: 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
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: 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
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: Masculino

<event type="target" name="guarda" event="script" value="guarda.lua"/> <event type="StatsChange" name="guarda" event="script" value="guarda.lua"/>
Editado Junho 23 por 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>Editado Junho 23 por zipter98
info
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: 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
Editado Junho 24 por zipter98
info
Grupo: Visconde
Registrado: 24/11/12
Posts: 474
Reputação: +98
Gênero: Masculino


info
Grupo: Herói
Registrado: 20/09/12
Posts: 2.6k
Reputação: +1.1k
Gênero: Masculino
Foi mal, é o sono. Códigos corrigidos.
Editado Junho 21 por zipter98