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

Solved NPC - Console and talk problem

xardas33

New Member
Joined
Jan 28, 2010
Messages
83
Reaction score
0
Hello guys. I have problem with my script, first look at script part with error:
Code:
if msgcontains(msg, 'humble') then
   if getPlayerStorageValue(cid,50021) == 3 and getPlayerStorageValue(cid,50022) <= 0 and talkState[talkUser] == 1 then
     selfSay("To become humble you need to kill 50 {skeletons} and bring me 6 {skulls}, 2 {big} {bones}, 2 {bones}. Back when you do all.",cid)
     setPlayerStorageValue(cid,50021,4)
     setPlayerStorageValue(cid,50022,1)
     talkState[talkUser] = 0
   end
end

if msgcontains(msg, 'humble') then
   if getPlayerStorageValue(cid,50021) == 4 then
     selfSay("Do you killed skeletons and bring me items?",cid)
     talkState[talkUser] = 1
   end
end
if msgcontains(msg, 'yes') then
   if getPlayerStorageValue(cid,60000) == 50 and getPlayerItemCount(cid,2229) >= 6 and getPlayerItemCount(cid,2230) >= 2 and getPlayerItemCount(cid,2231) >= 2 then
     if doPlayerRemoveItem(cid,2229,6) and doPlayerRemoveItem(cid,2230,2) and doPlayerRemoveItem(cid,2231,2) then
       selfSay("Great, it's your reward, you will need these skulls later. Now Tom must tell you all what he know about {Golden} {Key}! Go, meet him.",cid)
       doPlayerAddItem(cid,2320,6)
       setPlayerStorageValue(50021,5)
       talkState[talkUser] = 0
     end
   else
     getPlayerStorageValue(cid,60000,0-49)
     getPlayerItemCount(cid,2229,0-5)
     getPlayerItemCount(cid,2230,0-1)
     getPlayerItemCount(cid,2231,0-1)
     selfSay("You must do all what I told you to become humble.", cid)
     talkState[talkUser] = 0
   end
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
   selfSay("So don't lose your time, do all.",cid)
   talkState[talkUser] = 0
end
return true
end

First problem is when I ask about "humble" NPC saying two things:
09:35 Fitula [900]: humble
09:35 Cipfried: To become humble you need to kill 50 skeletons and bring me 6 skulls, 2 big bones, 2 bones. Back when you do all.
09:35 Cipfried: Do you killed skeletons and bring me items?

I want to change it - when I say "humble" i get first message, and after if I say "humble" next time I have second message.

Second problem is when I say "humble -> yes", it's work as it should, but I have error messages in console:
[12/09/2014 09:38:10] [Error - Npc interface]
[12/09/2014 09:38:10] data/npc/scripts/Cipfried.lua:eek:nCreatureSay
[12/09/2014 09:38:10] Description:
[12/09/2014 09:38:10] (luaGetCreatureStorage) Creature not found

Anybody can fix it?
 
What is this part supposed to do?
Code:
getPlayerStorageValue(cid,60000,0-49)
getPlayerItemCount(cid,2229,0-5)
getPlayerItemCount(cid,2230,0-1)
getPlayerItemCount(cid,2231,0-1)
If you want a random number you can use math.random
Code:
math.random(0, 49)
getPlayerStorageValue returns a number, so adding it like this won't do anything, same goes for getPlayerItemCount.
If it should set storage, change get to set, so: setPlayerStorageValue.
 
@kikos - thanks, just small mistake :)
@Limos - I just wanted to do: exmaple, if quest need 6 items, you have 5 items, it's checking and if you have 0,1,2,3,4 or 5 items npc says about "you need more", making quest not completed. I removed that and now it's working good :)

Limos, now only one problem left, here:
Code:
if msgcontains(msg, 'humble') then
   if getPlayerStorageValue(cid,50021) == 3 and getPlayerStorageValue(cid,50022) <= 0 and talkState[talkUser] == 1 then
     selfSay("To become humble you need to kill 50 {skeletons} and bring me 6 {skulls}, 2 {big} {bones}, 2 {bones}. Back when you do all.",cid)
     setPlayerStorageValue(cid,50021,4)
     setPlayerStorageValue(cid,50022,1)
     talkState[talkUser] = 0
   end
end

if msgcontains(msg, 'humble') then
   if getPlayerStorageValue(cid,50021) == 4 then
     selfSay("Do you killed skeletons and bring me items?",cid)
     talkState[talkUser] = 1
   end
end

I want to do, if I say "humble" NPC says "To become humble... bla bla bla" and if I say second time "humble" NPC says: "Do you killed... bla bla bla".
But now if I say "humble i have something like this:
09:35 Fitula [900]: humble
09:35 Cipfried: To become humble you need to kill 50 skeletons and bring me 6 skulls, 2 big bones, 2 bones. Back when you do all.
09:35 Cipfried: Do you killed skeletons and bring me items?
(Two answers to say "humble")
 
Don't use 2x an if statement for the same word.
If reads from the top to the bottom, so when a player says humble and has storage value 3, it will do the first msgcontains(msg, 'humble') part, this part sets the storagevalue to 4.
Then when it comes to the second msgcontains(msg, 'humble') part, well the msg is humble and the storage value is 4 because it was just set to 4, so it will do that part aswell, which has the result that it will do it at the same time.
Code:
if msgcontains(msg, 'humble') then
      if getPlayerStorageValue(cid, 50021) == 3 and getPlayerStorageValue(cid, 50022) <= 0 and talkState[talkUser] == 1 then
           selfSay("To become humble you need to kill 50 {skeletons} and bring me 6 {skulls}, 2 {big} {bones}, 2 {bones}. Back when you do all.", cid)
           setPlayerStorageValue(cid, 50021, 4)
           setPlayerStorageValue(cid, 50022, 1)
           talkState[talkUser] = 0
       elseif getPlayerStorageValue(cid, 50021) == 4 then
           selfSay("Do you killed skeletons and bring me items?",cid)
           talkState[talkUser] = 1
       end
end
To prevent this kind of things with storage, always use elseif statements under the if statement when checking for other storage values. By using elseif, it will only do that part if the statement above it is not true, else it will skip it.
So in the part I just posted, it can never do these 2 textmessages at the same time.
If this line is true
Code:
if getPlayerStorageValue(cid, 50021) == 3 and getPlayerStorageValue(cid, 50022) <= 0 and talkState[talkUser] == 1 then
It will do the part under that with "To become humble you need.." and will ignore the elseif part.
If that line is not true it will ignore that part and look if this line is true and if it is, it will do that part.
Code:
elseif getPlayerStorageValue(cid, 50021) == 4 then
This way the 2 parts will never happen at the same time.
 

Similar threads

Back
Top