• 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 if string contains?

Xagul

deathzot.net
Joined
Jun 30, 2008
Messages
1,295
Solutions
3
Reaction score
1,043
Hello I am trying to simply determine if a string contains somthing and for some reason it will not work, it keeps sending me the error:

Code:
[6:45:22.246] data/actions/scripts/tools/unid.lua:5: bad argument #1 to 'find' (string expected, got nil)

I am currently using this:

Code:
itemdesc = getItemAttribute(itemEx.uid, "description")
	
	if(string.find(itemdesc, 'hello') ~= nil) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "true")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "false")
	end
 
well the problem I am having is the item does have a description, the item description is infact the word "hello" but even then it still throws me that error =\
 
data/actions/scripts/tools/unid.lua:5: bad argument #1 to 'find' (string expected, got nil)

Argument #1 in the string.find function is 'nil'.
Means itemdesc IS nil.

itemdesc = getItemAttribute(itemEx.uid, "description")

Something is wrong there probably, I think "description" isn't correct.
 
Back
Top