Jump to content

[Pedido] Script Comando !frags


Leoxtibia

Recommended Posts

Andei procurando pelo xtibia e outros fórums que muita, mas muita gente procura por um script de frags funcionando, então creio que se alguém tiver/fizer um, irá ajudar muita gente (os que achei no xtibia, ou não funcionavam ou era esse que estou colocando). Primeiramente, eu tenho o seguinte script:

 

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

    doPlayerPopupFYI(cid, 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

 

Esse script funciona quase que perfeitamente (funciona para os players que tem um pequeno ou nenhum frags e não estão white/red/black skull), ele tem os seguintes problemas:

-Depois de uma determinada quantidade de frags que o player alcança, o comando !frags para de funcionar.

- Assim que um player pega red/black skull e depois esse skull sai, é só o player matar mais alguém que volta a ser red/black skull, ou seja, os frags não ZERAM.

 

Então, se possível, gostaria de um script que não apresentasse esses erros ou caso o erro não esteja no script, que digam qual é/são. Desde já, agradeço!

Link to comment
Share on other sites

Olha tenho dois tipos de contador de FRAGS, vou postar esse.

se acaso não funcionar, fala comigo que eu posto o otro!

 

 

Vá em Data/Talkations/script e crie um arquivo Frags.Lua e adicione isso dentro, [Obs: control+c clica control+ v ]

 

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

 

doPlayerPopupFYI(cid, 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

 

 

 

Após faser a etapa , pule para segunda, e vá em Data/Talkactions/Talkactions.xml abra e adicione essa Tag!

 

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

 

 

Duvidas msn: waguiinrodriguez@hotmail.com msn.png

 

 

 

MEREÇO UM +REP??

post-324120-0-17434700-1330088700_thumb.jpg

Link to comment
Share on other sites

×
×
  • Create New...