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

Need help with an old script!

Tofflarn

New Member
Joined
Mar 22, 2008
Messages
360
Reaction score
1
Location
Sweden
Well i wonder if someone can make this script work for the latest tfs!
I'll tried to make it by myself, but im not pro in scripting :S



Code:
-- the id of the creature we are attacking, following, etc.
 
  focus = 0
  talk_start = 0
  target = 0
  following = false
  attacking = false
 
  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 ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Hello, ' .. creatureGetName(cid) .. '! I sell beer and wine for 10 gp.')
  		focus = cid
  		talk_start = os.clock()
  	end

	if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Leave us alone, ' .. creatureGetName(cid) .. '!')
  	end

  	if msgcontains(msg, 'buy beer') and focus == cid then
  		buy(cid,2006,3,10)
  		talk_start = os.clock()
  	end
 
  	if msgcontains(msg, 'buy wine') and focus == cid then
  		buy(cid,2006,15,10)
  		talk_start = os.clock()
  	end
 
  	if msgcontains(msg, 'quest') and focus == cid then
  		talk_start = os.clock()
  		queststatus = getPlayerStorageValue(cid,5019)
 
  		if queststatus == -1 then
  			selfSay('When I was leaving my ship, I hide priceless artifact in one of the barrels. You could bring it to me.')
  		else
  			selfSay('Bloody adventurers, always looking for trouble!')
  		end
  	end

	if msgcontains(msg, 'ship') and focus == cid then
  		selfSay('My ship is on the desert. It doesn\'t look well but still can sail. Of course if you know how to steer it.')
  		talk_start = os.clock()
  	end
 
  	if msgcontains(msg, 'steer') and focus == cid then
  		talk_start = os.clock()
  		queststatus = getPlayerStorageValue(cid,5019)
 
  		if queststatus == -1 then
  			selfSay('If you want to learn steering, bring me artifact from the ship.')
  		else
  			selfSay('You know everything I do.')
  		end
  	end
 
  	if msgcontains(msg, 'artifact') and focus == cid then
  		talk_start = os.clock()
  		queststatus = getPlayerStorageValue(cid,5019)
 
  		if queststatus == -1 then
  			itemstatus = doPlayerRemoveItem(cid,2342)
 
  			if itemstatus == -1 then
  				selfSay('It\'s in one of the barrels. Look under the deck.')
  			else
  				setPlayerStorageValue(cid,5019,1)
  				selfSay('Thank you! To steer a ship, just use a steering wheel.')
  			end
  		else
			selfSay('This helmet belongs to me.')
  		end
  	end
 
  	if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
  		selfSay('Bye, ' .. creatureGetName(cid) .. '!')
  		focus = 0
  		talk_start = 0
  	end
  end
 
 
  function onCreatureChangeOutfit(creature)
 
  end
 
 
  function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Go away.')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
  end


hope someone can help me, i need this :D
Thx in advanced
 
Code:
  focus = 0
  talk_start = 0
  target = 0
  following = false
  attacking = false
 
 
  function onCreatureDisappear(cid, pos)
      if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
      end
  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, ' .. creatureGetName(cid) .. '! I sell beer and wine for 10 gp.')
          focus = cid
          talk_start = os.clock()
        
      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
          selfSay('Leave us alone, ' .. creatureGetName(cid) .. '!')
        
      elseif focus == cid then
        talk_start = os.clock()

        if msgcontains(msg, 'buy beer') and focus == cid then
            buy(cid,2006,3,10)
            talk_start = os.clock()
        
         elseif msgcontains(msg, 'buy wine') and focus == cid then
            buy(cid,2006,15,10)
            talk_start = os.clock()
 
        elseif msgcontains(msg, 'quest') and focus == cid then
            talk_start = os.clock()
            queststatus = getPlayerStorageValue(cid,5019)
 
            if queststatus == -1 then
                selfSay('When I was leaving my ship, I hide priceless artifact in one of the barrels. You could bring it to me.')
            else
                selfSay('Bloody adventurers, always looking for trouble!')
            end
        

        elseif msgcontains(msg, 'ship') and focus == cid then
            selfSay('My ship is on the desert. It doesn\'t look well but still can sail. Of course if you know how to steer it.')
            talk_start = os.clock()
        
 
        elseif msgcontains(msg, 'steer') and focus == cid then
            talk_start = os.clock()
            queststatus = getPlayerStorageValue(cid,5019)
 
            if queststatus == -1 then
                selfSay('If you want to learn steering, bring me artifact from the ship.')
            else
                selfSay('You know everything I do.')
            end
        
 
        elseif msgcontains(msg, 'artifact') and focus == cid then
            talk_start = os.clock()
            queststatus = getPlayerStorageValue(cid,5019)
 
            if queststatus == -1 then
                itemstatus = getPlayerItemCount(cid, 2342) -- WTF were you trying (doPlayerRemoveItem(cid,2342)( ?
 
                if itemstatus >= 1 then
                    setPlayerStorageValue(cid,5019,1)
                    selfSay('Thank you! To steer a ship, just use a steering wheel.')
                    doPlayerRemoveItem(cid,2342)
                else
                    selfSay('It\'s in one of the barrels. Look under the deck.')                
                end
            else
                selfSay('This helmet belongs to me.')
            end
        end 
      elseif msgcontains(msg, 'bye') and focus == cid and getDistanceToCreature(cid) < 4 then
          selfSay('Bye, ' .. creatureGetName(cid) .. '!')
          focus = 0
          talk_start = 0
      end
  end
 
  function onThink()
      if (os.clock() - talk_start) > 30 then
          if focus > 0 then
              selfSay('Go away.')
          end
              focus = 0
      end
     if focus ~= 0 then
         if getDistanceToCreature(focus) > 5 then
             selfSay('Good bye then.')
             focus = 0
         end
     end
  end
 
Back
Top