i replaced the text what you said now its says
Error 1 error C2228: left of '.c_str' must have class/struct/union
You didn't look at my code.
You need open/close parenthesis next to GetName():
Code:
player->GetName[COLOR="#00FF00"]()[/COLOR].c_str();
here you go the whole script
Code:
include "ScriptPCH.h"
#define SONG 11466
class on_login : public PlayerScript
{
public:
on_login() : PlayerScript("on_login") {}
void OnLogin(Player* player)
{
ChatHandler(player->GetSession()).PSendSysMessage("Welcome back online! Your character has been saved to the database, buffed and healed! Now remember to vote every 12 hours on www.endlesswow.net!");
player->GetSession()->SendNotification("WELCOME BACK ONLINE ");
player->GetSession()->SendNotification("! %s !", player->GetName());
player->SetXpRate(1);
if (player->GetMap()->IsBattlegroundOrArena())
{
player->ResurrectPlayer(0.5f);
player->TeleportTo(534, 5541.770020f, -3783.469971f, 1594.910034f, 2.883010f);
}
/*QueryResult result = CharacterDatabase.PQuery("SELECT first_login FROM characters WHERE guid = '%u'", player->GetGUID());
Field* fields = result->Fetch();
uint8 flag = fields[0].GetUInt8();
if (player->HasFlag)
{
player->CastSpell(player, 11543, 1);
player->PlayDirectSound(11466, player);
CharacterDatabase.PExecute("UPDATE characters set first_login = 1 WHERE guid = '%u'", player->GetGUID());
}*/
}
};
void AddSC_on_login()
{
new on_login();
}
How old is your source? I'm asking because the updated "OnLogin" hook has a parameter
"bool firstLogin" to check if it's the player's first login. Overall, if you have an older source you don't need to check the database for the player's "first login", you can check their flags.
Not related to your issue:
I removed your define directive since it wasn't being used
I removed the ScriptPCH.h include since you don't need it (unless your source is a few years old+ longer)
"PSendSysMessage" requires arguments (doesn't necessarily require them but it expects it) ~ I changed it to "SendSysMessage"
Added "c_str()" so player->GetName() will send a const char* instead of a const string
Lastly I added a check to see if the player is dead and in a battleground/arena map to see if the player should be revived
Output:
Code:
class on_login : public PlayerScript
{
public:
on_login() : PlayerScript("on_login") { }
void OnLogin(Player* player)
{
ChatHandler(player->GetSession()).SendSysMessage("Welcome back online! Your character has been saved to the database, buffed and healed! Now remember to vote every 12 hours on www.endlesswow.net!");
player->GetSession()->SendNotification("WELCOME BACK ONLINE ");
player->GetSession()->SendNotification("! %s !", player->GetName().c_str());
player->SetXpRate(1);
if (!player->IsAlive && player->GetMap()->IsBattlegroundOrArena())
{
player->ResurrectPlayer(0.5f);
player->TeleportTo(534, 5541.770020f, -3783.469971f, 1594.910034f, 2.883010f);
}
/*QueryResult result = CharacterDatabase.PQuery("SELECT first_login FROM characters WHERE guid = '%u'", player->GetGUID());
Field* fields = result->Fetch();
uint8 flag = fields[0].GetUInt8();
if (player->HasFlag)
{
player->CastSpell(player, 11543, 1);
player->PlayDirectSound(11466, player);
CharacterDatabase.PExecute("UPDATE characters set first_login = 1 WHERE guid = '%u'", player->GetGUID());
}*/
}
};
void AddSC_on_login()
{
new on_login();
}
If your disconnection problems are still happening, it must be another custom script causing it, it's on your side or it's a core issue.