Im working on a new library for a friends list command! But I ran into some problems with lists (Just had to be lists!) Anyhow, what happens is it only displays anything for the first person added (For example will say 1 friend logged in on list, and will only display to one person on friends message) The variable says, for example if two friends are added Joe and bob, the variable will be Joe bob.
Hope people like the library after its finished, Here's the coding:
mob/verb/AddFriend(var/mob/characters/M in oview(6))
set category = "Communication"
if(findText("[usr.friendmob]","[M.name]")==1)
usr << "You already befriended [M]!"
else
if(istype(M,/mob/monsters/)||M.npc == 1)
usr << "You cant befriend an NPC!"
else
if(M.gm == 0)
usr.friendmob += "[M.name] "
usr << "You add [M], to your list!"
mob/verb/RemoveFriend(var/mob/characters/M in world)
set category = "Communication"
usr.friendmob -= "[M.name]"
usr << "[M.name] is no longer your friend"
mob/verb/FriendList()
set category = "Communication"
for(var/mob/characters/M in world)
if(findText("[usr.friendmob]","[M.name]")==1)
usr << "[M.prefix] [M.name] [M.suffix][M.title]([M.key])"
usr.counter += 1
usr << "
Friends Online: [counter]"
usr.counter = 0
mob/verb/FriendMessage(msg as text)
set category = "Communication"
for(var/mob/characters/M in world)
if(findText("[usr.friendmob]","[M.name]")==1)
M << "[usr] {Friends Message}: [msg]"
usr << "[usr] {Friends Message}: [msg]"
ID:148076
Jul 20 2003, 5:15 pm
|
|
Jul 20 2003, 5:17 pm
|
|
Okay, first of all, don't use text strings like that. You most definatley CANNOT subtract like you are doing. Use lists. Nowhere in here do I see any use of lists, which would be what you should use here.
|
In response to Garthor
|
|
I used another part of the code this way before. You're right im going to have to define a list :( I dont think it can loop through all the people in the world and work correctly, Im guessing this beceause my other code that uses this works just fine, if it only applies to one person. Ill post again if I have any other problems, Thanks :)
James |