all right? (Name Check)

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Juzeph
New User
Posts: 23
Joined: Sun Apr 15, 2007 5:58 pm

all right? (Name Check)

Post by Juzeph »

Code: Select all

 var staffList := {"staff", "conselour", "seer", "gm", "admin", "owner", "developer", "sir", "lord"};
 var i := 1;
  while(staffList[i])
    if(lower(name[staffList[i]]))
      SendMessage(quem, "The word " + staffList[i] + " was not authorized to use in the name.");
      changeName(quem);
     break;
    endif
   i := i + 1;
  endwhile
Independent of the used word, it always appears the message "The word was not authorized to use in the name".
Last edited by Juzeph on Fri Jun 29, 2007 8:58 pm, edited 1 time in total.
User avatar
MontuZ
Forum Regular
Posts: 338
Joined: Fri Feb 10, 2006 8:08 am

Post by MontuZ »

you want to use a for() not while()

Code: Select all

    for (i := 1; i >= staffList.Size(); i += 1 )
        if(lower(name[staffList[i]]))
            SendMessage(quem, "The word " + staffList[i] + " was not authorized to use in the name.");
            changeName(quem);
            break;
        endif
    endfor
Xenawar
New User
Posts: 13
Joined: Thu May 03, 2007 2:23 pm

Post by Xenawar »

Your While() loop is perfectly fine. There isn't a single thing wrong with it. Don't change it if that's how you want to use it.

Your problem is this line:

Code: Select all

if(lower(name[staffList[i]]))
Think about what you are doing there for a second. Let's break it down:

Code: Select all

var v1 := staffList[i];  //v1 := "staff";
var v2 := name[v1];  //v2 := {error = Uninitialized object};
var v3 := lower(v2);  //v3 := "error: Uninitialized Object";
if (v3)  //v3 is now a string literal. So this is TRUE
  ...
The problem is your call to lower() is converting whatever the result is from the inner statements into a string literal.

You need to do it this way:

Code: Select all

var lowername := lower(name);
if (lowername[staffList[i]])
  ...

While you are at it, your list of names has two problems that maybe are minor.

First, you don't have 'lady' in it, though you have 'lord'.

Second, your list would prevent a name like 'paradigm' because it just checks for 'gm' together. Maybe split the check for 'gm' into a separate check to see if the name starts with 'gm', like so:

Code: Select all

if (lower(name[1,2])=="gm"))
  ...
Juzeph
New User
Posts: 23
Joined: Sun Apr 15, 2007 5:58 pm

Post by Juzeph »

Xenawar wrote:

Code: Select all

var lowername := lower(name);
if (lowername[staffList[i]])
  ...
perfectly

The words of staffList still are not all, alone made a rough draft.

Good remembered on GM, does not decide placing "gm " (space).
Post Reply