Jump to content

Recommended Posts

 

There is a existing command for this?

rid2name(getcharid(3));

 

rid2name() will only return the name of an online character, using their RID; additionally, the character name may not be produced properly, since the RID for a player is the account ID. getcharname() queries the `char` table for the name of the specified character ID, regardless of whether or not they are online. I've purposefully released an Account Remover utility simultaneously to demonstrate how this function may be used efficiently.

 

Here's an excerpt in which getcharname() is used to list all character names on an account:

					mes .npc_name$;					switch (@menu) {						case 1:	// View list of characters							if (query_sql("SELECT `char_id` FROM `char` WHERE `account_id` = '"+ .@account_id +"' ORDER BY `name` ASC", .@char_id[0])) {								mes "List of characters:";																for (.@i = 0; .@i < getarraysize(.@char_id); .@i++) {									mes "- ^0000FF"+ getcharname(.@char_id[.@i]) +"^000000";								}															} else {								mes "There are no characters on this account.";							}														next;							break;

 

Documentation for rid2name() can be found in doc/script_commands.txt.

Share this post


Link to post
Share on other sites

Since you brought up the list of characters thing as an example. Supposed to be i would like to get all the character name of all characters on my server. Your function would only get the first 128 values ( 128 character names supposed to be ). A suggestion from me that you might want to add into your function is to support > 128 values. That will make your function more flexible and more awesome. Anyway good job! :P

Share this post


Link to post
Share on other sites

@Mumbles

Question: What if for example, the character deletion is still ongoing, but suddenly someone logins that same account, what will happen then?

:)

Share this post


Link to post
Share on other sites

Since you brought up the list of characters thing as an example. Supposed to be i would like to get all the character name of all characters on my server. Your function would only get the first 128 values ( 128 character names supposed to be ). A suggestion from me that you might want to add into your function is to support > 128 values. That will make your function more flexible and more awesome. Anyway good job!  :P

 

The only purpose of getcharname() is to return a single character's name, by querying the database with an ID; the example above that returns all character names of the account being invoked uses an array filled by query_sql(), which may multiple results. This limitation is not exclusive to getcharname(), as any array filled in any manner (currently) can only store 128 values. It is my understanding that the limitation on arrays may soon be lifted, though it is up to our core developers or other contributors to do so; I wouldn't know where to begin.

 

 

@Mumbles

Question: What if for example, the character deletion is still ongoing, but suddenly someone logins that same account, what will happen then?

:)

 

If you're deleting an account, I recommend you ban the account prior to doing so; if the system hosting your database has at least 512MB RAM, the deletion process should only take a second (if not less). Despite this, a check is made to ensure that the account is not logged in when the invoking user chooses to confirm removal.

 

This check can be found on lines 80-86:

						case 3:	// Confirm removal							if (isloggedin(.@account_id)) {								mes "All characters from this account must be offline before proceeding.";								next;																break;							}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.