• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

NPC Rent Mounts!

Critico

Sexy
Joined
Mar 25, 2010
Messages
360
Best answers
0
Reaction score
165
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
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
 

Wolfenrir

how you remind me?
Joined
Sep 29, 2008
Messages
109
Best answers
0
Reaction score
1
Location
/home?
@Vodkart, perfeito mano. Obrigado por contribuir by Beeki.

Perfect man, thanks for contribute :D
 

Solarium

New Member
Joined
Jul 18, 2009
Messages
30
Best answers
0
Reaction score
0
is there any way this can be changed to just regular scripts without a mod? cause my server doesnt have a mods folder so i cant use mods :(, but i really would love to use the script i think its a great idea
 
OP
Critico

Critico

Sexy
Joined
Mar 25, 2010
Messages
360
Best answers
0
Reaction score
165
is there any way this can be changed to just regular scripts without a mod? cause my server doesnt have a mods folder so i cant use mods :(, but i really would love to use the script i think its a great idea
but has the lib folder on your server?
 

Solarium

New Member
Joined
Jul 18, 2009
Messages
30
Best answers
0
Reaction score
0
yeah i have the lib folders, just not a mods folder
 

Solarium

New Member
Joined
Jul 18, 2009
Messages
30
Best answers
0
Reaction score
0
oh ok i didnt know whats what he meant im sorry thank you :)

- - - Updated - - -

so i just put it in my lib/npcsystem folder?
 
OP
Critico

Critico

Sexy
Joined
Mar 25, 2010
Messages
360
Best answers
0
Reaction score
165
oh ok i didnt know whats what he meant im sorry thank you :)

- - - Updated - - -

so i just put it in my lib/npcsystem folder?
Data/lib

RentMount.lua
Lua:
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

Data/globalevents/script

checkmount.lua
Lua:
function onThink(interval, lastExecution)
local on = getPlayersOnline()
if #on > 0 then
for i = 1, #on do
CheckRentMount(on[i])
end
end
return true
end

Data/Npc/script

aluguelmounts.lua
Lua:
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())
 

Cys9211

Sencor!
Joined
Aug 21, 2008
Messages
83
Best answers
0
Reaction score
2
Location
Poland (Bełchatów)
Help!?

Code:
[13:35:32.407] [Error - LuaInterface::loadFile] data/npc/scripts/aluguelmounts.l
ua:5: function arguments expected near ':'
[13:35:32.408] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scr
ipts/aluguelmounts.lua
[13:35:32.409] data/npc/scripts/aluguelmounts.lua:5: function arguments expected
near ':'
 
Top