PDA

View Full Version : function findName()


Mark Sir Link
09-18-2007, 07:17 PM
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!


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, 08:34 PM
You should use allplayers tho..

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


public function getAccountName(community) {
temp.getaccount = 0;

for (temp.i: allplayers) {
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:


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

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

napo_p2p
09-18-2007, 08:42 PM
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:
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, 08:46 PM
Hmm... for getCommunityName, couldn't you just do:
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, 10: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, 04: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, 07:35 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?

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, 04:51 PM
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
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
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
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:

public function findName( i )
{
this.look = { "account", "communityname", "nick", "id" };

for ( temp.a : allplayers )
{
for ( temp.n : this.look )
{
if ( makevar( "temp.a." @ temp.n ) == i )
{
return temp.a.account;
}
}
}

for ( temp.a : allplayers )
{
for ( temp.n : this.look )
{
if ( makevar( "temp.a." @ temp.n ).starts( i ) )
{
return temp.a.account;
}
}
}

return "Error!";
}

Skyld
11-25-2007, 12:58 AM
return "Error!";
return false;
Returning false makes it easier to do a quick negative check:
if (!this.findName("foo"))
3,000th post and this is all I had to say?

cbk1994
11-25-2007, 01:21 AM
return false;
Returning false makes it easier to do a quick negative check:
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
New function: findplayerbycommunityname(string)

And that returns a player object I assume?

napo_p2p
12-18-2007, 06:14 AM
And that returns a player object I assume?

What else would it return? :confused:

cbk1994
12-18-2007, 11:04 PM
What else would it return? :confused:

The account, name, rank, serial number?

Inverness
12-19-2007, 12:32 AM
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
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
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.