Ir para conteúdo

Featured Replies

  • 3 weeks later...
  • Respostas 6
  • Visualizações 1.1k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor
Em 2017-3-22 ás 19:09, Skydangerous disse:

Está  proibido postar em outros fóruns

 

 

Informação:

 

1. Sistema de Alugar montaria via NPC

 1.0. Opções por apenas VIP , PREMIUM E FREE

   1.1.0. Caso opte por VIP (Exemplo) a montaria não aparecerá para os demais jogadores.

 

2. Configurável o tempo, tipo da montaria, level e o preço da montaria.

 2.1. Acabou o tempo automaticamente remove a montaria.

 

3.1 Totalmente limpo e fácil de configuração.

 

Instalação: 

 

LIB: mount_rent.lua

 


MOUNT_H = {
	["war horse"] 			= {price = 10000, hours = 2, mountid = 17, level = 10, vip = false, premium = false, storage = 500561},
	["fire war horse"] 		= {price = 30000, hours = 2, mountid = 23, level = 20, vip = true, premium = false, storage = 500562},
	["sandstone scorpion"] 	= {price = 50000, hours = 1, mountid = 21, level = 10, vip = false, premium = true, storage = 500563}
}

function Player.checkRentMounts(self)

	for name, v in pairs(MOUNT_H) do
		if (self:hasMount(v.mountid)) and (self:getStorageValue(v.storage) ~= -1) and (self:getStorageValue(v.storage) <= os.time()) then
			self:removeMount(v.mountid)	
			
			local outfit = self:getOutfit()
			outfit.lookMount = 0
			self:setOutfit(outfit)

			self:sendTextMessage(MESSAGE_STATUS_WARNING, "The time of your mount ".. name .." has ended.")
			self:setStorageValue(v.storage, -1)
		end
	end		

	return true
end

TAG: dofile('data/lib/mount_rent.lua')

 

CREATURESCRIPT: mount_rent.lua

 


function onLogin(player)
	player:checkRentMounts()
	return true
end

TAG: 


	<event type="login" name="checkmounts" script="mount_rent.lua"/>

 

 

GLOBALEVENTS: mount_rent.lua

 


function onThink(interval, lastExecution)

	for _, player in pairs(Game.getPlayers()) do
		player:checkRentMounts()
	end

	return true
end

TAG: 


	<globalevent name="CheckMount" interval="60000" script="mount_rent.lua"/>	

 

NPC: mount_rent.lua

 


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()						npcHandler:onThink()						end

local keywords = {"aluguel", "alugar", "rent", "mounts", "mount"}




function Player.isVip(self)
	return false
end

npcHandler:addModule(FocusModule:new())

function creatureSayCallback(cid, type_, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	
	local msg = string.lower(msg)
	local player = Player(cid)

	if isInArray(keywords, msg) then
		local str = "You can rent"
		local amount = 0

		for name, v in pairs(MOUNT_H) do
			if not ((v.premium and player:getPremiumDays() < 1) or (v.vip and not player:isVip()) or 
				(player:getLevel() < v.level) or (player:getStorageValue(v.storage) >= os.time())) then
				
				str = str .. " {".. name .. "},"
				amount = amount + 1
			end
		end		

		if amount > 0 then
			npcHandler:say(str:sub(1, #str - 1) .. "!", cid)
			npcHandler.topic[cid] = 1			
		else
			npcHandler:say("You are not allowed to rent any mount.", cid)
		end
	elseif npcHandler.topic[cid] == 1 and MOUNT_H[msg] then
		local mount = MOUNT_H[msg]

		if mount.premium and player:getPremiumDays() < 1 then
			npcHandler:say("You must be premium to rent this mount.", cid)
			return true
		elseif player:getLevel() < mount.level then
			npcHandler:say("You must be, at least, level " .. mount.level .. " to rent this mount.", cid)
			return true
		elseif player:getStorageValue(mount.storage) >= os.time() then
			npcHandler:say("You already have rented this mount!", cid)
			return true
		end

		local str = "You want to rent ".. msg .." for ".. mount.hours .. " hour".. (mount.hours > 1 and "s" or "")

		npcHandler:say(str .. " for ".. mount.price .. " gold pieces?", cid)
		npcHandler.topic[cid] = msg
	elseif type(npcHandler.topic[cid]) == "string" then
		local mount = MOUNT_H[npcHandler.topic[cid]]

		if player:removeMoney(mount.price) then
 			player:addMount(mount.mountid)
			player:setStorageValue(mount.storage, os.time() + mount.hours * 60)
			npcHandler:say("Here is your ".. npcHandler.topic[cid] ..", it will last until ".. os.date("%d %B %Y %X", os.time() + mount.hours * 60) ..".", cid)
		else
			npcHandler:say("Sorry, you do not have enough money to rent the mount!", cid)
		end
		npcHandler.topic[cid] = 0
	elseif msgcontains(msg, "no") then 
		npcHandler:say("Ok then.", cid)
		npcHandler.topic[cid] = 0
	end
	
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

Divirta-se (:
 

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo