Ir para conteúdo

Reset System[stages]


Skymagnum

Posts Recomendados

Olá galerinha, vim trazer um reset system com stages/ou sem, você escolhe, é fácil configurar ele.

 

/data/talkactions/scripts/resetSystem.lua adicione o seguinte conteúdo dentro:

 

local _MAIN_CONFIG = {
toLevel = 8,
teleport = true
needProtection = true,
needBattle = true,
stages = false,
resetMainLevel = 5000,
maxResets = 20
}

local _RESETS_CONFIG = { -- only if you use stages mode
[{1, 5}] = {level = 5000},
[{6, 8}] = {level = 6500}
}

local function getResets(uid)
local resets = getPlayerStorageValue(uid, 83921)
return resets < 0 and 0 or resets
end

function onSay(cid, words, param, channel)

local M = _MAIN_CONFIG
local level = nil --don't change

if(M.needProtection and not getTileInfo(getThingPos(cid)).protection) then
	return doPlayerSendCancel(cid, "Só pode usar em protection zone.")
elseif(M.needBattle and getCreatureCondition(cid, CONDITION_INFIGHT)) then
	return doPlayerSendCancel(cid, "Só pode usar se não estiver com battle.")
end

if(M.stages) then
	for resets, info in pairs(_RESETS_CONFIG) do
		if(getResets(cid) >= resets[1] and getResets(cid) <= resets[2]) then
			level = info.level
		end
	end
else
	level = M.resetMainLevel
end

local toPosition = M.teleport and getTownTemplePosition(getPlayerTown(cid)) or getThingPos(cid)

if(getResets(cid) < M.maxResets) then
	if(getPlayerLevel(cid) >= level) then
		setPlayerStorageValue(cid, 83921, getResets(cid) + 1)
		doPlayerSendTextMessage(cid, 27, "Agora você tem " .. getResets(cid) .. " resets.")
		doTeleportThing(cid, toPosition, false)
		db.executeQuery("UPDATE `players` SET `level` = " .. M.toLevel .. ", `experience` = " .. getExperienceForLevel(M.toLevel) .. " WHERE `id` = " .. getPlayerGUID(cid))
		addEvent(doRemoveCreature, 2000, cid)
	else
		doPlayerSendTextMessage(cid, 27, "Você não tem o level necessário[" .. level .. "].")
	end
else
	doPlayerSendTextMessage(cid, 27, "Você já atingiu o máximo de resets permitidos.")
end

return true
end

 

 

TAG:

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


 

/data/creaturescripts/scripts/resetRank.lua:

 

function getPlayerNameByGUID2(n)

local c = db.getResult("SELECT `name` FROM `players` WHERE `id` = "..n..";")

if c:getID() == -1 then
  return "SQL_ERROR["..n.."]"
end
return c:getDataString("name")
end

function onSay(cid, words, param)

if (param == "") then
  doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Você possui "..getPlayerStorageValue(cid, 83921).." resets.")
  return TRUE
end

if (param == "rank") then

local max = 50
local letters_to_next = 50

local name_now
local name = "Highscore for Resets\n"
local rkn = 0
local no_break = 0

name = name.."\n"
name = name.."Rank. Resets | Nome do Jogador\n"
local v = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = 83921 ORDER BY cast(value as INTEGER) DESC;")
local kk = 0

repeat
  if kk == max or v:getID() == -1 then
break
end

kk = kk+1
name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("player_id")))
space = ""

for i=1, letters_to_next-l do
space = space.." "
end

if name_now == nil then
  name_now = 'sql error['..v:getDataInt("player_id")..']'
end

name = name..kk..". "..v:getDataInt("value").." | "..name_now..space.." \n"
until v:next() == false

if name ~= "Highscore\n" then
  doPlayerPopupFYI(cid, name)
end

return TRUE

else

doPlayerSendCancel(cid, "Command valid: !resets, !resets rank.")
return TRUE
end

end

 

 

TAG:

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


 

/data/creaturescripts/scripts/resetLook.lua:

 

local function getResets(uid)
local resets = getPlayerStorageValue(uid, 83921)
return resets < 0 and 0 or resets
end

function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n[Resets: " .. getResets(thing.uid) .."]")
end
return true
end

 

 

TAG:

<event type="look" name="showResets" event="script" value="resetLook.lua"/>

 

login.lua:

registerCreatureEvent(cid, "showResets")


 

Qualquer erro postei ai galerinha galerosa.

 

O rank é um script antigo do Jhon922 para o Simple Reputation System dele, eu só peguei e modifiquei as mensagens e storages.

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

  • 2 weeks later...
×
×
  • Criar Novo...