• 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 npc problem

Triggah

TrigCore
Joined
Aug 1, 2007
Messages
436
Reaction score
2
im trying to make an npc that trades a nose ring for marijuana, with specific lines.

I believe its horribly scripted (i suck), please help fix :)

LUA:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)
end
if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Yooooo ' .. getCreatureName(cid) .. ', waddup man?')
focus = cid
talk_start = os.clock()
end
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Brooo, ' .. getCreatureName(cid) .. '! wait a sec... man')
end
end

elseif msgcontains(msg, 'marijuana') then
selfSay('You got some dope, man?')
talk_state = 1
talk_start = os.clock()
end

elseif talk_state == 1 and msgcontains(msg, 'yes') then
end
if doPlayerRemoveItem(cid,5953,1) then
selfSay('THANKS! man, you the best hookup!')
doPlayerAddItem(cid,5804,1)
end
else
selfSay('Come on bro... get me some marijuana!')
end
        elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
            selfSay('Peace homie, but hey,' .. getCreatureName(cid) .. ', please find me some more dope, I will run out soon.')
            focus = 0
            talk_start = 0
		end
    elseif msgcontains(msg, 'kashfeioyorgheklçguyio') then
            selfSay('What the **** man?')
            talk_state = 0
        end
end
function onCreatureChangeOutfit(creature)
end

function onThink()
    doNpcSetCreatureFocus(focus)
    if (os.clock() - talk_start) > 30 then
        if focus > 0 then
            selfSay('Who there?')
        end
        focus = 0
        talk_start = 0
    end
    if focus ~= 0 then
        if getDistanceToCreature(focus) > 5 then
            selfSay('I see the way it is man...')
            focus = 0
            talk_start = 0
        end
    end
end
end
 
Bumping topics need to whait atleast 24 hours.

Man maybe am helping you, but.
Please post the error it gives, i am not genious or psiquic for known it.

hmm man i tryed everything to fix it, but nothing worked for me!. i recommend you to use the jiddo's npc system, that one is more easy!.

and the error it gives is:
[24/07/2009 00:18:43] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/marijuana.lua
[24/07/2009 00:18:45] data/npc/scripts/marijuana.lua:45: '<eof>' expected near 'elseif'
 
Back
Top