Author Topic: Reading user from text file  (Read 2536 times)

0 Members and 1 Guest are viewing this topic.

Sizzles

  • Youngling
  • *
  • Posts: 48
  • Karma: +1/-0
    • View Profile
Reading user from text file
« on: June 21, 2017, 01:41:13 PM »
So i am trying to get a command that will read a text file and check if @user@ is in the text file then if it is it will run a success command and it if isn't then i will run a fail command. Is this possible and how would i do it?

xxxScorpion

  • Youngling
  • *
  • Posts: 29
  • Karma: +0/-0
    • View Profile
  • Twitch Name: xxxScorpion
Re: Reading user from text file
« Reply #1 on: June 21, 2017, 06:43:49 PM »
@if@[@readfile@[(name of text file).txt]||@user@||!successcommand||!failcommand]

You can also just whisper the user that the command isn't ready or they arent the person in the text file by replacing "!failcommand" (or whatever the failcommand you have is called) with /w @user@ You aren't on the list!  Full example below.

@if@[@readfile@[supercoolguys.txt]||@user@||!successcommand||/w @user@ You aren't cool enough for this command!]

The issue however is that there isn't a way to search a @savelog@. So if you had a command that added people to a @savelog@ text file you wouldn't be able to search to see if they are within the file. There's no search function.

To remedy this you can have a command that makes a new txt file per user (Yeah, lots of text files...) and put in in a new folder. So in custom logs make a "coolguyslist" folder and then make the command below.

@savefile@[coolguylist/@user@.txt,@user@]

That makes a text file with the users name and checks to see if their name is inside it. From there you can run the @if@ command to check permissions.

Sizzles

  • Youngling
  • *
  • Posts: 48
  • Karma: +1/-0
    • View Profile
Re: Reading user from text file
« Reply #2 on: June 21, 2017, 08:00:01 PM »
The second command you suggested is more what i am looking for as it is like 20 viewers and adding more each day.
I did have it set up like @if@[@readfile@[Redeem\\Fluffcup\\Fluffs\\Fluffs.txt]||@user@||!redeempass3 @target@[1] @target@[2|50]||!redeemfluff @target@[1] @target@[2|50]] but as you said there is no search so that is why it wasn't working.

Could i just do @if@[@readfile@[Redeem\\Fluffcup\\Fluffs\\@user@.txt]||@user@||!redeempass3 @target@[1] @target@[2|50]||!redeemfluff @target@[1] @target@[2|50]] It is in a completely different file from my other @readfile@ stuff so it shouldn't interfere, correct? (currently not on computer to test)
« Last Edit: June 21, 2017, 08:06:17 PM by Sizzzles »

xxxScorpion

  • Youngling
  • *
  • Posts: 29
  • Karma: +0/-0
    • View Profile
  • Twitch Name: xxxScorpion
Re: Reading user from text file
« Reply #3 on: June 21, 2017, 08:21:36 PM »
Yeah as long as its in a different folder from any other @user@.txt type things you should be fine. The first half of your example should work fine, granted I cant confirm the rest without knowing what the targets are and all that.  But yeah, that should get what you want.

Sizzles

  • Youngling
  • *
  • Posts: 48
  • Karma: +1/-0
    • View Profile
Re: Reading user from text file
« Reply #4 on: June 21, 2017, 11:39:52 PM »
Yeah thanks it worked perfectly. Kind of sucks that there has to be so many text files but guess it is a case of had to. Thanks again

xxxScorpion

  • Youngling
  • *
  • Posts: 29
  • Karma: +0/-0
    • View Profile
  • Twitch Name: xxxScorpion
Re: Reading user from text file
« Reply #5 on: June 22, 2017, 12:01:20 AM »
You're welcome. Yeah it does indeed suck. Maybe eventually some search function could be added for @savelog@ files. Until then though at least it works for now. No