RO

[Resolvido] Duvida sobre a script

Por rogeriofarkas, 17 de out. de 2019 em Resolvidos

10
3k
17 de outubro de 2019 às 19:14

Boa Tarde então tenho essa script porem ele tá fazendo ao contrario do que eu queria invés dele barra quem tem a storage ele tá barrando quem não tem queria sabe o que falto para acrescenta na script

a action já está dando storage por tal hora do jeito que queria só movement mesmo que não está fazendo do jeito que eu queria

caso tiver no lugar errado me desculpa por favor me mover obrigado a todos do fórum

MarshmelloM
17 de outubro de 2019 às 21:34

@rogeriofarkas Tenta ae

 

Spoiler

function onStepIn(cid, item, position, fromPosition)
    local config = {
    storage = 789458,
    from = {x = 1269, y = 2250, z = 7},
    to = {x = 1269, y = 2253, z = 7},
    maxPlayers = 50,
    pos = {x = 1270, y = 2251, z = 7},
    }
    
    local function getPlayersInArea(left, right)
        local playersInArea = {}
        for _, cid in ipairs(getPlayersOnline()) do
            if isInRange(getThingPos(cid), left, right) then
                table.insert(playersInArea, cid)
            end
        end
    return playersInArea
    end
    
    if isPlayer(cid) then
        if getPlayerStorageValue (cid, config.storage) > os.time() then
            doPlayerSendTextMessage(cid, 19, "Voce Ja fez a quest volte amanha.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        else
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        end
    
        if table.getn(getPlayersInArea(config.from, config.to)) < config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doTeleportThing (cid, config.pos)
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        elseif table.getn(getPlayersInArea(config.from, config.to)) >= config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then
            doPlayerSendTextMessage (cid, 19, "Voce Ja Tem grupo na quest favor aguarda.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        end
    end
return true
end

 

17 de outubro de 2019 às 21:50
15 minutos atrás, Marshmello disse:

@rogeriofarkas Tenta ae

 

  Mostrar conteúdo oculto

function onStepIn(cid, item, position, fromPosition)
    local config = {
    storage = 789458,
    from = {x = 1269, y = 2250, z = 7},
    to = {x = 1269, y = 2253, z = 7},
    maxPlayers = 50,
    pos = {x = 1270, y = 2251, z = 7},
    }
    
    local function getPlayersInArea(left, right)
        local playersInArea = {}
        for _, cid in ipairs(getPlayersOnline()) do
            if isInRange(getThingPos(cid), left, right) then
                table.insert(playersInArea, cid)
            end
        end
    return playersInArea
    end
    
    if isPlayer(cid) then
        if getPlayerStorageValue (cid, config.storage) > os.time() then
            doPlayerSendTextMessage(cid, 19, "Voce Ja fez a quest volte amanha.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        else
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        end
    
        if table.getn(getPlayersInArea(config.from, config.to)) < config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doTeleportThing (cid, config.pos)
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        elseif table.getn(getPlayersInArea(config.from, config.to)) >= config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then
            doPlayerSendTextMessage (cid, 19, "Voce Ja Tem grupo na quest favor aguarda.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        end
    end
return true
end

 

foi meio óbvio que ai da erro mais em fim deu erro

 

MarshmelloM
18 de outubro de 2019 às 12:13

Pode informar os erros que deu?

Yan OliveiraY
20 de outubro de 2019 às 23:05
Em 17/10/2019 em 19:14, rogeriofarkas disse:
Versão do Servidor: TFS - 0.4
Tipo de Script: moveevent
Código:
  Ocultar conteúdo

function onStepIn(cid, item, position, fromPosition)
	local config = {
	storage = 789458,
	from = {x = 1269, y = 2250, z = 7},
	to = {x = 1269, y = 2253, z = 7},
	maxPlayers = 50,
	pos = {x = 1270, y = 2251, z = 7},
	}
	
	local function getPlayersInArea(left, right)
		local playersInArea = {}
		for _, cid in ipairs(getPlayersOnline()) do
			if isInRange(getThingPos(cid), left, right) then
				table.insert(playersInArea, cid)
			end
		end
	return playersInArea
	end
	
	if isPlayer(cid) then
		if getPlayerStorageValue (cid, config.storage) < os.time() then
			doPlayerSendTextMessage(cid, 19, "Voce Ja fez a quest volte amanha.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
			doTeleportThing(cid, fromPosition, true)
		else
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		end
	
		if table.getn(getPlayersInArea(config.from, config.to)) < config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then
			doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
			doTeleportThing (cid, config.pos)
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		elseif table.getn(getPlayersInArea(config.from, config.to)) >= config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then
			doPlayerSendTextMessage (cid, 19, "Voce Ja Tem grupo na quest favor aguarda.")
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
			doTeleportThing(cid, fromPosition, true)
		end
	end
return true
end

Boa Tarde então tenho essa script porem ele tá fazendo ao contrario do que eu queria invés dele barra quem tem a storage ele tá barrando quem não tem queria sabe o que falto para acrescenta na script

a action já está dando storage por tal hora do jeito que queria só movement mesmo que não está fazendo do jeito que eu queria

caso tiver no lugar errado me desculpa por favor me mover obrigado a todos do fórum

Essa quest ai, o player só poderá fazer uma vez? E seria bom postar o seu action também.

21 de outubro de 2019 às 15:06
15 horas atrás, Yan18 disse:

Essa quest ai, o player só poderá fazer uma vez? E seria bom postar o seu action também.

function onUse(cid, item, frompos, item2, topos)
local config = {
	timeExhausted = 24, -- tempo em horas para poder usar o item novamente.
	timeForUse = 6, -- tempo em horas que o player poderá entrar na cave.
	exhausted = 456790,
	storage = 789456,
	toKnow = 123456,
	effect = 28, -- efeito que dará ao usar o item.
	}
	if getPlayerStorageValue(cid, config.exhausted) < os.time() then
		setPlayerStorageValue (cid, config.storage, config.timeForUse * 60 * 60 + os.time())
		setPlayerStorageValue (cid, config.exhausted, config.timeExhausted * 60 * 60 + os.time())
		setPlayerStorageValue (cid, config.toKnow, 1)
		doSendMagicEffect (getThingPos(cid), config.effect)
		doPlayerSendTextMessage (cid, 19, "Voce ganho Acesso A Cave Exclusiva por 6h.")
	else
		doPlayerSendTextMessage (cid, 19, "Voce Ja Fez A Quest Espere 24 horas Para Usar Denovo Se continua ")
	end
local Templo = {x=155, y=52, z=7}

doTeleportThing(cid, Templo) 

doPlayerSendTextMessage(cid,20,"VOCE PEGOU SUA CAVE FOI TELEPORTA PARA O TEMPLO volte daqui 1 dia.")
return true
end

Ele iria fazer 1 vez por dia tipo no começo da quest verificar se ja tem a storage se tiver nao deixa passa ate ela acabar so falta isso na quest

Em 18/10/2019 em 12:13, Marshmello disse:

Pode informar os erros que deu?

[15:12:55.735] [Error - MoveEvents Interface]
[15:12:55.736] data/movements/scripts/Questcave.lua
[15:12:55.737] Description:
[15:12:55.738] data/movements/scripts/Questcave.lua:2: attempt to call global 'getPlayerCarValue' (a nil value)
[15:12:55.738] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/Questcave.lua)

MarshmelloM
22 de outubro de 2019 às 00:47
Melhor resposta

@rogeriofarkas Faz um teste ae

function onStepIn(cid, item, position, fromPosition)

    local config = {
    storage = 789458,
    area = {fromx = 1269, fromy = 2250, fromz = 7, tox = 1269, toy = 2253, toz = 7},
    maxPlayers = 50,
    pos = {x = 1270, y = 2251, z = 7},
    }
    
function getPlayersInArea(area)
local players = {}

for x = area.fromx,area.tox do
for y = area.fromy,area.toy do
for z = area.fromz,area.toz do

local m = getTopCreature({x=x, y=y, z=z}).uid

if m ~= 0 and isPlayer(m) then
table.insert(players, m)
end
end
end
end
return players
end
    
    if isPlayer(cid) then
        if getPlayerStorageValue (cid, config.storage) > os.time() then
            doPlayerSendTextMessage(cid, 19, "Voce Ja fez a quest volte amanha.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        else
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        end
    
        if #getPlayersInArea(config.area) < config.maxPlayers and getPlayerStorageValue (cid, config.storage) < os.time() then
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doTeleportThing (cid, config.pos)
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        elseif #getPlayersInArea(config.area) >= config.maxPlayers and getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSendTextMessage (cid, 19, "Voce Ja Tem grupo na quest favor aguarda.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        end
    end
return true
end

 

22 de outubro de 2019 às 17:48
17 horas atrás, Marshmello disse:

@rogeriofarkas Faz um teste ae

function onStepIn(cid, item, position, fromPosition)

    local config = {
    storage = 789458,
    area = {fromx = 1269, fromy = 2250, fromz = 7, tox = 1269, toy = 2253, toz = 7},
    maxPlayers = 50,
    pos = {x = 1270, y = 2251, z = 7},
    }
    
function getPlayersInArea(area)
local players = {}

for x = area.fromx,area.tox do
for y = area.fromy,area.toy do
for z = area.fromz,area.toz do

local m = getTopCreature({x=x, y=y, z=z}).uid

if m ~= 0 and isPlayer(m) then
table.insert(players, m)
end
end
end
end
return players
end
    
    if isPlayer(cid) then
        if getPlayerStorageValue (cid, config.storage) > os.time() then
            doPlayerSendTextMessage(cid, 19, "Voce Ja fez a quest volte amanha.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        else
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        end
    
        if #getPlayersInArea(config.area) < config.maxPlayers and getPlayerStorageValue (cid, config.storage) < os.time() then
            doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
            doTeleportThing (cid, config.pos)
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        elseif #getPlayersInArea(config.area) >= config.maxPlayers and getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSendTextMessage (cid, 19, "Voce Ja Tem grupo na quest favor aguarda.")
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doTeleportThing(cid, fromPosition, true)
        end
    end
return true
end

 

Funciono acho que na primeira vez eu devo ter feito algo errado. valeu mano ta perfeito só vou arrumar agora para os players que forem fazer a quest conseguir volta pra trás caso desistir dela duvida sanada

Editado Outubro 22 por rogeriofarkas

MarshmelloM
22 de outubro de 2019 às 18:46
Agora, rogeriofarkas disse:

Funciono acho que na primeira vez eu devo ter feito algo errado. valeu mano ta perfeito só vou arrumar agora para os players que forem fazer a quest conseguir volta pra trás caso desistir dela duvida sanada

Eu so troquei a função de getPlayerInArea. fico feliz em saber que funcionou ;)

Yan LiimaY
23 de outubro de 2019 às 00:12
A questão neste tópico de suporte foi respondida e/ou o autor do tópico resolveu o problema. Este tópico está fechado e foi movido para Suporte - Resolvidos. Se você tiver outras dúvidas, crie um novo tópico.