zaneria hoster
Monte :)
- Joined
- Oct 20, 2010
- Messages
- 321
- Reaction score
- 5
rashid.lua script:
in console i have this:
How Can I Fix This?
PHP:
local RASHID_STORAGE_KEY = 1234
local RASHID_STORAGE_TIME = 1235
local RASHID_TIME = 2*3600 -- ?h*3600sek
local RASHID_STORAGE_SPAM = 1236
local RASHID_SPAM = 16 -- how many times can to spam
local SPAM_PRICE = 30000 -- 3cc
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
function mission(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
local CZAS = getPlayerStorageValue(cid, RASHID_STORAGE_TIME)
local KEY = getPlayerStorageValue(cid, RASHID_STORAGE_KEY)
local SPAM = getPlayerStorageValue(cid, RASHID_STORAGE_SPAM)
local poz_m = math.floor((RASHID_TIME - (os.time() - CZAS))/60)
if ((os.time() - CZAS) <= RASHID_TIME) then
npcHandler:say("I told you. I don\'t have time now. Remember! Please come to me for " .. poz_m .. "min again!", cid)
npcHandler:resetNpc()
return false
elseif SPAM >= RASHID_SPAM then
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, -1)
npcHandler:say('Spammer?! Aha! Now you have to pay ' .. SPAM_PRICE .. 'gold. Do you have enough?', cid)
elseif KEY == 7 then
npcHandler:say('You have already completed my mission. Thank you for that!', cid)
-- Sunday
elseif KEY == 6 then
npcHandler:say('Ah, right. <ahem> I hereby declare you - one of my recognised traders! Feel free to offer me your wares!', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 7)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
npcHandler:resetNpc()
-- Saturday
elseif KEY == 16 then
npcHandler:say('Have you brought me a gold fish?', cid)
elseif KEY == 5 then
npcHandler:say('So, my friend, are you willing to proceed to the next mission to become a recognised trader?', cid)
-- Friday
elseif KEY == 15 then
npcHandler:say('Have you brought a cheap but good crimson sword?', cid)
elseif KEY == 4 then
npcHandler:say('So, my friend, are you willing to proceed to the next mission to become a recognised trader?', cid)
-- Thursday
elseif KEY == 14 then
npcHandler:say('Have you brought the vase?', cid)
elseif KEY == 3 then
npcHandler:say('So, my friend, are you willing to proceed to the next mission to become a recognised trader?', cid)
-- Wednesday
elseif KEY == 13 then
npcHandler:say('Have you brought the cheese?', cid)
elseif KEY == 2 then
npcHandler:say('So, my friend, are you willing to proceed to the next mission to become a recognised trader?', cid)
-- Tuesday
elseif KEY == 12 then
npcHandler:say('Did you bring me the package?', cid)
elseif KEY == 1 then
npcHandler:say('So, my friend, are you willing to proceed to the next mission to become a recognised trader?', cid)
-- Monday
elseif KEY == 11 then
npcHandler:say('Have you managed to obtain a rare deer trophy for my customer?', cid)
else
npcHandler:say('Well, you could attempt the mission to become a recognised trader, but it requires a lot of travelling. Are you willing to try?', cid)
end
return true
end
function acceptFirst(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
local KEY = getPlayerStorageValue(cid, RASHID_STORAGE_KEY)
local SPAM = getPlayerStorageValue(cid, RASHID_STORAGE_SPAM)
if SPAM >= RASHID_SPAM then
if getPlayerMoney(cid) >= SPAM_PRICE then
if doPlayerRemoveMoney(cid, SPAM_PRICE) then
npcHandler:say('Ok. Now you can do {mission}.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
npcHandler:resetNpc()
return true
end
end
npcHandler:say('You do not have money!', cid)
npcHandler:resetNpc()
return false
-- Saturday
elseif KEY == 16 then
if getPlayerItemCount(cid,8766) >= 1 then
doPlayerTakeItem(cid,8766, 1)
npcHandler:say('Thank you!! Ah, this makes my day! I\'ll take the rest of the day off to get to know this little guy. Come see me tomorrow, if you like.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 6) -- teraz do Sunday
else
npcHandler:say('You do not have those items!', cid)
end
npcHandler:resetNpc()
elseif KEY == 5 then
npcHandler:say('There is just one little favour that I would ask from you... something personal, actually, forgive my boldness. ...\nI have always dreamed to have a small pet, one that I could take with me and which wouldn\'t cause problems. ...\nCould you - just maybe - bring me a small goldfish in a bowl? I know that you would be able to get one, wouldn\'t you?', cid)
-- Friday
elseif KEY == 15 then
if getPlayerItemCount(cid,8209) >= 1 then
doPlayerTakeItem(cid,8209, 1)
npcHandler:say('Ha! You are clever indeed, well done! I\'ll take this from you. Come see me tomorrow, I think we two might get into business after all.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 5) -- teraz do Saturday
else
npcHandler:say('You do not have those items!', cid)
end
npcHandler:resetNpc()
elseif KEY == 4 then
npcHandler:say('Dwarves are said to be the most stubborn of all traders. Travel to Kazordoon and try to get the smith Uzgod to sell a crimson sword to you. ...\nOf course, it has to be cheap. Don\'t come back with anything more expensive than 400 gold. ...\nAnd the quality must not suffer, of course! Everything clear and understood?', cid)
-- Thursday
elseif KEY == 14 then
if getPlayerItemCount(cid,7582) >= 1 then
doPlayerTakeItem(cid,7582, 1)
npcHandler:say('I\'m surprised that you managed to bring this vase without a single crack. That was what I needed to know, thank you.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 4) -- teraz do Friday
else
npcHandler:say('You do not have those items!', cid)
end
npcHandler:resetNpc()
elseif KEY == 3 then
npcHandler:say('Well, that\'s good to hear. From you as my trader and deliveryman, I expect more than bringing stinky cheese. ...\nI wonder if you are able to deliver goods so fragile they almost break when looked at. ...\nI have ordered a special elven vase from Briasol in Ab\'Dendriel. Get it from him and don\'t even touch it, just bring it to me while I\'m in Ankrahmun. Everything clear and understood?', cid)
-- Wednesday
elseif KEY == 13 then
if getPlayerItemCount(cid,8112) >= 1 then
doPlayerTakeItem(cid,8112, 1)
npcHandler:say('Mmmhh, the lovely odeur of scarab cheese! I really can\'t understand why most people can\'t stand it. Thanks, well done!', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 3) -- teraz do Thursday
else
npcHandler:say('You do not have those items!', cid)
end
npcHandler:resetNpc()
elseif KEY == 2 then
npcHandler:say('You also need to be fast and deliver wares in time. I have ordered a very special cheese wheel made from Darashian milk. ...\nUnfortunately, the high temperature in the desert makes it rot really fast, so it must not stay in the sun for too long. ...\nI\'m also afraid that you might not be able to use ships because of the smell of the cheese. ...\nPlease get the cheese from Miraia and bring it to me while I\'m in Port Hope. Everything clear and understood?', cid)
-- Tuesday
elseif KEY == 12 then
if getPlayerItemCount(cid,7503) >= 1 then
doPlayerTakeItem(cid,7503, 1)
npcHandler:say('Great. Just place it over there - yes, thanks, that\'s it. Come see me another day, I\'ll be busy for a while now.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 2) -- teraz do Wednesday
else
npcHandler:say('You do not have those items!', cid)
end
npcHandler:resetNpc()
elseif KEY == 1 then
npcHandler:say('Alright, that\'s good to hear. From you as my trader and deliveryman, I expect more than finding rare items. ...\nYou also need to be able to transport heavy wares, weaklings won\'t get far here. I have ordered a special package from Edron. ...\nPick it up from {Willard} and bring it back to me while I\'m in {Liberty Bay}. Everything clear and understood?', cid)
-- Monday
elseif KEY == 11 then
if getPlayerItemCount(cid,7397) >= 1 then
doPlayerTakeItem(cid,7397, 1)
npcHandler:say('Well done! I\'ll take that from you. <snags it> Come see me another day, I\'ll be busy for a while now.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 1) -- teraz do Tuesday
else
npcHandler:say('You do not have those items!', cid)
end
npcHandler:resetNpc()
else
npcHandler:say('First, I\'d like to see if you can dig up rare wares. Something like a ... {mastermind shield}! ...\nHaha, just kidding, fooled you there, didn\'t I? Always control your nerves, that\'s quite important during bargaining. ...\nOkay, all I want from you is one of these rare deer trophies. I have a customer here in Svargrond who ordered one, so I\'d like you to deliver it tome while I\'m in Svargrond. ...\nEverything clear and understood?', cid)
end
return true
end
function acceptSecond(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
local KEY = getPlayerStorageValue(cid, RASHID_STORAGE_KEY)
-- Saturday
if KEY == 5 then
npcHandler:say('Thanks so much! I\'ll be waiting eagerly for your return then.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 16)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
-- Friday
elseif KEY == 4 then
npcHandler:say('Okay, I\'m curious how you will do with Uzgod. Good luck!', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 15)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
-- Thursday
elseif KEY == 3 then
npcHandler:say('Okay, then please find Briasol in Ab\'Dendriel and ask for a {fine vase}.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 14)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
-- Wednesday
elseif KEY == 2 then
npcHandler:say('Okay, then please find Miraia in Darashia and ask her about the {scarab cheese}.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 13)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
-- Tuesday
elseif KEY == 1 then
npcHandler:say('Fine. Then off you go, just ask {Willard} about the {package for Rashid}.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 12)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
-- Monday
else
npcHandler:say('Fine. Then get a hold of that {deer trophy} and bring it to me while I\'m in Svargrond. Just ask me about your mission.', cid)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, 11)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, -1)
npcHandler:resetNpc()
end
return true
end
function decline(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
npcHandler:say('Oh well, maybe some other time then.', cid)
npcHandler:resetNpc()
return true
end
local mission = keywordHandler:addKeyword({'mission'}, mission)
local first = mission:addChildKeyword({'yes'}, acceptFirst)
first:addChildKeyword({'yes'}, acceptSecond)
first:addChildKeyword({'no'}, decline)
mission:addChildKeyword({'no'}, decline)
function rashidSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
local MISJA = getPlayerStorageValue(cid, RASHID_STORAGE_KEY)
local CZAS = getPlayerStorageValue(cid, RASHID_STORAGE_TIME)
local SPAM = getPlayerStorageValue(cid, RASHID_STORAGE_SPAM)
local poz_m = math.floor((RASHID_TIME - (os.time() - CZAS))/60)
if (MISJA ~= 7) then
if CZAS >= os.time() then
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, os.time())
npcHandler:say("Sorry. I don\'t have time now. Please come to me for " .. poz_m .. "min again!", cid)
return false
elseif SPAM == (RASHID_SPAM - 2) then
npcHandler:say("Continue spamming. Then you lose all your missions!!! Repurchase is a very costly.", cid)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, SPAM + 1)
return false
elseif SPAM == (RASHID_SPAM - 1) then
npcHandler:say("OK exaggerated, All the missions you have to start over. And pay".. SPAM_PRICE .."GOLD!", cid)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, RASHID_SPAM)
setPlayerStorageValue(cid, RASHID_STORAGE_KEY, -1)
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, -1)
npcHandler:resetNpc()
return false
elseif (((os.time() - CZAS)) < RASHID_TIME) and (MISJA ~= 7) then
if CZAS < (os.time() - 300) then
setPlayerStorageValue(cid, RASHID_STORAGE_TIME, CZAS + 120)
end
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, SPAM + 1)
npcHandler:say("I told you. I don\'t have time now. Please come to me for " .. poz_m .. "min again! Remember it!", cid)
npcHandler:resetNpc()
return false
else
npcHandler:say("Oh, no, no! You need to do {mission}!!!", cid)
setPlayerStorageValue(cid, RASHID_STORAGE_SPAM, SPAM + 1)
npcHandler:resetNpc()
return false
end
end
return true
end
function onTradeRequest(cid)
return getPlayerStorageValue(cid, RASHID_STORAGE_SPAM) <= RASHID_SPAM
end
npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_ONBUY, rashidBuy)
npcHandler:setCallback(CALLBACK_ONSELL, rashidSell)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
in console i have this:
PHP:
[Error - NpcScript Interface]
data/npc/scripts/rashid.lua
Description:
data/npc/lib/npcsyste/npchandler.lua:261:table index is nil
[Warning - NpcEvent] Cannot load script data/npc/scripts/rashid.lua
How Can I Fix This?