Ir para conteúdo
  • Cadastre-se

(Resolvido)Usar Comando Somente Em X Position


Ir para solução Resolvido por Igorzerah,

Posts Recomendados

1 minuto atrás, mullino disse:

Boa Noite Tk

Gostaria de saber se tem como colocar uma talkactions para ser usada somente se o player estiver em x Position?

 

 

Opa, Suavera Maicon :) To editando um Ot aqui nesse momento estou fazendo uma script de passagem para usar um comando num certo lugar EX voce precisará usar esse comando no piso preto!

Quando vc chega no piso preto que é um exemplo de uma posição... X=123 Y=123 Z=7 <<< quando player chega nessa posicao(PISOPRETO) ele vai digitar seguinte comando.

!passagem. So que tem um porem. Quando ele chega no PISOPRETO, ele digitar comando passagem ele vai precisar de um ITEM.

Ex: PISOPRETO+!passagem+IDITEM(ai tu coloca um ID queira usar pra pode usar esse comando).

Então player vai precisar de Item que vou colocar de Ex nesse Script.

PISOPRETO+!passagem+2154(Yellow Gem).

Mais menos resumindo

Player vai usar esse comando num determinado local mas quando chega nesse local ele nao tiver a Yellow Gem na BP nao vai pode usar e nem passar...

Eu espero que voce consiga entender..

Vamos na Instalaçao...

Vai na PASTA do OT em Data/Talkactions/scripts e crie um arquivo.lua com nome passagem(nome que voce preferir) e cola essa script aqui:

 

 

function onSay(cid, words, param, channel)

if getCreaturePosition(cid).x ~= 383 or getCreaturePosition(cid).y ~= 350 or getCreaturePosition(cid).z ~= 15 then
doPlayerSendTextMessage(cid,25,"Voce tem que estar no piso preto para digitar esse comando")
doSendMagicEffect(getCreaturePosition(cid),2)
return true
end

if getPlayerItemCount(cid,6536,1) < 1 then
doPlayerSendTextMessage(cid,25,"Voce nao tem a bola de cristal dos deuses!")
doSendMagicEffect(getCreaturePosition(cid),2)
return true
end

if isPlayer(cid) then
doSendMagicEffect(getCreaturePosition(cid),2)
doTeleportThing(cid,{x=385,y=350,z=15})
doSendMagicEffect(getCreaturePosition(cid),10)
doPlayerSendTextMessage(cid,25,"Voce achou a passagem secreta!")
doPlayerRemoveItem(cid,6536,1)
return true
end

end

 


Depois disso vai em Talkactions.xml esse copie e cole essa Tag Aqui:

 

        <talkaction words="!passagem" access="0" event="script" value="passagem.lua"/>

Lembrando que no WORDS voce pode coloca qualquer comando que queira usar

Espero de te Ajudado :););)

 

Link para o post
Compartilhar em outros sites
7 horas atrás, Pedrok22 disse:

Opa, Suavera Maicon :) To editando um Ot aqui nesse momento estou fazendo uma script de passagem para usar um comando num certo lugar EX voce precisará usar esse comando no piso preto!

Quando vc chega no piso preto que é um exemplo de uma posição... X=123 Y=123 Z=7 <<< quando player chega nessa posicao(PISOPRETO) ele vai digitar seguinte comando.

!passagem. So que tem um porem. Quando ele chega no PISOPRETO, ele digitar comando passagem ele vai precisar de um ITEM.

Ex: PISOPRETO+!passagem+IDITEM(ai tu coloca um ID queira usar pra pode usar esse comando).

Então player vai precisar de Item que vou colocar de Ex nesse Script.

PISOPRETO+!passagem+2154(Yellow Gem).

Mais menos resumindo

Player vai usar esse comando num determinado local mas quando chega nesse local ele nao tiver a Yellow Gem na BP nao vai pode usar e nem passar...

Eu espero que voce consiga entender..

Vamos na Instalaçao...

Vai na PASTA do OT em Data/Talkactions/scripts e crie um arquivo.lua com nome passagem(nome que voce preferir) e cola essa script aqui:

 

 

function onSay(cid, words, param, channel)

