Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-14-2008, 10:05 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
findplayerbycommunityname

Hi,

so when should you use findplayer and when findplayerbycommunityname? o.o
__________________
Reply With Quote
  #2  
Old 01-14-2008, 10:10 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Well, instead of saying.. uhm

'/join Graal884675' to join Graal884675's party, you send his community name serverside, then use findplayerbycommityname().account

just an example tho This is how I use it atm
__________________
Reply With Quote
  #3  
Old 01-14-2008, 10:13 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
findplayer() will work no matter what, but only on account names. If you want to make something that is more friendly to the players, generally you would go with findplayerbycommunityname(). Keep in mind, though, that this will not work for players who have not yet set a community name.

Nowadays, it is good to use both. For example, I found that with text-based commands, it is sometimes hard to go searching for the actual account name. Here's a function that allows you to use the 'account' that you see in the profile of the player:

PHP Code:
function findplayer2(p) {
  
temp.result findplayer(temp.p);
  return (
temp.result != null) ? temp.result findplayerbycommunityname(temp.p);

__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #4  
Old 01-14-2008, 10:13 AM
TSAdmin TSAdmin is offline
Forum Moderator
TSAdmin's Avatar
Join Date: Aug 2006
Location: Australia
Posts: 1,980
TSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud of
I tend to use findPlayerByCommunityName() more often, now, since even if your account is Pre-Graal12345 and is an actual account name, it still uses that as your community name, and won't negatively affect finding of the target.

Biggest issue: It's way too long, even to assign once to a "pl" or what-have-you variable.
__________________
TSAdmin (Forum Moderator)
Welcome to the Official GraalOnline Forums! Where sharing an opinion may be seen as a declaration of war!
------------------------
· User Agreement · Code of Conduct · Forum Rules ·
· Graal Support · Administrative Contacts ·
Reply With Quote
  #5  
Old 01-14-2008, 10:20 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by TSAdmin View Post
I tend to use findPlayerByCommunityName() more often, now, since even if your account is Pre-Graal12345 and is an actual account name, it still uses that as your community name, and won't negatively affect finding of the target.
There's a chance it could negatively effect the finding of the target, because I believe that if a player has not yet set a community name, then findPlayerByCommunityName() doesn't work.

For example:
PHP Code:
findPlayerByCommunityName("Graal12345"); 
returns null.

There's a chance I'm wrong. I don't have the opportunity to test this at the moment .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #6  
Old 01-14-2008, 10:21 AM
TSAdmin TSAdmin is offline
Forum Moderator
TSAdmin's Avatar
Join Date: Aug 2006
Location: Australia
Posts: 1,980
TSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud of
Quote:
Originally Posted by napo_p2p View Post
There's a chance it could negatively effect the finding of the target, because I believe that if a player has not yet set a community name, then findPlayerByCommunityName() doesn't work.

For example, I believe that:
PHP Code:
findPlayerByCommunityName("Graal12345"); 
returns null.
Nah, it's fine with it. I personally haven't set a Community Name, never felt it necessary, but it works on myself, and appears to work also on friends of mine who allowed me to try out scripts on them.
__________________
TSAdmin (Forum Moderator)
Welcome to the Official GraalOnline Forums! Where sharing an opinion may be seen as a declaration of war!
------------------------
· User Agreement · Code of Conduct · Forum Rules ·
· Graal Support · Administrative Contacts ·
Reply With Quote
  #7  
Old 01-14-2008, 10:33 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
It should be findPBCN(); :P
__________________
Deep into the Darkness peering...
Reply With Quote
  #8  
Old 01-14-2008, 11:18 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Angel_Light View Post
It should be findPBCN(); :P
why? o.o
__________________
Reply With Quote
  #9  
Old 01-14-2008, 02:19 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
player.communityname never returns null as far as I know, never ever did for me on Zodiac. I believe it returns your account name if you haven't chosen a communityname yet.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 01-14-2008, 03:59 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by xXziroXx View Post
player.communityname never returns null as far as I know, never ever did for me on Zodiac. I believe it returns your account name if you haven't chosen a communityname yet.
What he said. As far as my tests go with this, it returns the account name if theres no community name chosen yet.
Reply With Quote
  #11  
Old 01-14-2008, 08:37 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
findplayerbycommunityname() is actually first checking for the account (because that is faster), and then trying to find a player with the community name matching the parameter. So it should work in any case - finds players by account name exactly like findplayer(), but also works if you provide a community name. May be findplayer() could be changed to do that as well, might only need to optimize it a little bit.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.