UpInSmoke
Supreme Ruler
- Joined
- Nov 16, 2008
- Messages
- 303
- Reaction score
- 21
So since nobody was replying to my thread requesting it i tried to make it.
Seriously i suck at NPCs ...
my server will run but if i have this NPC anywhere on the map it crashes after like 10 seconds lol
heres the script:
Somebody want to fix this for me please? would be very greatful.
this is what im trying to do if youre having troubles understanding: http://otland.net/f132/addon-npc-9-8-a-194864/
Seriously i suck at NPCs ...
my server will run but if i have this NPC anywhere on the map it crashes after like 10 seconds lol
heres the script:
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
function creatureSayCallback(cid, type, msg)
local t = {
{"hunter", 129,137, 18900},
}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and not npcHandler:isFocused(cid) then
npcHandler:say("Hello, "..getCreatureName(cid).."! Would you like to buy some {addons}?", cid)
return true
end
if(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "addon") then
selfSay('I will give you both addons for any {outfit} you want for.... hm.. 1000 gold coins and 10 wolf paws.', cid)
elseif msgcontains(msg, "outfit") then
selfSay('Which {outfit} would you like? {hunter}, {mage}, {knight}, {Nobleman}, {Summoner}, {Warrior}, {Barbarian}, {Druid}, {Wizard}, {Oriental}, {Pirate}, {Assasin}, {Beggar}, {Shaman}, {Norseman}, {Knightmare}, {Jester}, {Brotherhood}, {Demonhunter}, {Yalaharian}, {Warmaster}, {Wayfarer}, {Afflicted}, {Elementalist}, {Deepling}, {Insectoid}, {Entrepreneur}, {Crystal Warlord}, {Soil Guardian}, {Demon}?', cid)
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
selfSay("Farewell, " .. getCreatureName(cid) .. "!", cid, TRUE)
npcHandler:releaseFocus(cid)
end
----------------------
for i = 1, #t do
if msgcontains(msg, t[i][1]) then
selfSay('1000 gold coins and 10 wolf paws for the '..t[i][1]..' addons sound good to you?', cid)
if msgcontains(msg, "yes") then
if t[i][4] == -1 then
if doPlayerRemoveItem(cid,5897,10) and doPlayerRemoveMoney(cid, 1000) then
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddOutfit(cid, t[i][2], 1)
doPlayerAddOutfit(cid, t[i][3], 1)
doPlayerAddOutfit(cid, t[i][2], 2)
doPlayerAddOutfit(cid, t[i][3], 2)
setPlayerStorageValue(cid, t[i][4] ,1)
npcHandler:say('Here you are, enjoy your brand new addons!', cid)
else
npcHandler:say('You do not have the required items for these addons.', cid)
end
else
npcHandler:say('You already have these addons!', cid)
end
else
npcHandler:say('Okay. Maybe some other time then.', cid)
end
else
npcHandler:say('There is no such outfit.', cid)
end
end
-------------------------
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Well, bye then.")
Somebody want to fix this for me please? would be very greatful.
this is what im trying to do if youre having troubles understanding: http://otland.net/f132/addon-npc-9-8-a-194864/