Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   findplayerbycommunityname (https://forums.graalonline.com/forums/showthread.php?t=78345)

projectigi 01-14-2008 10:05 AM

findplayerbycommunityname
 
Hi,

so when should you use findplayer and when findplayerbycommunityname? o.o

Chompy 01-14-2008 10:10 AM

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 :p This is how I use it atm

napo_p2p 01-14-2008 10:13 AM

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);



TSAdmin 01-14-2008 10:13 AM

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.

napo_p2p 01-14-2008 10:20 AM

Quote:

Originally Posted by TSAdmin (Post 1369710)
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 :(.

TSAdmin 01-14-2008 10:21 AM

Quote:

Originally Posted by napo_p2p (Post 1369711)
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.

Angel_Light 01-14-2008 10:33 AM

It should be findPBCN(); :P

Chompy 01-14-2008 11:18 AM

Quote:

Originally Posted by Angel_Light (Post 1369714)
It should be findPBCN(); :P

why? o.o

xXziroXx 01-14-2008 02:19 PM

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.

Crow 01-14-2008 03:59 PM

Quote:

Originally Posted by xXziroXx (Post 1369724)
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.

Admins 01-14-2008 08:37 PM

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.


All times are GMT +2. The time now is 01:52 PM.

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