GA
pedido

Reset Frags e prêmios, Mensalmente

Por Gabrielkss, 28 de jan. de 2016 em Scripts

16
2.2k
GabrielkssG
28 de janeiro de 2016 às 19:59

Olá gostaria de pedir um script, no qual, ele todo mês automaticamente tivesse um resete no final do mês dos pontos de frag, e um premio para o top frag do servidor, alguém poderia me ajudar por favor.

Server 8.60. Sistema de frag normal, que tem no xtibia.

 

Agradeço desde de ja.

Editado Janeiro 29 por gabreilk

NickbhzN
28 de janeiro de 2016 às 21:41

È sempre bom mencionar qual server você usa, versão e até o seu sistema de frags para que alguem possa te ajuda-lo...

 

Gostei da ideia, caso alguem poder lhe ajudar, me ajudaria tb.. rs

GabrielkssG
29 de janeiro de 2016 às 16:49

Mudei lá. se alguém puder ajudar, agradeço muito.


up


alguém plz ?

DanihcvD
29 de janeiro de 2016 às 23:53

Bom, para que alguem possa oferecer uma ajuda 100% eficiente, é necessário que vc informe qual distro vc usa, e que ponha um link para mostrar qual o frag system q vc está usando exatamente.

GabrielkssG
30 de janeiro de 2016 às 11:04

Eu uso distro OTX. a versão do frags é essa.. http://www.xtibia.com/forum/topic/145118-creatureevent-contagem-de-frags-no-look/

 

 


Alguém ?

CaronteC
30 de janeiro de 2016 às 16:28

Testa isso numa função aí, veja se da print de um número

local online = getOnlinePlayers()
		local winner = online[1]

		for l, pid in pairs(online) do 
			if getPlayerFrags(online[l]) > getPlayerFrags(winner) then 
				local winner = online[l]
			end
		end
print(getCreatureName(winner))

Não esquece de colocar a função getPlayerFrags junto com o script de test... (eu recomendo colocar ela dentro da pasta data/lib, para não precisar declarar toda hora que usar)

GabrielkssG
31 de janeiro de 2016 às 02:59

teria como fazer ? eu não sei mecher em scripts =/

CaronteC
31 de janeiro de 2016 às 03:10

É só copiar um onSay e colocar o script entre o

function onSay(cid, ...)

 

E o

 

end

 

Só colocar no meio,e uma tag você cópia e edita, vou dormir... Qq coisa quando acessar o fórum eu respondo.

DanihcvD
31 de janeiro de 2016 às 03:13

*Apenas a titulo de testes...

Vá em data\talkactions e adicione essa tag ao arquivo talkactions.xml:

<talkaction words="!teste" event="script" value="teste.lua"/>

Agora vá em data\talkactions\scripts e crie um arquivo chamado teste.lua e adicione isso dentro:

local function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}
 
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end
 
    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    } 
    return size.day + size.week + size.month
end

function onSay(cid, words, param)
local online = getOnlinePlayers()
		local winner = online[1]

		for l, pid in pairs(online) do 
			if getPlayerFrags(online[l]) > getPlayerFrags(winner) then 
				local winner = online[l]
			end
		end
print(getCreatureName(winner))
return true
end

Agora, dentro do jogo utilize o comando !teste e então confira no console (distro) se apareceu algum nome de player avulso na ultima linha.

Editado Janeiro 31 por Danihcv

GabrielkssG
01 de fevereiro de 2016 às 21:49

Deu esse erro :

 

[Error - TalkAction Interface]
data/talkactions/scripts/teste.lua:onSay
Description:
(LuaInterface::internalGetPlayerInfo) Player not found when requesting player info #18
[Error - TalkAction Interface]
data/talkactions/scripts/teste.lua:onSay
Description:
data/talkactions/scripts/teste.lua:5: attempt to concatenate a boolean value
stack traceback:
data/talkactions/scripts/teste.lua:5: in function 'getPlayerFrags'
data/talkactions/scripts/teste.lua:33: in function <data/talkactions/scripts/teste.lua:28>

up

DanihcvD
01 de fevereiro de 2016 às 22:03

Ok... Vamos tentar isolar o problema...

Troque o seu script do sistema, por esse:
*ou seja, troque o ultimo script que vc me mandou por pm, por esse:

function getPlayerFrags(cid)
local time = os.time()
local times = {today = (time - 86400), week = (time - (7 * 86400))}

local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
if(result:getID() ~= -1) then
repeat
local content = {date = result:getDataInt("date")}
if(content.date > times.today) then
table.insert(contents.day, content)
elseif(content.date > times.week) then
table.insert(contents.week, content)
else
table.insert(contents.month, content)
end
until not result:next()
result:free()
end

local size = {
day = table.maxn(contents.day),
week = table.maxn(contents.week),
month = table.maxn(contents.month)
}
return size.day + size.week + size.month
end

function onLogin(cid)
registerCreatureEvent(cid, "fraglook")
return true
end

function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and thing.uid ~= cid then
doPlayerSetSpecialDescription(thing.uid,'[Frags: '..getPlayerFrags(thing.uid)..']')
return true
elseif thing.uid == cid then
doPlayerSetSpecialDescription(cid,'[Frags: '..getPlayerFrags(cid)..']')
local string = 'You see yourself.'
if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
string = string..' You are '.. getPlayerGroupName(cid) ..'.'
elseif getPlayerVocation(cid) ~= 0 then
string = string..' You are '.. getPlayerVocationName(cid) ..'.'
else
string = string..' You have no vocation.'
end
string = string..getPlayerSpecialDescription(cid)..''

if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
end

if getPlayerGuildId(cid) > 0 then
string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
end

if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
string = string..'nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
string = string..'nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
end

if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
string = string..'nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
return false
end



local online = getOnlinePlayers()
		local winner = online[1]

		for l, pid in pairs(online) do 
			if getPlayerFrags(online[l]) > getPlayerFrags(winner) then 
				local winner = online[l]
			end
		end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, tostring(getCreatureName(winner)))

return true
end

Editado Fevereiro 1 por Danihcv

GabrielkssG
02 de fevereiro de 2016 às 18:00

continua dando o mesmo erro.


up

 

CaronteC
02 de fevereiro de 2016 às 22:54
 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " 

Tá dando boolean

GabrielkssG
05 de fevereiro de 2016 às 15:26

Poderia resolver o problema por favor ? Não entendo... =/


up


alguém plz


Alguém por favor poderia ajudar ?

SkullsS
05 de fevereiro de 2016 às 23:48
 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " 

Tá dando boolean

 

Acredito que o boolean seja ou no getPlayerGUID(cid) ou na hora de selecionar da tabela (se o player me questão não tiver nada no campo requisitado), não?