- Joined
- Jul 25, 2007
- Messages
- 382
- Reaction score
- 38
Alright, this is my first attempt at writing a NPC, just been doing actions. And ,well, Just getting a host of errors and when I fixed them all the script wasn't correct anymore. So, if someone could edit this to be proper, I'd really appreciate it, will learn off it.
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()
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 target_level = 25
local item_cloth = 5913
local item_reward = 2152
if talkSate[talkUser] == 1 then
if getPlayerStorageValue(cid, 1003) == 1 then
npcHandler:say("Sorry mate, gotta get back to work, no time to chat")
npcHandler:say("Might have some more work for you in the future though.")
talkState[talkUser] = 0
elseif getPlayerStorageValue(cid, 1002) == 1 then
npcHandler:say("Welcome back, have any luck?")
if msgcontains(msg, "yes") then
if doPlayerRemoveItem(cid, item_cloth, 1) == true then
npcHandler:say("HAH, sent those bandits to their grave eh?")
npcHandler:say("Nice work there, here, take this for a job well done")
doPlayerAddItem(cid, item_reward, 5)
doPlayerSetStorageValue(cid, 1003, 1)
talkState[talkUser] = 0
elseif getPlayerStorageValue(cid, 1001) == 1 then
npcHandler:say("Come for work have ya'?")
if msgcontains("yes") or msgcontains("ya") then
npcHandler:say("Hah, great, was hoping you'd say that")
if getPlayerLevel(cid) < target_level then
npcHandler:say("Hrmm, you may need to train up a bit more first")
else npcHandler:say("Well, to the point then.")
npcHandler:say("Lately these damned bandits have been jumping travelers,")
npcHandler:say("specifically traders, I need you to.. take care of them so to speak.")
npcHandler:say("Just bring me back a piece of their cloth as a soveniour.")
npcHandler:say("Good luck!")
talkState[talkUser] = 0
doPlayerSetStorageValue(cid, 1002, 1)
elseif msgcontains(msg, "job") or msgcontains(msg, "work") or msgcontains(msg, "quest") then
npcHandler:say("Hah! I am a proud guard of CITY")
if msgcontains(msg, "do") or msgcontains("details") or msgcontains("guard")
npcHandler:say("WHAT DO I DO? I protect these walls inside and out! From preventing muggings to slaying treturous beasts.")
npcHandler:say("Why just recently I saved Jin over there from getting robbed blind")
if msgcontains(msg, "Jin") then
npcHandler:say("Great fellow he is, carves the finest damn arrows this side the Eastern Sea too.")
npcHandler:say("You know what, I've taken a liking to ya lad.")
npcHandler:say("I may have some work for ya, if yer' interested of course")
doPlayerSetStorageValue(cid, 1001, 1)
talkState[talkUser] = 0
end
end
end
end
return TRUE
end