if getCreaturePosition(cid).x ~= 383 or getCreaturePosition(cid).y ~= 350 or getCreaturePosition(cid).z ~= 15 then
doPlayerSendTextMessage(cid,25,"Voce tem que estar no piso preto para digitar esse comando")
doSendMagicEffect(getCreaturePosition(cid),2)
return true
end

if getPlayerItemCount(cid,6536,1) < 1 then
doPlayerSendTextMessage(cid,25,"Voce nao tem a bola de cristal dos deuses!")
doSendMagicEffect(getCreaturePosition(cid),2)
return true
end

if isPlayer(cid) then
doSendMagicEffect(getCreaturePosition(cid),2)
doTeleportThing(cid,{x=385,y=350,z=15})
doSendMagicEffect(getCreaturePosition(cid),10)
doPlayerSendTextMessage(cid,25,"Voce achou a passagem secreta!")
doPlayerRemoveItem(cid,6536,1)
return true
end

end

 


Depois disso vai em Talkactions.xml esse copie e cole essa Tag Aqui:

 

        <talkaction words="!passagem" access="0" event="script" value="passagem.lua"/>

Lembrando que no WORDS voce pode coloca qualquer comando que queira usar

Espero de te Ajudado :););)

 

 

opa Obrigado @Pedrok22....

 

Vou tirar uma Ideia da Sua Ideia kkk

 Script Bem interessante.

Da Pra Colocar Esse Seu em Uma Quest Top.

7 horas atrás, .Smile disse:

Sim, posta o código, e é pra ele só conseguir usar em certa área ou em certo piso exatamente em certa posição ?

 

Em uma certa Areá Seria Melhor @.Smile.

Obrigado A Todos Pela Ajuda.

local config = {
	minlevel = 30000, --- level inical para resetar
	price = 100000, --- preço inicial para resetar
	newlevel = 20, --- level apos reset
	priceByReset = 90000, --- preço acrescentado por reset
	percent = 80, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
	maxresets = 25,
        look = true,
	levelbyreset = 10000 --- quanto de level vai precisar a mais no próximo reset
}



local function getResets(cid)
	local query = db.getResult("SELECT `resets` FROM `players` WHERE `id`= "..getPlayerGUID(cid))
	return query:getDataInt("resets") <= 0 and 0 or query:getDataInt("resets")
end
local function addReset(cid)
	local resets = getResets(cid)
	doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
	local hp = getCreatureMaxHealth(cid)
	local resethp = hp*(config.percent/100)
	setCreatureMaxHealth(cid, resethp)
	local differencehp = (hp - resethp)
	doCreatureAddHealth(cid, -differencehp)
	local mana = getCreatureMaxMana(cid)
	local resetmana = mana*(config.percent/100)
	setCreatureMaxMana(cid, resetmana)
	local differencemana = (mana - resetmana)
	doCreatureAddMana(cid, -differencemana)
	local guid = getPlayerGUID(cid)
	doRemoveCreature(cid) 
	local description = resets+1
	db.query("UPDATE `players` SET `level` = "..config.newlevel..", `experience`= 0, `resets`= "..description.." WHERE `players`.`id`= ".. guid)
	return true
end

function onSay(cid, words, param, channel)
	local var = getResets(cid)
	local newPrice = config.price + (var * config.priceByReset)
	local newminlevel = config.minlevel + (var * config.levelbyreset)
	if param == "quantity" then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a total of '..var..' reset(s).')
	end
	if var >= config.maxresets then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'You already have reached the maximum of '.. config.maxresets.. ' resets!')
	elseif getPlayerMoney(cid) < newPrice then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'Its necessary to have at least '..newPrice..' gp\'s for reseting!')
	elseif getPlayerLevel(cid) < newminlevel then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'The minimum level for reseting is '..newminlevel..'!')

	end
	doPlayerRemoveMoney(cid,newPrice)
	addEvent(function()
		if isPlayer(cid) then
			addReset(cid)
		end
	end, 3000)
	local number = var+1
	local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds."
	doPlayerPopupFYI(cid, msg)
	return true
end

 

