Ir para conteúdo

Posts Recomendados

Aew gente blz? to aqui pra pedir um complemento de script

Tipo, eu estou tentando colocar as potions para uma nova vocação, mas eu ja fiz o que vários tutoriais ensinavam daqui mesmo do Xtibia

 

Obs: Já botei o ID da vocação no function.lua

 

function isKnight(cid)
    if(isPlayer(cid) == FALSE) then
        debugPrint("isKnight: Player not found.")
        return false
    end

    return (isInArray({4,8,12}, getPlayerVocation(cid)) == TRUE)
end

Tem algo errado? falta algo?

 

12 é a nova vocação

 

Obrigado !.

 

Se for a área errada, por favor me desculpe !.

Link para o comentário
https://xtibia.com/forum/topic/123304-potions-falta-algum-script/
Compartilhar em outros sites

Tá errado sim

Não existe "isKnight(cid)"

 

O code é enorme, põe em actions e arrume conforme precisar

 

local config = {
removeOnUse = "no",
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)

local POTION = {
[id cheio] = {empty = id vazio, splash = 2, health = {minimo, maximo}, vocation = 12, vocStr = "nome da voc"}}, -- edite a gosto
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTION[item.itemid]
if(not potion) then
	return false
end

if(not isPlayer(itemEx.uid)) then
	if(not config.splashable) then
		return false
	end

	if(toPosition.x == CONTAINER_POSITION) then
		toPosition = getThingPos(item.uid)
	end

	doDecayItem(doCreateItem(2016, potion.splash, toPosition))
	doTransformItem(item.uid, potion.empty)
	return true
end

if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
	doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	return true
end

if(potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)) and
	not getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges))
then
	doCreatureSay(itemEx.uid, "Only [nome da vocação] may drink this fluid.", TALKTYPE_ORANGE_1)
	return true
end

local health = potion.health
if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2])))) then
	return false
end

doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
if(not realAnimation) then
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
else
	for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
		if(isPlayer(tid)) then
			doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
		end
	end
end

doAddCondition(cid, exhaust)
if(not potion.empty or config.removeOnUse) then
	doRemoveItem(item.uid)
	return true
end

doTransformItem(item.uid, potion.empty)
return true
end

Link para o comentário
https://xtibia.com/forum/topic/123304-potions-falta-algum-script/#findComment-814966
Compartilhar em outros sites

Tá errado sim

Não existe "isKnight(cid)"

 

O code é enorme, põe em actions e arrume conforme precisar

 

local config = {
removeOnUse = "no",
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)

local POTION = {
[id cheio] = {empty = id vazio, splash = 2, health = {minimo, maximo}, vocation = 12, vocStr = "nome da voc"}}, -- edite a gosto
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTION[item.itemid]
if(not potion) then
	return false
end

if(not isPlayer(itemEx.uid)) then
	if(not config.splashable) then
		return false
	end

	if(toPosition.x == CONTAINER_POSITION) then
		toPosition = getThingPos(item.uid)
	end

	doDecayItem(doCreateItem(2016, potion.splash, toPosition))
	doTransformItem(item.uid, potion.empty)
	return true
end

if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
	doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	return true
end

if(potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)) and
	not getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges))
then
	doCreatureSay(itemEx.uid, "Only [nome da vocação] may drink this fluid.", TALKTYPE_ORANGE_1)
	return true
end

local health = potion.health
if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2])))) then
	return false
end

doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
if(not realAnimation) then
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
else
	for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
		if(isPlayer(tid)) then
			doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
		end
	end
end

doAddCondition(cid, exhaust)
if(not potion.empty or config.removeOnUse) then
	doRemoveItem(item.uid)
	return true
end

doTransformItem(item.uid, potion.empty)
return true
end

 

Eu configurei e talz, mas ta dando erro.

 

Ta ai oq eu configurei, acho q fiz algo errado.

 

local config = {
removeOnUse = "no",
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)

local POTION = {
[8473] = {empty = 7635, splash = 2, health = {100, 200}, vocation = 12, vocStr = "Slayer Knight"}}, -- edite a gosto
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTION[item.itemid]
if(not potion) then
return false
end

if(not isPlayer(itemEx.uid)) then
if(not config.splashable) then
return false
end

if(toPosition.x == CONTAINER_POSITION) then
toPosition = getThingPos(item.uid)
end

doDecayItem(doCreateItem(2016, potion.splash, toPosition))
doTransformItem(item.uid, potion.empty)
return true
end

if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end

if(potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)) and
not getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges))
then
doCreatureSay(itemEx.uid, "Only [Knights] may drink this fluid.", TALKTYPE_ORANGE_1)
return true
end

local health = potion.health
if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2])))) then
return false
end

doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
if(not realAnimation) then
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
else
for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
if(isPlayer(tid)) then
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
end
end
end

doAddCondition(cid, exhaust)
if(not potion.empty or config.removeOnUse) then
doRemoveItem(item.uid)
return true
end

doTransformItem(item.uid, potion.empty)
return true
end

 

Link para o comentário
https://xtibia.com/forum/topic/123304-potions-falta-algum-script/#findComment-815259
Compartilhar em outros sites

Acho que achei o erro

 

local POTION = {

[id cheio] = {empty = id vazio, splash = 2, health = {minimo, maximo}, vocation = 12, vocStr = "nome da voc"}}, -- edite a gosto

}

 

Tem um colchete a mais, troca }} por }

Link para o comentário
https://xtibia.com/forum/topic/123304-potions-falta-algum-script/#findComment-815342
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...