Critico
Sexy
- Joined
- Mar 25, 2010
- Messages
- 370
- Reaction score
- 178
Credits: Vodkart
Tested version: 9.1
Description: It is a simple NPC whose function is to rent some mounts for a time, days to be exact.
Mods:
AluguelMount.xml
ps: Check two things in mods
first:
if the function that checks if you have the mount is 'canPlayerRideMount' or 'getPlayerMount' case is 'getPlayerMount' exchange:
canPlayerRideMount(cid, ret.mountid) by: getPlayerMount(cid, ret.mountid)
second:
the time interval in the globalevents tag, in my server was in mile seconds:
interval = "60000" - if your server not is in mile seconds, replace 60000 by 60.
Data/Npc
Peach.xml
Data/Npc/Script
aluguelmounts.lua
Configuration:
Aluguel_mounts = {
["war horse"] = {price = 10000, days = 2, mountid = 17, level = 10, premium = false, storage = 500561},
["fire war horse"] = {price = 30000, days = 1, mountid = 23, level = 20, premium = false, storage = 500562},
["sandstone scorpion"] = {price = 50000, days = 1, mountid = 21, level = 30, premium = true, storage = 500563}
}
within the [""] is the name of the mount, lowercased the name of the mount
price = 10000 - price it will cost to rent
days = 2 - how many days he will rent the mount
mountid = 17 - is the id of the mount, you look mounts.xml
level = 10 - level you need to rent a mount
premium = false - if need be premium, true or false.
storage = 500561 - storage you put a random, ex: 500564 note: can not retry the storage
Tested version: 9.1
Description: It is a simple NPC whose function is to rent some mounts for a time, days to be exact.


Mods:
AluguelMount.xml
LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Aluguel Mounts" version="1.0" author="Vodkart" contact="otland.com" enabled="yes">
<config name="aluguel_func"><![CDATA[
Aluguel_mounts = {
["war horse"] = {price = 10000, days = 2, mountid = 17, level = 10, premium = false, storage = 500561},
["fire war horse"] = {price = 30000, days = 1, mountid = 23, level = 20, premium = false, storage = 500562},
["sandstone scorpion"] = {price = 50000, days = 1, mountid = 21, level = 30, premium = true, storage = 500563}
}
function doRemovePlayerMount(cid, mountId) -- vodka
doPlayerRemoveMount(cid, mountId)
return doCreatureChangeOutfit(cid,{lookType = getCreatureOutfit(cid).lookType, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = getCreatureOutfit(cid).lookAddons})
end
function CheckRentMount(cid)
for var, ret in pairs(Aluguel_mounts) do
if canPlayerRideMount(cid, ret.mountid) and getPlayerStorageValue(cid, ret.storage) ~= -1 and getPlayerStorageValue(cid, ret.storage) <= os.time() then
doRemovePlayerMount(cid, ret.mountid)
doPlayerSendTextMessage(cid,18,"The time of your mount "..var.." has ended, to get it again back to the NPC.")
end
end
end
]]></config>
<globalevent name="CheckMount" interval="60000" event="script"><![CDATA[
domodlib('aluguel_func')
function onThink(interval, lastExecution)
local on = getPlayersOnline()
if #on > 0 then
for i = 1, #on do
CheckRentMount(on[i])
end
end
return true
end]]></globalevent>
</mod>
ps: Check two things in mods
first:
if the function that checks if you have the mount is 'canPlayerRideMount' or 'getPlayerMount' case is 'getPlayerMount' exchange:
canPlayerRideMount(cid, ret.mountid) by: getPlayerMount(cid, ret.mountid)
second:
the time interval in the globalevents tag, in my server was in mile seconds:
interval = "60000" - if your server not is in mile seconds, replace 60000 by 60.
Data/Npc
Peach.xml
Code:
<?xml version="1.0"?>
<npc name="Peach" script="data/npc/scripts/aluguelmounts.lua" walkinterval="50000" floorchange="0">
<health now="1000" max="1000"/>
<look type="130" head="0" body="114" legs="114" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. You want to {rent} a {mount}?"/>
</parameters>
</npc>
Data/Npc/Script
aluguelmounts.lua
LUA:
domodlib('aluguel_func')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local msg = string.lower(msg)
if isInArray({'aluguel','alugar', 'rent', 'mounts', 'mount'}, msg) then
npcHandler:say("You can buy {war horse}, {fire war horse} and {sandstone scorpion}!", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if Aluguel_mounts[msg] then
if Aluguel_mounts[msg].premium == true and not isPremium(cid) then
npcHandler:say('You need to be premium to rent this mount.', cid) return true
elseif getPlayerLevel(cid) < Aluguel_mounts[msg].level then
npcHandler:say('You need level ' .. Aluguel_mounts[msg].level .. ' or more to rent this mount.', cid) return true
elseif getPlayerStorageValue(cid, Aluguel_mounts[msg].storage) >= os.time() then
npcHandler:say('you already have rented this mount!', cid) return true
end
name,price,stor,days,mountid = msg,Aluguel_mounts[msg].price,Aluguel_mounts[msg].storage,Aluguel_mounts[msg].days,Aluguel_mounts[msg].mountid
npcHandler:say('You want to rent the mount '..name..' for '..days..' day'..(days > 1 and 's' or '')..' the price '..price..' gps? {yes}', cid)
talkState[talkUser] = 2
else
npcHandler:say('Sorry, I do not sell this mount.', cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if doPlayerRemoveMoney(cid, price) then
doPlayerAddMount(cid, mountid)
setPlayerStorageValue(cid, stor, os.time()+days*86400)
npcHandler:say('Here is your mount '..name..', it will last until '..os.date("%d %B %Y %X", getPlayerStorageValue(cid,stor))..'.', cid)
else
npcHandler:say('you do not have enough money to rent the mount!', cid)
talkState[talkUser] = 0
end
elseif msg == "no" then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Configuration:
Aluguel_mounts = {
["war horse"] = {price = 10000, days = 2, mountid = 17, level = 10, premium = false, storage = 500561},
["fire war horse"] = {price = 30000, days = 1, mountid = 23, level = 20, premium = false, storage = 500562},
["sandstone scorpion"] = {price = 50000, days = 1, mountid = 21, level = 30, premium = true, storage = 500563}
}
within the [""] is the name of the mount, lowercased the name of the mount
price = 10000 - price it will cost to rent
days = 2 - how many days he will rent the mount
mountid = 17 - is the id of the mount, you look mounts.xml
level = 10 - level you need to rent a mount
premium = false - if need be premium, true or false.
storage = 500561 - storage you put a random, ex: 500564 note: can not retry the storage