Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-18-2007, 06:17 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
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;
}

Reply With Quote
  #2  
Old 09-18-2007, 07:34 PM
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
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>"
__________________

Last edited by Chompy; 09-18-2007 at 07:47 PM..
Reply With Quote
  #3  
Old 09-18-2007, 07:42 PM
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 Chompy View Post
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.
__________________
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 09-18-2007, 07:46 PM
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 napo_p2p View Post
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()..
__________________
Reply With Quote
  #5  
Old 09-18-2007, 09:49 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
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...)
Reply With Quote
  #6  
Old 09-20-2007, 03:47 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
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?
__________________
Reply With Quote
  #7  
Old 09-20-2007, 06:35 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 Googi View Post
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.
__________________
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
  #8  
Old 09-20-2007, 03:51 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
Quote:
Originally Posted by Googi View Post
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.
Reply With Quote
  #9  
Old 11-03-2007, 02:50 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
You should have some sort of auto-deleter.
If someone signs-up and has no activity for a month, then their account is deleted.
__________________
Trying to be nice now...
Reply With Quote
  #10  
Old 11-03-2007, 04:20 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by bscharff View Post
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.
__________________
Reply With Quote
  #11  
Old 11-03-2007, 09:57 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 Inverness View Post
For trial accounts only.
Dur!

__________________
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
  #12  
Old 11-03-2007, 02:11 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
Well trial accounts cannot set their community name anyway.
Reply With Quote
  #13  
Old 11-10-2007, 01:58 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
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.
__________________
Trying to be nice now...
Reply With Quote
  #14  
Old 11-18-2007, 01:51 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 bscharff View Post
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.
__________________
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
  #15  
Old 11-25-2007, 12:35 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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!";

__________________
Reply With Quote
  #16  
Old 11-25-2007, 12:58 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by cbkbud View Post
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?

Last edited by Skyld; 11-25-2007 at 01:12 AM..
Reply With Quote
  #17  
Old 11-25-2007, 01:21 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Skyld View Post
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
__________________
Reply With Quote
  #18  
Old 12-16-2007, 10:54 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
New function: findplayerbycommunityname(string)
__________________
Reply With Quote
  #19  
Old 12-18-2007, 04:02 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
New function: findplayerbycommunityname(string)
And that returns a player object I assume?
__________________
Reply With Quote
  #20  
Old 12-18-2007, 06:14 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 cbkbud View Post
And that returns a player object I assume?
What else would it return?
__________________
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
  #21  
Old 12-18-2007, 11:04 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by napo_p2p View Post
What else would it return?
The account, name, rank, serial number?
__________________
Reply With Quote
  #22  
Old 12-19-2007, 12:32 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by cbkbud View Post
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.
__________________
Reply With Quote
  #23  
Old 12-19-2007, 01:57 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
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!
__________________
Reply With Quote
  #24  
Old 12-19-2007, 05:47 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by cbkbud View Post
Sorry, didn't realize that. I was way out of line for asking a question like that!
Yes, best learn to use common sense.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:06 AM.


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