Editado por mullino (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
local config = {
	minlevel = 30000, --- level inical para resetar
	price = 100000, --- preço inicial para resetar
	newlevel = 20, --- level apos reset
	priceByReset = 90000, --- preço acrescentado por reset
	percent = 80, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
	maxresets = 25,
	look = true,
	levelbyreset = 10000
}



local function getResets(cid)
	local query = db.getResult("SELECT `resets` FROM `players` WHERE `id`= "..getPlayerGUID(cid))
	return query:getDataInt("resets") <= 0 and 0 or query:getDataInt("resets")
end
local function addReset(cid)
	local resets = getResets(cid)
	doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
	local hp = getCreatureMaxHealth(cid)
	local resethp = hp*(config.percent/100)
	setCreatureMaxHealth(cid, resethp)
	local differencehp = (hp - resethp)
	doCreatureAddHealth(cid, -differencehp)
	local mana = getCreatureMaxMana(cid)
	local resetmana = mana*(config.percent/100)
	setCreatureMaxMana(cid, resetmana)
	local differencemana = (mana - resetmana)
	doCreatureAddMana(cid, -differencemana)
	local guid = getPlayerGUID(cid)
	doRemoveCreature(cid) 
	local description = resets+1
	db.query("UPDATE `players` SET `level` = "..config.newlevel..", `experience`= 0, `resets`= "..description.." WHERE `players`.`id`= ".. guid)
	return true
end

function onSay(cid, words, param, channel)
local from,to = {x=1001, y=705, z=7},{x=1031, y=737, z=7} -- AREA QUE O COMANDO PODE SER USADO  
	if not isInRange(getCreaturePosition(cid), from, to) then
		doPlayerSendCancel(cid, "Voce nao esta no local certo para utilizar este comando.") 
    	return true
	end

	local var = getResets(cid)
	local newPrice = config.price + (var * config.priceByReset)
	local newminlevel = config.minlevel + (var * config.levelbyreset)
	if param == "quantity" then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a total of '..var..' reset(s).')
	end
	if var >= config.maxresets then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'You already have reached the maximum of '.. config.maxresets.. ' resets!')
	elseif getPlayerMoney(cid) < newPrice then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'Its necessary to have at least '..newPrice..' gp\'s for reseting!')
	elseif getPlayerLevel(cid) < newminlevel then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'The minimum level for reseting is '..newminlevel..'!')

	end
	doPlayerRemoveMoney(cid,newPrice)
	addEvent(function()
		if isPlayer(cid) then
			addReset(cid)
		end
	end, 3000)
	local number = var+1
	local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds."
	doPlayerPopupFYI(cid, msg)
	return true
end

 

Editado por .Smile
arrumei o código. (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
2 horas atrás, .Smile disse:

local config = { minlevel = 30000, --- level inical para resetar price = 100000, --- preço inicial para resetar newlevel = 20, --- level apos reset priceByReset = 90000, --- preço acrescentado por reset percent = 80, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 25, look = true, levelbyreset = 10000, from,to = {x=1001, y=705, z=7},{x=1031, y=737, z=7} -- AREA QUE O COMANDO PODE SER USADO } local function getResets(cid) local query = db.getResult("SELECT `resets` FROM `players` WHERE `id`= "..getPlayerGUID(cid)) return query:getDataInt("resets") <= 0 and 0 or query:getDataInt("resets") end local function addReset(cid) local resets = getResets(cid) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) local hp = getCreatureMaxHealth(cid) local resethp = hp*(config.percent/100) setCreatureMaxHealth(cid, resethp) local differencehp = (hp - resethp) doCreatureAddHealth(cid, -differencehp) local mana = getCreatureMaxMana(cid) local resetmana = mana*(config.percent/100) setCreatureMaxMana(cid, resetmana) local differencemana = (mana - resetmana) doCreatureAddMana(cid, -differencemana) local guid = getPlayerGUID(cid) doRemoveCreature(cid) local description = resets+1 db.query("UPDATE `players` SET `level` = "..config.newlevel..", `experience`= 0, `resets`= "..description.." WHERE `players`.`id`= ".. guid) return true end function onSay(cid, words, param, channel) if not isInRange(getCreaturePosition(cid), from, to) then doPlayerSendCancel(cid, "Voce nao esta no local certo para utilizar este comando.") return true end local var = getResets(cid) local newPrice = config.price + (var * config.priceByReset) local newminlevel = config.minlevel + (var * config.levelbyreset) if param == "quantity" then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a total of '..var..' reset(s).') end if var >= config.maxresets then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'You already have reached the maximum of '.. config.maxresets.. ' resets!') elseif getPlayerMoney(cid) < newPrice then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'Its necessary to have at least '..newPrice..' gp\'s for reseting!') elseif getPlayerLevel(cid) < newminlevel then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'The minimum level for reseting is '..newminlevel..'!') end doPlayerRemoveMoney(cid,newPrice) addEvent(function() if isPlayer(cid) then addReset(cid) end end, 3000) local number = var+1 local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds." doPlayerPopupFYI(cid, msg) return true end

