Jump to content




Player Detector code problem - Help please?


  • You cannot reply to this topic
2 replies to this topic

#1 AliveGhost

  • Members
  • 9 posts

Posted 12 April 2013 - 05:27 AM

Hey!

I'm fairly new to CC, and am playing with FTB (like many), so have the MiscPeripherals addon. I'm currently playing on a server, and I have a quick program I wrote to only allow me through the door. However, I want to add a couple of people to be able to access the door. I tried doing "if b == "Shivy011" or "namehere" then
blah blah blah

but this seemed to let anyone in! So, if possible, I ask for your help. Here's the pastebin link, can anyone check it out and help me? http://pastebin.com/KSzxEy2v

Help would be greatly appreciated!

Thanks in advance

AliveGhost

#2 zekesonxx

  • Signature Abuser
  • 263 posts
  • LocationWhere you aren't

Posted 12 April 2013 - 07:29 AM

a, b = os.pullEvent()
You need to specify "player" as the event, otherwise any event can be captured here and things will be unhappy.

if b == "Shivy011" or "[color=#282828][font=helvetica, arial, sans-serif]namehere[/font][/color]" then
This is what is actually happening:
a, b = os.pullEvent("player")
#a = "player", b = "zekesonxx" (me)
if b == "Shivy011" or "namehere" then
code()
end
#The if statement is saying:
if b == "Shivy011"
#Which equals false, because Me != You
#The statement is then saying:
if "namehere"
#"namehere" is not "nil", nil, 0, or false so it returns true.
#Instead, do:
if b == "Shivy011" OR b == "namehere" then
(The comments above are C style comments, which Lua is unfriendly with but Prettify is happy with)
You could also use tables, but that's a different story.

#3 GalactusX

  • Members
  • 29 posts
  • Locationspain

Posted 29 June 2013 - 09:48 AM

hi all, i´m here again!!!

i play w player detector and make a program, I hope this program is useful

http://pastebin.com/XATYmqg7

I'm sorry if my English is very bad





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users