Ir para conteúdo
  • 0

Contador de Frags


lugk123

Pergunta

Quero pedir outro script que não está funcionando em meu OT que é um que conta frags (um player mata um outro e no look aumenta um frag, tipo "Lugk123 [Frags:1]").

Esse script não aumenta de frag quando um player mata, mesmo injustamente fica "[Frags:0]

Link para o comentário
Compartilhar em outros sites

9 respostass a esta questão

Posts Recomendados

  • 0

Não da...é como eu disse "Esse script não aumenta de frag quando um player mata, mesmo injustamente fica "[Frags:0]".

Só uma pergunta: precisa executa algo na database ???pois n ta funcionando

Link para o comentário
Compartilhar em outros sites

  • 0

Precisa executar nada na database não. Usa esse fraglook aqui.

 

Vá em Pasta do seu OT/data/creaturescripts/scripts/fraglook.lua, e coloque isso:

 

--Script By Theax ""
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
return true
end

 

Agora, vá em Pasta do seu OT/data/creaturescripts/creaturescripts.xml, e adicione essas tag:

 

<event type="login" name="fraglook_register" event="script" value="fraglook.lua"/>
<event type="look" name="fraglook" event="script" value="fraglook.lua"/>

Editado por ThiagoBjiW
Link para o comentário
Compartilhar em outros sites

  • 0

Precisa executar nada na database não. Usa esse fraglook aqui.

 

Vá em Pasta do seu OT/data/creaturescripts/scripts/fraglook.lua, e coloque isso:

 

--Script By Theax ""
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
return true
end

 

Agora, vá em Pasta do seu OT/data/creaturescripts/creaturescripts.xml, e adicione essas tag:

 

<event type="login" name="fraglook_register" event="script" value="fraglook.lua"/>
<event type="look" name="fraglook" event="script" value="fraglook.lua"/>

Cara, ja disse denovo "Esse script não aumenta de frag quando um player mata, mesmo injustamente fica "[Frags:0]"

Link para o comentário
Compartilhar em outros sites

  • 0

Mas, eu não peguei do tópico. Eu peguei do meu ot, e no meu ot esse script está funcionando perfeitamente!

Ah, malz ae...Vou testar, e se funcionar vo falar editando aqui.

EDIT---

Bom, cara, agora deu esse erro:

[25/03/2013 18:45:14] Error during getDataInt(frags).

Editado por lugk123
Link para o comentário
Compartilhar em outros sites

  • 0

Tenta Esse Aqui Mano :

local config = {

useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),

advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))

}

 

function onSay(cid, words, param, channel)

if(not config.useFragHandler) then

return false

end

 

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 = {

name = result:getDataString("name"),

level = result:getDataInt("level"),

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)

}

if(config.advancedFragList) then

local result = "Frags gained today: " .. size.day .. "."

if(size.day > 0) then

for _, content in ipairs(contents.day) do

result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level

end

 

result = result .. "\n"

end

 

result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."

if(size.week > 0) then

for _, content in ipairs(contents.week) do

result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level

end

 

result = result .. "\n"

end

 

result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."

if(size.month > 0) then

for _, content in ipairs(contents.month) do

result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level

end

 

result = result .. "\n"

end

 

local skullEnd = getPlayerSkullEnd(cid)

if(skullEnd > 0) then

result = result .. "\nSua " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull ira sair em " .. os.date("%d %B %Y %X", skullEnd)

end

 

doPlayerPopupFYI(cid, result)

else

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Limites para sua redskull: 4 por dia, 8 por semana, 16 por mês.")

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")

if(size.day > 0) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "ultimo frag em " .. os.date("%d %B %Y %X", contents.day[1].date) .. " no level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")

end

 

local skullEnd = getPlayerSkullEnd(cid)

if(skullEnd > 0) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "sua " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull ira sair em " .. os.date("%d %B %Y %X", skullEnd))

end

end

 

return true

end

 

 

Ajudei? Rep+

Link para o comentário
Compartilhar em outros sites

  • 0

Consegui solucionar meu problema, bastava fazer isto, caso alguem tenha uma dúvida.

em talkactions>frags.lua

local config = {
useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}
function onSay(cid, words, param, channel)
if(not config.useFragHandler) then
 return false
end
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 = {
   name = result:getDataString("name"),
   level = result:getDataInt("level"),
   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)
}
if(config.advancedFragList) then
 local result = "Frags gained today: " .. size.day .. "."
 if(size.day > 0) then
  for _, content in ipairs(contents.day) do
   result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
  end
  result = result .. "\n"
 end
 result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
 if(size.week > 0) then
  for _, content in ipairs(contents.week) do
   result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
  end
  result = result .. "\n"
 end
 result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
 if(size.month > 0) then
  for _, content in ipairs(contents.month) do
   result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
  end
  result = result .. "\n"
 end
 local skullEnd = getPlayerSkullEnd(cid)
 if(skullEnd > 0) then
  result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
 end
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, result)
else
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
 if(size.day > 0) then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
 end
 local skullEnd = getPlayerSkullEnd(cid)
 if(skullEnd > 0) then
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
 end
end
return true
end

  <talkaction words="!frags" script="frags.lua"/>

e em creaturescripts, segue este tutorial:

http://www.xtibia.com/forum/topic/145118-creatureevent-contagem-de-frags-no-look/

e no config.lua

useBlackSkull = true
useFragHandler = true
advancedFragList = false

/\ tava advancedFragList=true

 

pode mover

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...