Ir para conteúdo

Npc Bugado


wr1000

Posts Recomendados

Estou aki novamente presizando de vcs meus amigos.

O problema é o seguinte eu tenho um npc chamado Professor Burton ele deveria fornecer uma determinada stone que o player pedisse

dependendo do level e da quantidade de dex que o player tiver ex: water Stone - para level 20 e com 12 dex registrados. só que mesmo que o player estiver com a quantidade de level e dex necessária para pegar a stone o npc diz que precisa de + dex registrados para liberar a stone. A única stone que o npc fornece certo é a Coccon Stone pois ela não pede Dex apenas level.

 

Aqui vai o script do npc

 

 

local focus = 0

local talk_start = 0

 

local target = 0

 

local following = false

 

local attacking = false

 

local talkState = {}

local states = {'1', '2', '3', '4', '5', '6'}

local store = {1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151}

local unlock = {}

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

 

 

end

 

 

 

 

 

function onCreatureAppear(creature)

 

 

 

end

 

 

 

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

 

selfSay('Good bye sir!')

 

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)

local msg = string.lower(msg)

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if(msgcontains(msg, 'yes') and not isInArray(states, talkState[talkUser]) and talkState[talkUser] == 0 and focus == cid) then

if getPlayerStorageValue(cid, 200) >= 1 then

selfSay('I have already given you a stone!')

talkState[talkUser] = 0

return false

end

selfSay('Ok i can give you one water, leaf, heart, coccon or venom stone. You can choose only one, what will it be?')

talkState[talkUser] = 1

elseif (msgcontains(msg, 'no') and (focus == cid) and (talkState[talkUser] == 0)) then

selfSay('You like to do everything without help dont you? Thats the spirit.')

focus = 0

elseif (msgcontains(msg, 'no') and (focus == cid) and (talkState[talkUser] >= 2)) then

selfSay('Come back later when you are ready.')

focus = 0

elseif (msgcontains(msg, 'bye') and focus == cid) then

focus = 0

selfSay('I will continue my studies.')

elseif (msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) <= 2) then

if getPlayerStorageValue(cid, 200) >= 1 then

selfSay('Hello again ' .. getCreatureName(cid) .. '! Hope you enjoyed my help. Im very busy right now, come back later!')

focus = cid

else

focus = cid

talk_start = os.clock()

talkState[talkUser] = 0

selfSay('Hello, Im professor burton and i study pokemon evolutions. Would you like some help to evolve your pokemons?')

end

elseif (msgcontains(msg, 'water') and talkState[talkUser] ~= 0 and talkState[talkUser] ~= 6 and focus == cid) then

selfSay('Water stones are used to evolve water pokemons, but i can only give water stones to players at level 20 or higher, with at least 12 pokemon registred on your pokedex, do you have those requirements?')

talkState[talkUser] = 6

elseif (msgcontains(msg, 'leaf') and talkState[talkUser] ~= 0 and talkState[talkUser] ~= 2 and focus == cid) then

selfSay('Leaf stones evolve grass pokemon. You need to be level 18 and have at least 10 pokemons registrations in your pokedex, do you have these requirements?')

talkState[talkUser] = 2

elseif (msgcontains(msg, 'coccon') and talkState[talkUser] ~= 0 and talkState[talkUser] ~= 3 and focus == cid) then

selfSay('Coccon stones are very common and they evolve bug pokemons, the only requirement is to be level 15, are you at this level?')

talkState[talkUser] = 3

elseif (msgcontains(msg, 'heart') and talkState[talkUser] ~= 0 and talkState[talkUser] ~= 4 and focus == cid) then

selfSay('Heart stones evolve either flying or normal pokemon, and you gotta be level 20 with 12 pokemon registrations in your pokedex, are you ok with that?')

talkState[talkUser] = 4

elseif (msgcontains(msg, 'venom') and talkState[talkUser] ~= 0 and talkState[talkUser] ~= 5 and focus == cid) then

selfSay('Ah, venom, used to evolve poison pokemons, this isnt the rarest stone but its used only with strong pokemons, you need level 28 and 18 pokemons registrations in your pokedex to get this stone, fine?')

talkState[talkUser] = 5

elseif (msgcontains(msg, 'yes') and talkState[talkUser] ~= 0 and focus == cid) then

if getPlayerStorageValue(cid, 200) >= 1 then

selfSay('I have already given you a stone!')

