What's new

NPC Mounty czasowe!

Status
Not open for further replies.

OldTejdi

Senior User
Joined
Jul 18, 2008
Messages
537
Reaction score
49
Skrypt nie jest m?j.
83lCd.png

yF9Uu.png


Stw?rz nowy MOD i wklej:

[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)
end
end
return true
end]]></globalevent>
</mod>
[/lua]

Data/Npc

[xml]
<?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>[/xml]

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:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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())
[/lua]​
 
Status
Not open for further replies.
Top