mIRC Home    About    Download    Register    News    Help

Print Thread
#180463 10/07/07 12:39 AM
Joined: Jul 2007
Posts: 19
O
Old Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
This is my first script and I've been working on it in my spare time. I've been using the forums as a tutorial and figured I might get the opinions of people who know what they're doing wink

It's a script for everyone on the server to add/view/edit/comment on various tasks that people add to the .ini file.

Code:
on *:TEXT:!addtask*:#: { 
  :one
  //set %randnum $rand(1,999)
  if ($readini(task.ini,%randnum,task)) {
    /goto one
  }
  else {
    //addtask $nick %randnum $2-
  }
}
alias addtask {
  if ($3- isin $readini(tasks.ini,$2,task)) {
    //notice $nick You already have this task!
  }
  else {
    //writeini todo.ini $1 tasks $2
    //writeini tasks.ini $2 task $3-
    //writeini tasks.ini $2 owner $1
    if (!$readini(tasks.ini,$2,task)) {
      //notice $nick There was an error in adding your task, try submitting agian.
    }
    else {
      //notice $nick Your task has been added!
    }
  }
}


The trouble I am having is only one %randnum is written to todo.ini per user. When you submit another task, it overwrites the previous %randnum.
Also, when it checks if a task already exists, it doesn't recognize it is there and writes it again with a new %randnum.

Any suggestions or comments would be greatly appreciated. Am I headed in the right direction for a noob? :P


http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne
Old #180528 10/07/07 07:25 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
I dont know the answer to your question, but I would advice you to stop using // in front of commands. In remote scripts, you never ever need these // in front of commands.

When you remove them, your script will immediately look cleaner.
It's one of the things I also learned from here.

OrionsBelt #180529 10/07/07 07:33 PM
Joined: Jul 2007
Posts: 19
O
Old Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
It's more of an organization thing, when I was going through troubleshooting, I would add
Code:
//echo -a I made it this far in the script

wherever there were // .

I didn't realize that my question was that tough. I know it's a simple concept (the script), perhaps I'm going about it wrong.
I appreciate the response, I will remove them.

Last edited by Old; 10/07/07 07:38 PM.

http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne
Old #180533 10/07/07 08:34 PM
Joined: Mar 2006
Posts: 47
C
Ameglian cow
Offline
Ameglian cow
C
Joined: Mar 2006
Posts: 47
I'm still not understanding what you're trying to do, or what you mean by the problem you're describing. You're generating random numbers, yet you... don't want them to be random?

Just tidying up some of the code while I'm here...
Code:
on *:TEXT:!addtask*:#: { 
  %randnum = $rand(1,999)
  while ($readini(task.ini,%randnum,task)) %randnum = $rand(1,999)
  addtask $nick %randnum $2-
}

CitizenKane #180536 10/07/07 09:13 PM
Joined: Jul 2007
Posts: 19
O
Old Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
The script is to allow users on a server to add certain things they have to do (the friend I intended it for, and gave me the idea, always has a bunch of things to do and this is a type of organization method) and everyone can review and comment (aspects still in thought, not script) on the various tasks of other users and possible do a few things for someone else if they have some spare time.
If that's not what you were asking, at least it will help others who were wondering smile

Yes, I do want them to be random, it was the easiest method I knew of to number the tasks.

The method that I used to keep from writing the same task isn't effective because it's reading the $rand() generated for the task previously, it doesn't see that in the new task so it writes it again. It has to be simple but, I am currently dumbfound on getting it to read the task written.

Thank you for the tidy up wink
*EDIT* Tested it and is now implemented. Thanks

Last edited by Old; 10/07/07 09:32 PM.

http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne
Old #180540 10/07/07 09:46 PM
Joined: Jul 2007
Posts: 19
O
Old Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
I think I have figured out my problem to:
Originally Posted By: Old

The trouble I am having is only one %randnum is written to todo.ini per user. When you submit another task, it overwrites the previous %randnum.


When writing the file, the item is always constant and the value is changing so it overwrites the previous value for that item.

Now, to change the syntax of the way everything is stored :S


http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne

Link Copied to Clipboard