• string.find fails to find?
    0 replies, posted
Hey guys, I've been having a problem with string.find lately. It was working before, but for some odd reason it just decided to stop functioning. Here is the code I'm using. [CODE] function httpCallBack(contents , size) local find = string.find(contents,"<br>") if(find == nil)then local songname = string.sub(contents, 1, find-1) local time = string.sub(contents,find+4) PrintMessage(HUD_PRINTTALK, songname.. " - " .. time.."mins. (Added to queue)") time=tonumber(time) if(time>10)then time=10 end time=(time/60)+CurTime() playnext=time else PrintMessage(HUD_PRINTTALK, contents.." (string find failed?)") end //table.Add(song_queue,time) //table.Add(song_queue,songname) end [/CODE] As you can see I've added a fail-safe for when "find" is nil, but it seems to be nil 100% of the time. In chat I keep getting, "Title of the song <br> 1.85 ". Any ideas what's going wrong here? EDIT: Ahh, nvm I mad a stupid mistake. My fail-safe, was actually 100% fail. Funny, I added it because I got a runtime error with find being nil, heh.
Sorry, you need to Log In to post a reply to this thread.