Ir para conteúdo

Bonus Exp/Loot System


Skulls

Posts Recomendados

  • Diretor

Tira a linha broadcastMessage(os.time... e testa

Skulls, lembra da adaptação que você fez para mim? eu disse que tinha alguns erros que eu tinha arrumado certo? um deles era dar debug quando eu colocava a tag la no login.lua

 

aparece no console brodcast 179797877 -1 e ninguem consegue entrar vai logar da debug error

 

Tente assim:

 

-- ### CONFIG ###

-- message send to player by script "type" (types you can check in "global.lua")

SHOP_MSG_TYPE = 19

-- time (in seconds) between connections to SQL database by shop script

SQL_interval = 30

-- ### END OF CONFIG ###

SQL_COMUNICATION_INTERVAL = SQL_interval * 1000

function onLogin(cid)

 

-- Bonus Event

local bonusTime = 10*24*60*60

local bonusStorage = 7718

doBroadcastMessage(os.time() .. " " .. getPlayerStorageValue(cid, bonusStorage))

if os.time() - bonusTime < getPlayerStorageValue(cid, bonusStorage) then

local remainingTime = (bonusTime - (os.time()-getPlayerStorageValue(cid, bonusStorage)))/(60*60)

if remainingTime >= 1 then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hours")

else

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hour")

end

registerCreatureEvent(cid, "doubleBonusRegister")

else

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your double bonus is over.")

doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))

setPlayerStorageValue(cid, bonusStorage, -1)

end

 

if(InitShopComunication == 0) then

local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})

InitShopComunication = eventServ

end

registerCreatureEvent(cid, 'advance')

registerCreatureEvent(cid, "PlayerDeath")

registerCreatureEvent(cid, "Ushuriel")

registerCreatureEvent(cid, "Zugurosh")

registerCreatureEvent(cid, "Madareth")

registerCreatureEvent(cid, "Golgordan")

registerCreatureEvent(cid, "Annihilon")

registerCreatureEvent(cid, "Hellgorak")

return TRUE

end

 

function sql_communication(parameters)

local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")

if(result_plr:getID() ~= -1) then

while(true) do

id = tonumber(result_plr:getDataInt("id"))

action = tostring(result_plr:getDataString("action"))

delete = tonumber(result_plr:getDataInt("delete_it"))

cid = getPlayerByName(tostring(result_plr:getDataString("name")))

if isPlayer(cid) == TRUE then

local itemtogive_id = tonumber(result_plr:getDataInt("param1"))

local itemtogive_count = tonumber(result_plr:getDataInt("param2"))

local container_id = tonumber(result_plr:getDataInt("param3"))

local container_count = tonumber(result_plr:getDataInt("param4"))

local add_item_type = tostring(result_plr:getDataString("param5"))

local add_item_name = tostring(result_plr:getDataString("param6"))

local received_item = 0

local full_weight = 0

if add_item_type == 'container' then

container_weight = getItemWeightById(container_id, 1)

if isItemRune(itemtogive_id) == TRUE then

items_weight = container_count * getItemWeightById(itemtogive_id, 1)

else

items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)

end

full_weight = items_weight + container_weight

else

full_weight = getItemWeightById(itemtogive_id, itemtogive_count)

if isItemRune(itemtogive_id) == TRUE then

full_weight = getItemWeightById(itemtogive_id, 1)

else

full_weight = getItemWeightById(itemtogive_id, itemtogive_count)

end

end

local free_cap = getPlayerFreeCap(cid)

if full_weight <= free_cap then

if add_item_type == 'container' then

local new_container = doCreateItemEx(container_id, 1)

local iter = 0

while iter ~= container_count do

doAddContainerItem(new_container, itemtogive_id, itemtogive_count)

iter = iter + 1

end

received_item = doPlayerAddItemEx(cid, new_container)

else

local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)

received_item = doPlayerAddItemEx(cid, new_item)

end

if received_item == RETURNVALUE_NOERROR then

doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')

db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")

db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")

else

doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')

end

else

doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')

end

end

if not(result_plr:next()) then

break

end

end

result_plr:free()

end

local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)

end

function checkRecord()

local onlinePlayers = getWorldCreatures(0)

if(onlinePlayers > getMaxPlayers()) then

broadcastMessageEx(MESSAGE_EVENT_ADVANCE, 'New record: ' .. onlinePlayers .. (onlinePlayers > 1 and ' players' or ' player').. ' are logged in.')

local save = assert(io.open('record.ini', "wb"))

local data = save:read("*number")

save:write(onlinePlayers)

save:close()

end

end

 

function getMaxPlayers()

 

local file = assert(io.open('record.ini', "rb"))

local t = file:read("*number")

file:close()

 

return (t == nil and 0 or t)

end

 

Link para o comentário
Compartilhar em outros sites

  • 2 months later...
  • 9 months later...
  • 3 years later...
Em 13/03/2016 em 22:02, Skulls disse:

Fala galera, tudo bem?

 

Bom, estou trazendo aqui um sisteminha de double exp e double loot system que fiz sob encomenda só que acabaram fazendo por conta própria e desistindo de comprar o que me encomendaram, então estou divulgando aqui para vocês o sistema completo já que não tem mais nenhum termo de privacidade e é um sisteminha legal de se usar para diversas coisas (quests, itens especiais, etc).

 

O nome é bem auto-explicativo, o sistema aumenta a rate de exp e loot daquele cidadão por um período X de tempo.

 

Scripts:

 

 

  Ocultar conteúdo

 



--[[Action que ativa o double bonus ao usar o item]]--
-- Tag: Colocar em action.xml
<action itemid="ID_DO_ITEM" script="doubleExpAndLoot.lua"/>
 
-- Criar arquivo em actions/scripts/ chamado doubleExpAndLoot.lua e colocar:
local storage = 7718
local bonusExp = 2 -- VOCÊ DEVE EDITAR AQUI PARA O BONUS EXP QUE DESEJA
function onUse(cid, item, frompos, item2, topos)
  if not isPlayer(cid) then return false end
  if (getPlayerStorageValue(cid, storage) == -1) then
    doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus started.")
    doPlayerSetRate(cid, SKILL__LEVEL, bonusExp*getExperienceStage(getPlayerLevel(cid)))
    registerCreatureEvent(cid, "doubleBonusRegister")
    setPlayerStorageValue(cid, storage, os.time())
    doBroadcastMessage(getPlayerStorageValue(cid, storage))
  else
    setPlayerStorageValue(cid, storage, -1)
    doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "You can only use one bonus per time.")
  end
end
 
 
----------------------------------------------------------------------------
 
 
--[[Creature Script que registra o double bonus sempre que ataca uma criatura]]--
-- Tag: Colocar em creaturescripts.xml
<event type="combat" name="doubleBonusRegister" event="script" value="doubleBonusRegister.lua"/>
 
-- Criar arquivo em creaturescripts/scripts/ chamado doubleBonusRegister.lua e colocar:
local storage = 7718
local bonusTime = 10*24*60*60
 
function registerDoubleBonus (cid, target)
  if getPlayerStorageValue(cid, storage) == -1 then return true end
  if os.time() - bonusTime >= getPlayerStorageValue(cid, storage) then
    doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
    doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))
    unregisterCreatureEvent(cid, "doubleBonusRegister")
    setPlayerStorageValue(cid, storage, -1)
    return true
  end
  if isMonster(target) then
    registerCreatureEvent(target, "doubleBonus")
  end
  return true
 
end
 
function onCombat(cid, target)
  registerDoubleBonus (cid, target)
  return true
end
 
 
----------------------------------------------------------------------------
 
 
--[[Creature Script que executa o double bonus sempre que a criatura registrada morre]]--
-- Tag: Colocar em creaturescripts.xml
<event type="death" name="doubleBonus" event="script" value="doubleBonus.lua"/>
 
