• Need help with: for _,hhe in pairs(ents.FindByClass()) do
    13 replies, posted
How to know if [CODE]for k,v in pairs(ents.FindByClass())[/CODE]Hasn't found anything?
-snip- mistake moar boxes please for fame..
Found a way around this problem.. Still like to know how, but its not necessary. [editline]10:43PM[/editline] [QUOTE=Cubar;23665315]for k,v in pairs(ents.FindByClass("props_*")) do print(v) else print("Nothing found") end You did it wrong fixed.[/QUOTE] I know.. -.- it was just an example. [editline]10:54PM[/editline] [QUOTE=Dave_Parker;23665484]print("Found ents: "..(#ents.FindByClass("classname") > 0))[/QUOTE] Hey thats good, gonna try it.
That's the other way, mine was a different way, he probably copied that from some where he is a skiddie, you obviously didn't know, allways are the same way there is no such thing as a ZOMG THATS A BETTER WAY THEN MINE OMFG OMFG OMFG.
[QUOTE=Dave_Parker;23666608]Can for loops even take an else operator?[/QUOTE] No, they can't. Cubar does, once again, not know what he's talking about. [EDITLINE]-[/EDITLINE] Dave_Parker already posted the answer. Minor mistake in his print function (You can't concatenate a string with a boolean just like that), but he got the important part right: [CODE]print("Found ents: ", [HIGHLIGHT]#ents.FindByClass("classname") > 0[/HIGHLIGHT])[/CODE]
Oops lol, well i've fixed it now just a silly mistake dumbasses.
[QUOTE=Cubar;23666744]Oops lol, well i've fixed it now just a silly mistake dumbasses.[/QUOTE] [QUOTE=Cubar;23665315][lua] lua_run_cl for k,v in pairs(ents.FindByClass("prop_physics")) do if v then print(v) else print("Nothing found") end end [/lua][/QUOTE] Great job in accomplishing nothing, your code still wouldn't work. If there are no entities with the "prop_physics" class on the map, the if-condition won't even be called. Please stop trying to help until you've at least got the basics of lua.
[lua] PrintTable(ents.FindByClass("prop_physics")) [/lua] if it prints nothing, it didn't find anything :)
[QUOTE=Silverlan;23666939]Great job in accomplishing nothing, your code still wouldn't work. If there are no entities with the "prop_physics" class on the map, the if-condition won't even be called. Please stop trying to help until you've at least got the basics of lua.[/QUOTE] Great job in a being jackass no one or likes you.
[QUOTE=Cubar;23667169]Great job in a being jackass no one or likes you.[/QUOTE] Well.. i like him more than you... So where does that leave you..?
[QUOTE=Cubar;23667169]Great job in a being jackass no one or likes you.[/QUOTE] Maybe you should learn to write grammatically correct sentences.
Sorry, you need to Log In to post a reply to this thread.