talkState[talkUser] = 0

return true

end

if talkState[talkUser] == 6 then

if getPlayerLevel(cid) >= 20 then

for i = 1, #store do

if getPlayerStorageValue(cid, store) > 0 then

table.insert(unlock, 1)

end

end

if #unlock >= 12 then

selfSay('Oh, very nice! Take this stone to help you complete your pokemon way!')

talkState[talkUser] = 0

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Professor Burton has given you a water stone.")

setPlayerStorageValue(cid, 200, 1)

doPlayerAddItem(cid, 2277, 1)

focus = 0

else

selfSay('You need to register more pokemon in your pokedex!')

talkState[talkUser] = 0

focus = 0

end

else

selfSay('You dont have the required level to take this stone.')

talkState[talkUser] = 0

focus = 0

end

elseif talkState[talkUser] == 2 then

if getPlayerLevel(cid) >= 18 then

for i = 1, #store do

if getPlayerStorageValue(cid, store) > 0 then

table.insert(unlock, 1)

end

end

if #unlock >= 10 then

selfSay('Oh, very nice! Take this stone to help you complete your pokemon way!')

talkState[talkUser] = 0

focus = 0

setPlayerStorageValue(cid, 200, 1)

doPlayerAddItem(cid, 2276, 1)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Professor Burton has given you a leaf stone.")

else

selfSay('You need to register more pokemon in your pokedex!')

talkState[talkUser] = 0

focus = 0

end

else

selfSay('You dont have the required level to take this stone.')

talkState[talkUser] = 0

focus = 0

end

elseif talkState[talkUser] == 3 then

if getPlayerLevel(cid) >= 15 then

selfSay('Oh, very nice! Take this stone to help you complete your pokemon way!')

talkState[talkUser] = 0

focus = 0

setPlayerStorageValue(cid, 200, 1)

doPlayerAddItem(cid, 2284, 1)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Professor Burton has given you a coccon stone.")

else

selfSay('You dont have the required level to take this stone.')

talkState[talkUser] = 0

focus = 0

end

elseif talkState[talkUser] == 4 then

if getPlayerLevel(cid) >= 20 then

for i = 1, #store do

if getPlayerStorageValue(cid, store) > 0 then

table.insert(unlock, 1)

end

end

if #unlock >= 12 then

selfSay('Oh, very nice! Take this stone to help you complete your pokemon way!')

talkState[talkUser] = 0

setPlayerStorageValue(cid, 200, 1)

doPlayerAddItem(cid, 2289, 1)

focus = 0

else

selfSay('You need to register more pokemon in your pokedex!')

talkState[talkUser] = 0

focus = 0

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Professor Burton has given you a heart stone.")

end

else

selfSay('You dont have the required level to take this stone.')

talkState[talkUser] = 0

focus = 0

end

elseif talkState[talkUser] == 5 then

if getPlayerLevel(cid) >= 28 then

for i = 1, #store do

if getPlayerStorageValue(cid, store) > 0 then

table.insert(unlock, 1)

end

end

if #unlock >= 18 then

selfSay('Oh, very nice! Take this stone to help you complete your pokemon way!')

talkState[talkUser] = 0

focus = 0

setPlayerStorageValue(cid, 200, 1)

doPlayerAddItem(cid, 2278, 1)

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Professor Burton has given you a venom stone.")

else

selfSay('You need to register more pokemon in your pokedex!')

talkState[talkUser] = 0

focus = 0

end

else

selfSay('You dont have the required level to take this stone.')

talkState[talkUser] = 0

focus = 0

end

end

end

end

 

function onThink()

if focus == 0 then

 

selfTurn(0)

else

argx, argy, argz = selfGetPosition()

dir = getDirectionTo({x=argx,y=argy,z=argz}, getThingPos(focus))

if dir == 7 then

dir = 0

elseif dir == 6 then

dir = 3

elseif dir == 5 then

dir = 1

elseif dir == 4 then

dir = 3

end

selfTurn(dir)

end

 

if (os.clock() - talk_start) > 61 then

 

focus = 0

 

end

 

if focus ~= 0 then

a, b, c = selfGetPosition()

if c ~= getThingPos(focus).z then

focus = 0

end

end

 

if focus ~= 0 then

if getDistanceToCreature(focus) > 3 then

focus = 0

end

end

 

return true

end

 

 

 

Como posso corrigir isso??

 

.

Editado por wr1000
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...