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

bad argument #1 to 'find' string expected, got nill

SixNine

Active Member
Joined
Dec 12, 2018
Messages
452
Reaction score
41
TFS 1.2
Lua:
    elseif isInArray(arrayGreetings, msg) and not npcHandler:isFocused(cid) then
        npcHandler:addFocus(cid)
        if string.find(playerGreetMessage, "|PLAYERNAME|") then --here
            local newMsg = string.gsub(playerGreetMessage, "|PLAYERNAME|", player:getName())
            selfSay(newMsg, cid)
        else
            selfSay(playerGreetMessage, cid)
        end
     
    elseif isInArray(arrayFarewell, msg) and npcHandler:isFocused(cid) then
        if string.find(playerGoodbyeMessage, "|PLAYERNAME|") then -- here
            local newMsg = string.gsub(playerGoodbyeMessage, "|PLAYERNAME|", player:getName())
            selfSay(newMsg, cid)
        else
            selfSay(playerGoodbyeMessage, cid)
        end
        npcHandler:releaseFocus(cid)
 
Solution
So i added array greeting to my npc lib file and forgot to add it in the code possibly. That would be my guess. You should create a table named arrayGreatings = {"hi"}

same with
playerGoodbyeMessage
read the error it says its in string.find in the code you posted and you even commented the lines
 
read the error it says its in string.find in the code you posted and you even commented the lines
Yea but what should i do is there like different function instead of string.find? Or maybe something like this? Have no idea
Lua:
if string.find(playerGreetMessage, "|PLAYERNAME|") < 0 then
 
no the message is literally nil it says argument #1 in the error message to string.find
don't know what else to tell you because i don't know what that message is supposed to say or what that npc is or where its from
 
no the message is literally nil it says argument #1 in the error message to string.find
don't know what else to tell you because i don't know what that message is supposed to say or what that npc is or where its from
Its Itutorial advanced npc
 
@SixNine could you be more specific? What is the console error you're receiving? Transfering scripts from 1.x to 1.3-4 can give many of such type or errors since a lot of functions have been rewritten.

note: don't bump your post this much, won't really help :(
 
@SixNine could you be more specific? What is the console error you're receiving? Transfering scripts from 1.x to 1.3-4 can give many of such type or errors since a lot of functions have been rewritten.

note: don't bump your post this much, won't really help :(
Sorry somehow imagine disappeared with error from this thread
20859266d3fbeb2132dce10ebad787a8.png
 
@SixNine you should start with changing MESSAGES_GREET to MESSAGE_GREET same goes for other ones being written as MESSAGES. These global variables have been changed in time to MESSAGE_XXX instead.

So in your case you must change these lines:
Lua:
line 118: local playerGreetMessage = MESSAGES_GREET[player:getStorageValue(npcStorage)]
to
line 118: local playerGreetMessage = MESSAGE_GREET[player:getStorageValue(npcStorage)]
and
Lua:
line 119: local playerGoodbyeMessage = MESSAGES_GOODBYE[player:getStorageValue(npcStorage)]
to
line 119: local playerGoodbyeMessage = MESSAGE_GOODBYE[player:getStorageValue(npcStorage)]

Hope it works for you. Most likely the error message will change which accomplish our goal here :D
 
@SixNine you should start with changing MESSAGES_GREET to MESSAGE_GREET same goes for other ones being written as MESSAGES. These global variables have been changed in time to MESSAGE_XXX instead.

So in your case you must change these lines:
Lua:
line 118: local playerGreetMessage = MESSAGES_GREET[player:getStorageValue(npcStorage)]
to
line 118: local playerGreetMessage = MESSAGE_GREET[player:getStorageValue(npcStorage)]
and
Lua:
line 119: local playerGoodbyeMessage = MESSAGES_GOODBYE[player:getStorageValue(npcStorage)]
to
line 119: local playerGoodbyeMessage = MESSAGE_GOODBYE[player:getStorageValue(npcStorage)]

Hope it works for you. Most likely the error message will change which accomplish our goal here :D
You sure its the solution? because getting same error
 
I didn't say it was the solution. But I know it has been changed.

The best would be that @Itutorial would check further on this since he wrote the code and most likely dealt with similar errors.
Hoping for the best if he would help you fixing your issue. I sadly do not have enough time to figure this out completely by reproducing the error right now.
 
So i added array greeting to my npc lib file and forgot to add it in the code possibly. That would be my guess. You should create a table named arrayGreatings = {"hi"}

same with
playerGoodbyeMessage
 
Last edited:
Solution
So i added array greeting to my npc lib file and forgot to add it in the code possibly. That would be my guess. You should create a table named arrayGreatings = {"hi"}
Yea he responds now, but
94c545c45c0e62f600c29c85cd640b50.png
EDIT: SOLUTION WAS IN THE ORIGINAL THREAD
 
Last edited:
Back
Top