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

How do I make this script work with the new TFS

Gsp

RP
Joined
Jan 3, 2008
Messages
250
Solutions
1
Reaction score
4
Code:
local focus = 0 
local talk_start = 0 
local target = 0 
local days = 0 

function onThingMove(creature, thing, oldpos, oldstackpos) 

end 


function onCreatureAppear(creature) 

end 


function onCreatureDisappear(cid, pos) 
      if focus == cid then 
          selfSay('Good bye then.') 
          focus = 0 
          talk_start = 0 
      end 
end 


function onCreatureTurn(creature) 

end 


function msgcontains(txt, str) 
      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) 
end 


function onCreatureSay(cid, type, msg) 
      msg = string.lower(msg) 

      if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then 
         selfSay('Hello ' .. getCreatureName(cid) .. '! I need some help.') 
         focus = cid 
         talk_start = os.clock() 

    elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
          selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') 

      elseif focus == cid then 
        talk_start = os.clock() 

        if msgcontains(msg, 'help') or msgcontains(msg, 'quest') then 
             if getPlayerStorageValue(cid,50088) == -1 then 
                selfSay('Do you want to help me?') 
                talk_state = 1 
            else 
                selfSay('I already gave you my Quest.') 
                talk_state = 0 
            end 

        elseif msgcontains(msg, 'sheet') or msgcontains(msg, 'music') then 
             if getPlayerStorageValue(cid,50088) == 1 then 
                selfSay('Do you have the music sheets?') 
                talk_state = 2 
            elseif getPlayerStorageValue(cid,50088) > 1 
                selfSay('You already did my quest')             
                talk_state = 0 
            end 

        elseif talk_state == 1 then 
            if msgcontains(msg, 'yes') then 
                selfSay('Get the 3 different music sheets from 3 different kings. They are in the human dimension.') 
                setPlayerStorageValue(cid,50088, 1) 
                talk_state = 0 
            else 
                selfSay('So shall it be chicken.') 
                talk_state = 0 
            end 

        elseif talk_state == 2 then 
            sheet1 = getPlayerItemCount(cid,6087) 
            sheet2 = getPlayerItemCount(cid,6088) 
            sheet3 = getPlayerItemCount(cid,6089) 
            if msgcontains(msg, 'yes') then 
                if sheet1 >= 1 and sheet2 >= 1 and sheet3 >=1 then 
                    doPlayerRemoveItem (cid,6087,1) 
                    doPlayerRemoveItem (cid,6088,1) 
                    doPlayerRemoveItem (cid,6089,1) 
                    doPlayerAddItem (cid,2127,1) 
                    selfSay('Here is your reward. You have to figure the secret out yourself.') 
                    talk_state = 0 
                     focus = 0 
                else 
                    selfSay('Fool, You dont have all the sheets! Get out of here.') 
                    talk_state = 0 
                     focus = 0 
                end 
            end 

          elseif msgcontains(msg, 'bye')  and getDistanceToCreature(cid) < 4 then 
              selfSay('Good bye, ' .. creatureGetName(cid) .. '!') 
              focus = 0 
              talk_start = 0 
          end 
end 


function onCreatureChangeOutfit(creature) 

end 


function onThink() 
    doNpcSetCreatureFocus(focus) 
      if (os.clock() - talk_start) > 30 then 
          if focus > 0 then 
              selfSay('Next Please...') 
          end 
              focus = 0 
      end 
     if focus ~= 0 then 
         if getDistanceToCreature(focus) > 5 then 
             selfSay('Good bye then.') 
             focus = 0 
         end 
      end 
end

Its a quest npc script you give him the sheets and he'll reward you. if someone can help i will be so happy
regards
 
PHP:
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()					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') or msgcontains(msg, 'quest') then 
        if getPlayerStorageValue(cid, 50088) == -1 then 
            selfSay('Do you want to help me?', cid) 
            talkState[talkUser] = 1 
        else 
            selfSay('I already gave you my Quest.') 
            talkState[talkUser] = 0 
        end 
    elseif msgcontains(msg, 'sheet') or msgcontains(msg, 'music') then 
        if getPlayerStorageValue(cid, 50088) == 1 then 
            selfSay('Do you have the music sheets?', cid) 
            talkState[talkUser] = 2 
        elseif getPlayerStorageValue(cid, 50088) > 1 then
            selfSay('You already did my quest', cid)             
            talkState[talkUser] = 0 
        end 
    elseif talkState[talkUser] == 1 then 
        if msgcontains(msg, 'yes') then 
            selfSay('Get the 3 different music sheets from 3 different kings. They are in the human dimension.', cid) 
            setPlayerStorageValue(cid, 50088, 1) 
        elseif msgcontains(msg, 'no') then
            selfSay('So shall it be chicken.', cid) 
        end
		talkState[talkUser] = 0
    elseif talkState[talkUser] == 2 then 
        if msgcontains(msg, 'yes') then 
            if(doPlayerRemoveItem(cid, 6087, 1) and doPlayerRemoveItem(cid, 6088, 1) and doPlayerRemoveItem(cid, 6089, 1)) == TRUE then           
                doPlayerAddItem(cid, 2127, 1) 
                selfSay('Here is your reward. You have to figure the secret out yourself.', cid) 
            else 
                selfSay('Fool, You dont have all the sheets! Get out of here.', cid) 
            end
        end
		talkState[talkUser] = 0
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
[24/11/2008 20:47:27] Lua Script Error: [TalkAction Interface] 
[24/11/2008 20:47:27] data/talkactions/scripts/createitem.lua:onSay

[24/11/2008 20:47:27] luaDoPlayerAddItem(). Item not found

npc is there but wont remove items and give the reward :eek:
 
Code:
[24/11/2008 20:47:27] Lua Script Error: [TalkAction Interface] 
[24/11/2008 20:47:27] data/talkactions/scripts/createitem.lua:onSay

[24/11/2008 20:47:27] luaDoPlayerAddItem(). Item not found

npc is there but wont remove items and give the reward :eek:

^ Thats a talkaction... o_O
Code:
if doPlayerRemoveItem(cid, 6087, 1) == TRUE and doPlayerRemoveItem(cid, 6088, 1) == TRUE and doPlayerRemoveItem(cid, 6089, 1) == TRUE then
 
Back
Top