-- Criar arquivo em creaturescripts/scripts/ chamado doubleBonus.lua e colocar:
local storage = 7718
local bonusTime = 10*24*60*60
local serverDropRate = 1000 -- VOCÊ DEVE EDITAR AQUI PARA O DROP RATE DO SEU SERVIDOR
local bonusLoot = 2 -- VOCÊ DEVE EDITAR AQUI PARA O BONUS LOOT QUE DESEJA
local bp_id = 1987
 
function bonusCreatureLoot(pos, monsterName)
  local corpse = getTileThingByPos(pos)
 
  if not isCorpse(corpse.uid) then return false end
  doAddContainerItem(corpse.uid, 1988, 1)
 
  local bp = getContainerItem(corpse.uid, getContainerItem(corpse.uid, getContainerSize(corpse.uid)))
 
  local lootList = getMonsterLootList(monsterName)
  for _, loot in pairs(lootList) do
    local randomizedChance = math.random (1, 100000)
    if randomizedChance <= bonusLoot * loot.chance * serverDropRate then
      doAddContainerItem(bp.uid, loot.id, loot.countmax and math.random(1,loot.countmax) or 1)
    end
  end
end
 
function onDeath(cid, corpse, deathList)
  local killer = #deathList > 1 and deathList[2] or deathList[1]
  if not isPlayer(killer) then return true end
  if not isMonster(cid) then return true end
  if getPlayerStorageValue(killer, storage) == -1 then return true end
  if os.time() - bonusTime >= getPlayerStorageValue(killer, storage) then
    doPlayerSendTextMessage(killer, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
    doPlayerSetRate(killer, SKILL__LEVEL, getExperienceStage(getPlayerLevel(killer)))
    unregisterCreatureEvent(killer, "doubleBonusRegister")
    unregisterCreatureEvent(cid, "bonusRegister")
    setPlayerStorageValue(killer, storage, -1)
    return true
  end
 
  if not isContainer(corpse.uid) then return true end
  addEvent(bonusCreatureLoot, 100, getCreaturePosition(cid), getCreatureName(cid))
 
  return true
end
 
 
 
-- colocar dentro de creaturescripts/scripts/login.lua colocar as seguintes linhas de código (dentro da função onLogin fora de qualquer if ou iteração):
 
local bonusTime = 10*24*60*60
local bonusStorage = 7718
doBroadcastMessage(os.time() .. " " .. getPlayerStorageValue(cid, bonusStorage))
if os.time() - bonusTime < getPlayerStorageValue(cid, bonusStorage) then
    local remainingTime = (bonusTime - (os.time()-getPlayerStorageValue(cid, bonusStorage)))/(60*60)
    if remainingTime >= 1 then
        doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hours")
    else
        doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus re-started. You have: less than " .. math.ceil(remainingTime) .. " hour")
    end
    registerCreatureEvent(cid, "doubleBonusRegister")
else
    doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_SAY, "Your double bonus is over.")
    doPlayerSetRate(cid, SKILL__LEVEL, getExperienceStage(getPlayerLevel(cid)))
    setPlayerStorageValue(cid, bonusStorage, -1)
end 

 

 

http://pastebin.com/Wc9ZL8Km

 

É bastante auto-explicativo o código acima, pois já coloquei no pastebin com os devidos comentários e com os passos a serem seguidos. Leiam tudo pois são 3 arquivos e 1 modificação no login.lua.

 

A forma como está feita ali é um item (a ser definido por você na tag) que você clica e habilita o bonus ao player. A rate de exp e loot são customizáveis tal qual o tempo de duração do bônus.

 

Espero que gostem.

Abraços,

 

 

[07/05/2020 21:26:46] > Loading Doble Exp.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/Doble Exp.xml
[07/05/2020 21:26:46] Line: 1, Info: Start tag expected, '<' not found


[07/05/2020 21:26:46]  failed!

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...