mIRC Home    About    Download    Register    News    Help

Print Thread
#244676 19/03/14 12:13 AM
Joined: Mar 2014
Posts: 4
J
John67 Offline OP
Self-satisified door
OP Offline
Self-satisified door
J
Joined: Mar 2014
Posts: 4
Hey! What I am looking for is a bit difficult to create which is why I come here for help.

Basically what I want is a script that allows people, when permitted by OPs, to pick a class(Wizard, Warrior, Cleric, etc.) Then I when they've picked their class I want their name with their class next to it to be written down in a text file somewhere for me to be able to check but I also want them to be able to use a on text command to check which class they are.

For example;
Code:
!permit <nick>
;This will allow <nick> to pick their class.

!class <classname>
;This will be used by the user who was permitted earlier to pick a class. (I want them to only be able to pick a class ONCE for each time they're permitted.)

!class
;This should respond with $nick's current class.



If anyone feel like they're up for it then I'd be extremely grateful! smile I realize this can be done using writeini and Hash Tables but I have experience with neither and I am trying to learn so please also feel free to explain how your script works! smile


Best Regards,
John

Last edited by John67; 19/03/14 12:24 AM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
on *:text:!permit*:#: { 
if ($nick !isop #) { return }
  if ($2 == $null) { msg # Who do you want to permit? | return }
  else {
    set -u60 %permit $addtok(%permit,$2,32)
    msg # $2 is now permitted to choose a class for 60 seconds.
  }
}




on *:text:!class*:#: { 
  if ($2 == $null) { msg # $nick is a $readini(classes.ini,$nick, Class) | return }
  if ($istok(%permit,$nick,32)) {  
    if ($2 != Cleric) && ($2 != Warrior) && ($2 != Wizard) { return }
    .writeini -n classes.ini $nick Class $2
    msg # $nick is now a $2 $+ .
  }
}


Something like that?
It's pretty straight forward if you can code from context.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Mar 2014
Posts: 4
J
John67 Offline OP
Self-satisified door
OP Offline
Self-satisified door
J
Joined: Mar 2014
Posts: 4
This works great! Thank you! laugh

Joined: Mar 2014
Posts: 4
J
John67 Offline OP
Self-satisified door
OP Offline
Self-satisified door
J
Joined: Mar 2014
Posts: 4
I would like for when someone does have a class and does !class to reply with something different like "You do not currently have a class". How would I go about doing this?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
 
on *:text:!permit*:#: { 
  if ($nick !isop #) { return }
  if ($2 == $null) { msg # Who do you want to permit? | return }
  else {
    set -u60 %permit $addtok(%permit,$2,32)
    msg # $2 is now permitted to choose a class for 60 seconds.
  }
}




on *:text:!class*:#: { 
  var %class $readini(classes.ini,$nick, Class)
  if ($2 == $null) {   
    if (%class == $null) { msg # $nick does not have a class yet. | return }
    if (%class != $null) { msg # $nick is a %class $+ . }
  }
  if ($istok(%permit,$nick,32)) {  
    if ($2 != cleric) && ($2 != warrior) && ($2 != wizard) { return }
    .writeini -n classes.ini $nick Class $2
    msg # $nick is now a $2 $+ .
  }
}


I made the $readini a variable called %class instead to simplify it. If %class is non existent ($null) it'll now say that message instead.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 14
A
Pikka bird
Offline
Pikka bird
A
Joined: Apr 2014
Posts: 14
Heyho,

i went through this thread for my own bot and changed the script a little bit, as i didn't need the permit-line.

Code:
on *:text:!setclass*:#: { 
  set -u30 %floodpoints. $+ $nick On 
  if ($2 != Warrior ) && ($2 != Sentinel) ($2 != Gambler ) && ($2 != Gunner ) && ($2 != Blackmage ) && ($2 != Whitemage ) && ($2 != Synergist ) && ($2 != Saboteur ) && ($2 != Summoner ) && ($2 != Bluemage ) && ($2 != Thief ) { return }
  .writeini -n Classes.ini $nick Class $2
  msg $chan $nick is now a $2 $+ .
}


The problem i have is, that people are able to freely write down a class which is actually not on the list. Did i make an error?

Last edited by Ahramanyu; 25/04/14 10:35 AM.
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
You forget && between ($2 != Sentinel) and ($2 != Gambler )

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
The way I demonstrated earlier in the script with ($2 != Knight) etc is not the most efficient way, use this instead.

Code:
on *:text:!setclass*:#: { 
  if ($($+(%,floodclasses.,$nick),2)) { return }
  set -u30 %floodclasses. $+ $nick On 
  if($istok(%classes,$2,32)) { 
  .writeini -n Classes.ini $nick Class $2
  msg # $nick is now a $2 $+ .
 }
}

Now, just create a variable called %classes with all of these.
If you don't know how to, just go to your variables in the scripts editor and make a variable yourself. %classes Gambler Thief etc


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 14
A
Pikka bird
Offline
Pikka bird
A
Joined: Apr 2014
Posts: 14
Originally Posted By: blessing
You forget && between ($2 != Sentinel) and ($2 != Gambler )

That did the job, thanks.

@Nillen

I look into it. It reminds me a bit of html and css, where you have the layout and the design seperat, so i guess it makes sense to do it that way. Thanks for the hint!


Link Copied to Clipboard