Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   function findName() (https://forums.graalonline.com/forums/showthread.php?t=76843)

Mark Sir Link 09-18-2007 06:17 PM

function findName()
 
Use: Find and return a player prioritized by:

1.) Account Name
2.) Display Name

this is used due to the fact that new Graal Online accounts display as
Graal######.


Not a difficult script, but one of conveinence. Please enjoy, if you do copy and paste verbatim, I do not need acknowledgement.

Enjoy!


NPC Code:
function findName(playername)
{
for(i = 0; i < players.size(); i++)
{
if(players[i].account.starts(playername))
{
temp = players[i];
break;
}
if(players[i].nick.starts(playername))
{
temp = players[i];
break;
}
}
return temp;
}


Chompy 09-18-2007 07:34 PM

You should use allplayers tho..

Crow added something like this on Esteria, he did the getAccountName() one..

PHP Code:

public function getAccountName(community) {
  
temp.getaccount 0;
  
  for (
temp.iallplayers) {
    if (
i.communityname == cname) {
      
getaccount i.account;
    }
  }
  return 
getaccount;
}
// hehe, ty Napo
public function getCommunityName(acct) {
  return 
findplayer(acct).communityname;


but personally with your scrit I would do:

PHP Code:

public function findName(n) {
  
temp.out 0;
  for(
temp.allplayers) {
    if(
i.account.pos(n) > -1) {
      
out = {i.accounti.communityname};
      break;
    }else if (
i.communityname.pos(n) > -1) {
      
out = {i.accounti.communityname};
      break;
    }
  }
  return 
out;


would return an array of "<acct>, <communityname>"

napo_p2p 09-18-2007 07:42 PM

Quote:

Originally Posted by Chompy (Post 1348533)
You should use allplayers tho..

Crow added something like this on Esteria, he did the getAccountName() one..


Hmm... for getCommunityName, couldn't you just do:
PHP Code:

function getCommunityName(acct) {
  return 
findplayer(acct).communityname;


???

I'm new to the whole new community name/Graal##### accounts, but that looks like it should work.

Chompy 09-18-2007 07:46 PM

Quote:

Originally Posted by napo_p2p (Post 1348534)
Hmm... for getCommunityName, couldn't you just do:
PHP Code:

function getCommunityName(acct) {
  return 
findplayer(acct).communityname;


???

I'm new to the whole new community name/Graal##### accounts, but that looks like it should work.

Hmm, it should work O.o
lol, never thought of that xD

But this would be solved if Stefan added communityname compatibility to findplayer().. :p

Mark Sir Link 09-18-2007 09:49 PM

Goal wasn't community name, it is in game nickname, which will make spoofing possible but pretty hard.

(scratch that, people couldn't create new accounts to steal nicknames...)

Googi 09-20-2007 03:47 AM

Is it possible for a player to have their community name be the same as the account name of a player who signed up before numbered accounts were instituted?

napo_p2p 09-20-2007 06:35 AM

Quote:

Originally Posted by Googi (Post 1348784)
Is it possible for a player to have their community name be the same as the account name of a player who signed up before numbered accounts were instituted?

I remember seeing a post by Stefan saying that the community name is automatically the same as the account name if the account is not a numbered account. So, I am guessing no.

Admins 09-20-2007 03:51 PM

Quote:

Originally Posted by Googi (Post 1348784)
Is it possible for a player to have their community name be the same as the account name of a player who signed up before numbered accounts were instituted?

That's not possible, we might delete some unused trial accounts sometime though, that would unblock some interesting names.

bscharff 11-03-2007 02:50 AM

You should have some sort of auto-deleter.
If someone signs-up and has no activity for a month, then their account is deleted.

Inverness 11-03-2007 04:20 AM

Quote:

Originally Posted by bscharff (Post 1356019)
You should have some sort of auto-deleter.
If someone signs-up and has no activity for a month, then their account is deleted.

For trial accounts only.

napo_p2p 11-03-2007 09:57 AM

Quote:

Originally Posted by Inverness (Post 1356032)
For trial accounts only.

Dur!

>_<

Admins 11-03-2007 02:11 PM

Well trial accounts cannot set their community name anyway.

bscharff 11-10-2007 01:58 AM

But for like old members that have run out of all of their subscriptions...
How can I explain it...

Like, if they haven't played in a month and have no subscriptions then delete their account so other paying players that want interesting names can have them.

napo_p2p 11-18-2007 01:51 AM

Quote:

Originally Posted by bscharff (Post 1357484)
But for like old members that have run out of all of their subscriptions...
How can I explain it...

Like, if they haven't played in a month and have no subscriptions then delete their account so other paying players that want interesting names can have them.

No, no, no.

It's common for people to not play for an extended period of time, then return.

Also, let's say you quit, and then your subscriptions expire and your account is deleted. Would you like it if someone bought an account and used your account name, and started posing as you? Probably not.

cbk1994 11-25-2007 12:35 AM

Looks like this got pretty off track, but I'll share the one I made for Utopia.


Script class_findname:
PHP Code:

public function findName)
{
  
this.look = { "account""communityname""nick""id" };
  
  for ( 
temp.allplayers )
  {
    for ( 
temp.this.look )
    {
      if ( 
makevar"temp.a." temp.) == )
      {
        return 
temp.a.account;
      }
    }
  }
  
  for ( 
temp.allplayers )
  {
    for ( 
temp.this.look )
    {
      if ( 
makevar"temp.a." temp.).starts) )
      {
        return 
temp.a.account;
      }
    }
  }
  
  return 
"Error!";



Skyld 11-25-2007 12:58 AM

Quote:

Originally Posted by cbkbud (Post 1360258)
PHP Code:

return "Error!"


PHP Code:

return false

Returning false makes it easier to do a quick negative check:
PHP Code:

if (!this.findName("foo")) 

3,000th post and this is all I had to say?

cbk1994 11-25-2007 01:21 AM

Quote:

Originally Posted by Skyld (Post 1360266)
PHP Code:

return false

Returning false makes it easier to do a quick negative check:
PHP Code:

if (!this.findName("foo")) 

3,000th post and this is all I had to say?

You are too picky!

I used that because on my server I was testing it, and I never really changed it ...

I had it on Error! so it would show that in the NPC-Server when I did /npc find plyr

Inverness 12-16-2007 10:54 PM

New function: findplayerbycommunityname(string)

cbk1994 12-18-2007 04:02 AM

Quote:

Originally Posted by Inverness (Post 1364126)
New function: findplayerbycommunityname(string)

And that returns a player object I assume?

napo_p2p 12-18-2007 06:14 AM

Quote:

Originally Posted by cbkbud (Post 1364323)
And that returns a player object I assume?

What else would it return? :confused:

cbk1994 12-18-2007 11:04 PM

Quote:

Originally Posted by napo_p2p (Post 1364342)
What else would it return? :confused:

The account, name, rank, serial number?

Inverness 12-19-2007 12:32 AM

Quote:

Originally Posted by cbkbud (Post 1364391)
The account, name, rank, serial number?

Use some common sense please, its obviously related to findplayer() which returns the player object so its obvious that this would return the player object too, considering its named findplayerbycommunityname(). However it simply returns the one with matching community name rather than matching account.

cbk1994 12-19-2007 01:57 AM

Quote:

Originally Posted by Inverness (Post 1364405)
Use some common sense please, its obviously related to findplayer() which returns the player object so its obvious that this would return the player object too, considering its named findplayerbycommunityname(). However it simply returns the one with matching community name rather than matching account.

Sorry, didn't realize that. I was way out of line for asking a question like that! :rolleyes:

Inverness 12-19-2007 05:47 AM

Quote:

Originally Posted by cbkbud (Post 1364417)
Sorry, didn't realize that. I was way out of line for asking a question like that! :rolleyes:

Yes, best learn to use common sense.


All times are GMT +2. The time now is 07:05 AM.

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