Ir para conteúdo

Featured Replies

Postado

Como faço para que apenas apenas os players que tem a storage 1805 receba os Ppoints nesse creaturescripts?

 

points.lua

Spoiler

--[[
P Points System by LsM.
OTServ Brasil © 2011
Version : v1.0
]]--

local config = {
                p_time = 3600, -- Tempo em segundos para receber os pontos( 3600 = 1hora )
                p_points = 2 -- Quantidade de pontos recebida a cada "p_time"
                }

local function givePoints(cid, quant)
      if os.time() - getCreatureStorage(cid, 1219) >= config.p_time then
           doPlayerSendTextMessage(cid, 19, "Congratulations, you recieved ".. config.p_points .." p points. Now you have ".. config.p_points + getPoints(cid) .." p points in your account. Your timer was reseted.")    
           doPlayerAddPoints(cid, quant)                 
           doCreatureSetStorage(cid, 1219, 0)
           doCreatureSetStorage(cid, 1219, os.time())
      end
      return true
end                  

function onThink(interval)
    for i, v in pairs(getPlayersOnline()) do   
         givePoints(v, config.p_points)
    end
    return true
end

 

 

E como posso alterar esse script para dar ppoints para todos online através de um simples comando?

 

talkaction.lua

Spoiler

function onSay(cid, words, param, channel)
local t = string.explode(param, ",")
if t[1] ~= nil and t[2] ~= nil then
local list = {}
for i, tid in ipairs(getPlayersOnline()) do
	list[i] = tid
end
for i = 1, #list do
doPlayerAddItem(list[i],t[1],t[2])
doBroadcastMessage(getPlayerName(cid) .. " Acabou de dar: " .. t[2] .." ".. getItemNameById(t[1]) .. " para todos os players online!")
end
else
doPlayerPopupFYI(cid, "No parm...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
end
return true
end

 

 

Editado por Thayguroficial (veja o histórico de edições)

Postado
Spoiler

local quant = 5 --quantidade de pontos

function onSay(cid, words, param, channel)
	for _, tid in ipairs(getPlayersOnline()) do
		doPlayerAddPoints(tid,quant)
	end

doBroadcastMessage(getPlayerName(cid) .. " acabou de dar: " .. quant .. " ppoints para todos os players online!")
return true
end

 

 

 

 

Spoiler

--[[
P Points System by LsM.
OTServ Brasil © 2011
Version : v1.0
]]--

local config = {
                p_time = 3600, -- Tempo em segundos para receber os pontos( 3600 = 1hora )
                p_points = 2 -- Quantidade de pontos recebida a cada "p_time"
                }

local function givePoints(cid, quant)
      if os.time() - getCreatureStorage(cid, 1219) >= config.p_time then
           doPlayerSendTextMessage(cid, 19, "Congratulations, you recieved ".. config.p_points .." p points. Now you have ".. config.p_points + getPoints(cid) .." p points in your account. Your timer was reseted.")    
           doPlayerAddPoints(cid, quant)                 
           doCreatureSetStorage(cid, 1219, 0)
           doCreatureSetStorage(cid, 1219, os.time())
      end
      return true
end                  

function onThink(interval)
    for i, v in pairs(getPlayersOnline()) do  
		if getPlayerStorageValue(v,1805) > 0 then
           givePoints(v, config.p_points)
		end
    end
    return true
end

 

 

Postado
  • Autor
4 horas atrás, antharaz disse:
  Mostrar conteúdo oculto


local quant = 5 --quantidade de pontos

function onSay(cid, words, param, channel)
	for _, tid in ipairs(getPlayersOnline()) do
		doPlayerAddPoints(tid,quant)
	end

doBroadcastMessage(getPlayerName(cid) .. " acabou de dar: " .. quant .. " ppoints para todos os players online!")
return true
end

 

 

 

 

  Mostrar conteúdo oculto


--[[
P Points System by LsM.
OTServ Brasil © 2011
Version : v1.0
]]--

local config = {
                p_time = 3600, -- Tempo em segundos para receber os pontos( 3600 = 1hora )
                p_points = 2 -- Quantidade de pontos recebida a cada "p_time"
                }

local function givePoints(cid, quant)
      if os.time() - getCreatureStorage(cid, 1219) >= config.p_time then
           doPlayerSendTextMessage(cid, 19, "Congratulations, you recieved ".. config.p_points .." p points. Now you have ".. config.p_points + getPoints(cid) .." p points in your account. Your timer was reseted.")    
           doPlayerAddPoints(cid, quant)                 
           doCreatureSetStorage(cid, 1219, 0)
           doCreatureSetStorage(cid, 1219, os.time())
      end
      return true
end                  

function onThink(interval)
    for i, v in pairs(getPlayersOnline()) do  
		if getPlayerStorageValue(v,1805) > 0 then
           givePoints(v, config.p_points)
		end
    end
    return true
end

 

 

Funcionou perfeitamente!!! obrigado

 

Poderia criar a talkaction com essa storage também 1805? apenas os que tem essa storage receber o item

Postado

@Thayguroficial 

 

Spoiler

function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	if t[1] ~= nil and t[2] ~= nil then
		for _,tid in pairs(getPlayersOnline()) do
			if getPlayerStorageValue(tid,1805) > 0 then
				doPlayerAddItem(tid,t[1],t[2])
			end
		end
		doBroadcastMessage(getPlayerName(cid) .. " Acabou de dar: " .. t[2] .." ".. getItemNameById(t[1]) .. " para todos os players online!")
	else
		doPlayerPopupFYI(cid, "No parm...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
	end
	return true
end

 

 

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo