|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 2:18 am
Simple Trigger Help Wanted |
Hello Everyone!
I have a trigger:
^(%w) says, 'report'
I'd like it to evaluate the person asking for the report and decide whether or not they are able to access the information.
So it compares the player name to an alias of my alternate characters names or group of allowed players.
If its true the character sends "score" to the MUD which triggers the report to be sent from a string that shows.
If the player is not on the allowed list or isn't on any list at all, it should say Authorization Failure: <PlayerName>
The text below was my half hearted attempt to start the logic, but I can't seem to make it fire.
#IF (%1 = @alts or @allowed){
score
#IF (%1 = @denied){
say Authorization Failure: %1
}
}
Please help! |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Fri Oct 22, 2010 2:52 am |
Try this as the command part of the trigger:
Code: |
#IF %ismember(%1, @alts|@allowed) {score} {say Authorization failure: %1} |
@alts and @allowed should be string list variables with a format like this:
Code: |
allowed = "John|Paul|George|Ringo" |
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Oct 22, 2010 3:04 am |
What you need is the %ismember function.
Something like this should work fine.
Code: |
#IF (%ismember(%1, @denied)) {
say Authorization Failure: %1
} {
score
} |
|
|
_________________ Asati di tempari! |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 1:03 pm |
Thanks for the help, can I get a link to more information about %ismember?
EDIT:
Nevermind, I saw when I went to type it in that it tells me exactly how it works. |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 7:31 pm |
Can I make this differentiate between denied and people not on a list? For instance I obviously want it to deny people on the denied list, but if they are no on list it still fires the command.
Along those same lines, how can i manage the lists without manually updating them? |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Oct 22, 2010 7:44 pm |
Sure you can just use and && statement.
Code: |
#IF (%ismember(%1, @denied) || !%ismember(%1, @allowed)){
say Authorization Failure: %1
} {
score
} |
Actually if you only want to do allowed people then you invert the if statement.
Code: |
#IF (%ismember(%1, @allowed)){
score
} {
say Authorization Failure: %1
} |
|
|
_________________ Asati di tempari! |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 8:27 pm |
Hmm then why doesnt this work: (I've edited it to suit other commands)
Code: |
#VAR foodRequestor %1
#IF (%ismember(@foodRequestor, @alts) || (%ismember(@foodRequestor, @allowed)) {
cast 'create food';cast 'create food';give all.mu @foodRequestor
} {
' Authorization Failure: @foodRequestor
} |
Maybe I'm not understanding a concept here... :( |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 8:30 pm |
Have you ever had a DOH! moment? I think I just did... *goes to check*
|
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 8:35 pm |
Nope, maybe it wasn't a revelation...
Code: |
#VAR foodRequestor %1
#IF (%ismember(@foodRequestor, @alts) || %ismember(@foodRequestor, @allowed)){
cast 'create food';cast 'create food';give all.mu @foodRequestor
} {
' Authorization Failure: @foodRequestor
} |
Except now it denies my Alt, who happens to be on both lists (for testing purposes).
@alts = Thrain|Yryllyn|Tripz
@allowed = Yryllyn|Tripz|Thrain|Zeevius|Osiris
Should this be a nested IF? Can you even nest?
Code: |
#VAR foodRequestor %1
#IF (%ismember(@foodRequestor, @alts)){
cast 'create food';cast 'create food';give all.mu @foodRequestor
} {
#IF (%ismember(@foodRequestor, @allowed)){
cast 'create food';cast 'create food';give all.mu @foodRequestor
} {
' Authorization Failure: @foodRequestor
}
}
|
Because this doesn't fire... :( |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Fri Oct 22, 2010 8:50 pm |
Is that part of a trigger? If so, what is the pattern you are using for the trigger?
|
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Fri Oct 22, 2010 8:51 pm |
Code: |
^(%w) pokes you in the ribs. |
Does it have something to do with the way it stores variables? Possibly extra spaces in the word it grabs? Is there a "trim" function if thats the case?
This is the actual syntax:
Code: |
Thrain pokes you in the ribs. |
|
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Fri Oct 22, 2010 9:15 pm |
Ah! No, there's a problem with the syntax of the trigger command itself. There needs to be a space separating the brackets and braces in your #IF lines. You can nest #IF statements, but you don't need to in this case. Cmud has a #SWITCH command that you should look at in the help files. It works rather like nested #IF statements.
Code: |
#VAR foodRequestor %1
#IF (%ismember(@foodRequestor, @alts) || %ismember(@foodRequestor, @allowed)) {
cast 'create food';cast 'create food';give all.mu @foodRequestor
} {
' Authorization Failure: @foodRequestor
} |
When you are inside of the package editor, you can press Control+K or click on Editor -> Check Syntax to check the syntax of that setting. It's invaluable in helping you spot problems like this.
It wasn't the problem with your code, but there is indeed a %trim() function to remove spaces from the beginning and end of strings. |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Sat Oct 23, 2010 12:31 am |
There aren't any errors but I still can't get past the verification, it denies my alt :(
|
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Sat Oct 23, 2010 12:35 am |
copy / paste this syntax to declare the variables:
Code: |
alts = Thrain|Yryllyn|Tripz
allowed = Yryllyn|Tripz|Thrain|Zeevius|Osiris |
It really ought to be working. |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Sat Oct 23, 2010 1:43 am |
Like this?
Code: |
#VAR foodRequestor %1
#SWITCH (@foodRequestor==@alts) {cast 'create food';cast 'create food';give all.mu @foodRequestor }
(@foodRequestor==@allowed) {cast 'create food';cast 'create food';give all.mu @foodRequestor }
(@foodRequestor==@denied) {' Authorization Failed: @foodRequestor}
{' Authorization Failed: @foodRequestor} |
Cuz this don't work, it denies everyone... same issue as i was having with the nested if's |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Sat Oct 23, 2010 1:55 am |
Nope, the syntax you'd want to have in the body of the trigger would be:
Code: |
#VAR foodRequestor %1
#SWITCH (%ismember(@foodRequestor,@alts)) {cast 'create food';cast 'create food';give all.mu @foodRequestor}
(%ismember(@foodRequestor,@allowed)) {cast 'create food';cast 'create food';give all.mu @foodRequestor}
(%ismember(@foodRequestor,@denied)) {' Authorization Failed: @foodRequestor}
{' Authorization Failed: @foodRequestor} |
The only thing I can think of is that you haven't got the variables set up properly.
Have you copy / pasted the following text to your command line (where you generally type things when you're playing the mud):
alts = Thrain|Yryllyn|Tripz
allowed = Yryllyn|Tripz|Thrain|Zeevius|Osiris
That should declare the lists correctly. With those two variables, and the trigger, it should work. |
|
|
|
XoVoX Beginner
Joined: 22 Dec 2005 Posts: 14 Location: San Antonio, TX
|
Posted: Sat Oct 23, 2010 2:30 am |
OK, typing the alts and allowed in the command line seemed to fix this... so let me ask you this. What is the easiest way for me to add/remove names from these lists without opening my variables and adding/removing manually.
Could it trigger off, say:
Code: |
Thrain says, 'add PersonName allowed' |
Would I have the trigger send:
Code: |
allowed = allowed+|%trim(%1) |
If so, how do I take the name off the list? I didn't think this question would stem so many more. |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Sat Oct 23, 2010 3:00 am |
What you want are the commands #ADDITEM and #DELITEM or the functions %additem() and %delitem(). These can be integrated in to triggers or aliases quite easily.
For the trigger you've got there, try this:
Code: |
#TRIGGER {^Thrain says, 'add (%w) (%w)'$} {
#VAR %2 %additem( %1, @{%2})
#SAY %1 added to list '%2'
} |
A similar trigger to remove items from lists would be:
Code: |
#TRIGGER {^Thrain says, 'del (%w) (%w)'$} {
#VAR %2 %delitem( %1, @{%2})
#SAY %1 removed from list '%2'
} |
|
|
Last edited by DraxDrax on Sat Oct 23, 2010 3:02 am; edited 1 time in total |
|
|
|
Fizgar Magician
Joined: 07 Feb 2002 Posts: 333 Location: Central Virginia
|
Posted: Sat Oct 23, 2010 3:01 am |
To add and remove items from a string list you can use #additem and #delitem from the command line or in a trigger if you want it set up like that.
|
|
_________________ Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34 |
|
|
|
|
|