deu esse erro 

[Error - TalkAction Interface]
data/talkactions/scripts/reset.lua:onSay
Description:
data/lib/032-position.lua:2: attempt to index local 'fromPosition' (a nil value)
stack traceback:
        data/lib/032-position.lua:2: in function 'isInRange'
        data/talkactions/scripts/reset.lua:40: in function <data/talkactions/scripts/reset.lua:39>

Link para o post
Compartilhar em outros sites
  • Solução
Spoiler

local config = {
    minlevel = 30000, --- level inical para resetar
    price = 100000, --- preço inicial para resetar
    newlevel = 20, --- level apos reset
    priceByReset = 90000, --- preço acrescentado por reset
    percent = 80, ---- porcentagem da vida/mana que você terá ao resetar (em relação à  sua antiga vida total)
    maxresets = 25,
        look = true,
    levelbyreset = 10000 --- quanto de level vai precisar a mais no próximo reset
}

local function getResets(cid)
    local query = db.getResult("SELECT `resets` FROM `players` WHERE `id`= "..getPlayerGUID(cid))
    return query:getDataInt("resets") <= 0 and 0 or query:getDataInt("resets")
end
local function addReset(cid)
    local resets = getResets(cid)
    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    local hp = getCreatureMaxHealth(cid)
    local resethp = hp*(config.percent/100)
    setCreatureMaxHealth(cid, resethp)
    local differencehp = (hp - resethp)
    doCreatureAddHealth(cid, -differencehp)
    local mana = getCreatureMaxMana(cid)
    local resetmana = mana*(config.percent/100)
    setCreatureMaxMana(cid, resetmana)
    local differencemana = (mana - resetmana)
    doCreatureAddMana(cid, -differencemana)
    local guid = getPlayerGUID(cid)
    doRemoveCreature(cid) 
    local description = resets+1
    db.query("UPDATE `players` SET `level` = "..config.newlevel..", `experience`= 0, `resets`= "..description.." WHERE `players`.`id`= ".. guid)
    return true
end

function onSay(cid, words, param, channel)

 if not isInArea(getThingPos(cid),{x = 294, y = 33, z = 7},{x = 314, y = 50, z = 7}) then
         doPlayerSendCancel(cid, "Nao pode resetar aqui!")
             return true
             end
             
    local var = getResets(cid)
    local newPrice = config.price + (var * config.priceByReset)
    local newminlevel = config.minlevel + (var * config.levelbyreset)
    if param == "quantity" then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a total of '..var..' reset(s).')
    end
    if var >= config.maxresets then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'You already have reached the maximum of '.. config.maxresets.. ' resets!')
    elseif getPlayerMoney(cid) < newPrice then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'Its necessary to have at least '..newPrice..' gp\'s for reseting!')
    elseif getPlayerLevel(cid) < newminlevel then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'The minimum level for reseting is '..newminlevel..'!')

    end
    doPlayerRemoveMoney(cid,newPrice)
    addEvent(function()
        if isPlayer(cid) then
            addReset(cid)
        end
    end, 3000)
    local number = var+1
    local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds."
    doPlayerPopupFYI(cid, msg)
    return true
end

@mullino

Link para o post
Compartilhar em outros sites

@Igorzerah Obrigado mano Ajudou de mais

@.Smile Obrigado tbm Mano...

Poderiao ajudar Nesse aqui agora?

 

 

Editado por mullino (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
Agora, .Smile disse:

SakopPkosaok sempre erro na hora de mexer com variáveis fico feliz que já tenham te ajudado, corrigi o  código lá de qualquer forma.

 

@.Smile Obrigado mano vc é 10 TBM...

da uma forcinha la no outro fazendo favor tem como?

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo