Page 1 of 1

player unique ID

Posted: Sun Oct 08, 2017 5:33 am
by Ememjr
how do i get a player( character)s uniqueid if all i know is their name
and they do not have to be logged in

this is for my
PlayerHouseAccessUpdateMsg function that is sent to client when adding a player to your house access list

Code: Select all

<Struct Name="WS_PlayerHouseAccessUpdateMsg" ClientVersion="1" OpcodeName="OP_PlayerHouseAccessUpdateMsg">
	<Data ElementName="unique_id" Type="int64" /> <!-- players unique_id -->
	<Data ElementName="access_delete" Type="int8" />
	<Data ElementName="access_name" Type="EQ2_16Bit_String" />
 	<Data ElementName="access_level" Type="int8" />
</Struct>

Re: player unique ID

Posted: Sun Oct 08, 2017 3:00 pm
by Jabantiz
If they are not logged in I do not believe it is possible to get the id so you will need to make a new function to hit the DB to get it.

Re: player unique ID

Posted: Sun Oct 08, 2017 4:18 pm
by xinux
Yea we started running in to the same issue over at vgoemu and we ended up making the the player unique ID the same as the character_id so we could grab it if they were on or offline.

Re: player unique ID

Posted: Sun Oct 08, 2017 10:52 pm
by Ememjr
so would you say the unique character id would be the ID from characters table?

Re: player unique ID

Posted: Mon Oct 09, 2017 4:48 am
by tyrbo
Yes.

Re: player unique ID

Posted: Mon Oct 09, 2017 3:19 pm
by Jabantiz
Yes, and the player already loads it but you can't get it if the player is offline.

Re: player unique ID

Posted: Thu Oct 12, 2017 2:46 pm
by Ememjr
well it appears that we already have a function that get the unique id by name
but as usual how do i call it from housingpackets.cpp

Code: Select all

int32 WorldDatabase::GetCharacterID(const char* name) {
	int32 id = 0;
	Query query;
	if (name) {
		MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT `id` FROM `characters` WHERE `name`='%s'", name);
		if (result && mysql_num_rows(result) > 0) {
			MYSQL_ROW row;
			row = mysql_fetch_row(result);
			id = atoul(row[0]);
		}
	}
	return id;
}

Re: player unique ID

Posted: Thu Oct 12, 2017 3:27 pm
by Jabantiz
First make sure world database is included then an "extern WorldDatabase database" under the includes then just do database.GetCharacterID()

Re: player unique ID

Posted: Fri Oct 13, 2017 3:58 am
by Ememjr
lol thanks that worked,
i had tired

Code: Select all

#include "../Worlddatabase.h"
and

Code: Select all

extern WorldDatabase database;
but i did not try them both at the same time