• 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!

Lua Script Problem.. -.-

_Arthur

Joined
Oct 22, 2009
Messages
2,190
Reaction score
143
Hey, I've got this script for my king, but for some reason it's not working.. In-game, this shows up...

Code:
07:56 King Arthur: Greetings mighty warrior, I am in deep need of help, would you help me?
07:56 Arthur [15]: help
07:56 King Arthur:

This is the script..

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local storage = 60010 ---- storage value
local dildo = 2357 --- item id of the item princess gives u
local reward = 2091 --- item id of the reward
local aid = 3141 ---- the aid that the key will have


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 greetCallback(cid)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  Topic[talkUser] = 0
    return true
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
  if msgcontains(msg, "help") and getPlayerStorageValue(cid, storage) < 1 then
    npcHandler:say({'You look like a mighty brave adventurer. Would you be willing to {help} me?'}, cid)
    Topic[talkUser] = 1
	elseif msgcontains(msg, "yes") and Topic[talkUser] == 1 then
    npcHandler:say({'I\'ve heard some rumours of my daughter; Princess Mandy being kidnapped by the sultan and his tribes people. Please bring information of my daughter\s well-being.'}, cid)
	setPlayerStorageValue(cid, storage, 1)
    Topic[talkUser] = 0
  elseif getPlayerStorageValue(cid, storage) == 1 and msgcontains(msg, "ring") then
    npcHandler:say({'You have returned, I assume you found my child.. Have you?'}, cid)
    Topic[talkUser] = 2
  elseif msgcontains(msg, "yes") and Topic[talkUser] == 2 and getPlayerItemCount(cid, dildo) == 1 then
    npcHandler:say({'My daughter Mandy is alive?! Thank you so much for returning her ring. Here\'s the key to the town prison. Perhaps you\'ll someday find something interesting going on in there. ', '', ''}, cid)
    doItemSetAttribute(doPlayerAddItem(cid,reward,1), 'aid', aid)
	doPlayerRemoveItem(cid, dildo, 1)
	setPlayerStorageValue(cid, storage, 2)
	Topic[talkUser] = 0
	elseif msgcontains(msg, "no") and Topic[talkUser] == 2 or Topic[talkUser] == 1 then
	npcHandler:say({'Please, find me my daugther! Bring me proof of her existance!'}, cid)
	Topic[talkUser] = 0
	end
  return TRUE
end
 
Lua:
npcHandler:say({'You look like a mighty brave adventurer. Would you be willing to {help} me?'}, cid)
For:
Lua:
npcHandler:say('You look like a mighty brave adventurer. Would you be willing to {help} me?', cid)
 
How about this..
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local storage = 60010 ---- storage value (The same as the king.lua)
local storage2 = 60011 ---- storage value (a new value for the princess only)
local dildo = 2357 --- item id of the item princess gives u
local reward = xxxx --- item id of the reward
local aid = 3141 ---- the aid that the key will have


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 greetCallback(cid)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  Topic[talkUser] = 0
    return true
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
  if msgcontains(msg, "hi") and getPlayerStorageValue(cid, storage2) < 1 and getPlayerStorageValue(cid, storage) == 1 then
    npcHandler:say('Who are you?? Who sent you here??', cid)
    Topic[talkUser] = 1
    elseif msgcontains(msg, "king arthur") and Topic[talkUser] == 1 then
    npcHandler:say('My father sent you?!, I got taken by these desert people, I don\'t know where I am. They seem to be very friendly though. Are you here to [rescue] me?', cid)
    Topic[talkUser] = 2
  elseif msgcontains(msg, "yes") and Topic[talkUser] == 2 then
    npcHandler:say('You came all the way here to resque me from these people?', cid)
    Topic[talkUser] = 3
  elseif msgcontains(msg, "yes") and Topic[talkUser] == 3 then
    npcHandler:say('Thank you for uncuffing me, I am in debt to you!', 'Take this ring to my father so he know\'s I\'m alright.', cid)
    doPlayerAddItem(cid, dildo, 1)
    setPlayerStorageValue(cid, storage2, 2)
    Topic[talkUser] = 0
    elseif msgcontains(msg, "no") and Topic[talkUser] == 3 then
    npcHandler:say('Please help me, please!.', cid)
    Topic[talkUser] = 0
    end
  return TRUE
end

npcHandler:setMessage(MESSAGE_GREET, "WHO ARE YOU!! DONT TOUCH MEE!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And..

Code:
08:44 Arthur [15]: hi
08:44 Mandy: WHO ARE YOU!! DONT TOUCH MEE!

(My storage is set correctly..
 
Last edited by a moderator:
npcHandler:setMessage(MESSAGE_GREET, "WHO ARE YOU!! DONT TOUCH MEE!")

Edit that line.

But the storage is...
if msgcontains(msg, "hi") and getPlayerStorageValue(cid, storage2) < 1 and getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say('Who are you?? Who sent you here??', cid)

She shouldn't be saying that to me..
 
Back
Top