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