if(findtext(src.key,Admins))
src<<"You are an Admin"
else
src<<"Haha you arnt admin"
Problem description: Well i added me and a friend to this list and tryed with another friend to test if it works but this code gives everyone Admin. Any idea? =P
ID:264645
Feb 3 2010, 11:38 am
|
|
Code:
if(findtext(src.key,Admins)) Problem description: Well i added me and a friend to this list and tryed with another friend to test if it works but this code gives everyone Admin. Any idea? =P |
Feb 3 2010, 11:42 am
|
|
When you're looking for something in a list, you implore Find(), usually formatted as such:
|
1) when doing something and you don't know what you're doing, read the documentation.
2) when you're using functions you don't know what do, read the documentation. 3) read the documentation. BYOND has two things for you to use. One, the guide located on the developer main page. This guide will teach you how to use the basic object structures and how it functions in general. Two, the reference, located on the developer main page AND accessible through the F1 key in Dream Maker (or you can go to Help -> Reference). In this reference, there is reference material for pretty much every variable, function, and object type you might want to use. In this case, you might want to look up what lists are, what findtext does, and you might soon see why findtext does not work with lists (hint: it finds text in another text string, not another list). While looking at the "list" entry in the reference, you will find a list of functions (also called procs). One of which is called "Find." Using the Find() function (which belongs to your list), you can find any object, type path, number, string, or anything that currently exists in your list (if it does). var/list/fruits = new In this example, we create a list of fruits and vegetables and then fill it with the text names of fruits and vegetables. fruits.Find("apple") will look for the text string "apple" within the contents of the list. If it is found, it will return its position in the list. The short version is, if "apple" is found in the list, the if() block will execute. Otherwise, the else block will execute. Alternatively, you can use the "in" operator which returns a normal TRUE or FALSE (at least here it does). if ("apple" in fruits) Have a great day. |
Ok, the findtext() proc is to find text from a string, not a list. Find() proc for lists and in list() are different.
Example of findtext() proc mob/Login() Example of Find() proc for lists var/list/stuff=list("potatoes","apples") Example of in list() var/list/stuff=list("potatoes","apples") I hope that helped. |