function FirstLogin(event, player)
CharDBExecute("INSERT INTO [COLOR="#FF0000"]create arena team query here[/COLOR])
CharDBExecute("UPDATE `characters` SET `[COLOR="#FF0000"]arenateam?[/COLOR]` where `guid` = "..player:GetGUIDLow())
if not query then
return
end
end
RegisterPlayerEvent(30, FirstLogin)
Code:function FirstLogin(event, player) CharDBExecute("INSERT INTO [COLOR="#FF0000"]create arena team query here[/COLOR]) CharDBExecute("UPDATE `characters` SET `[COLOR="#FF0000"]arenateam?[/COLOR]` where `guid` = "..player:GetGUIDLow()) if not query then return end end RegisterPlayerEvent(30, FirstLogin)
Places in red need to be changed, I don't remember what the TC database structure looks like. For all I know the all the queries could be wrong, but it would look somewhat like this. It should create a new arena team and then place that character into it the first time they log in. Like Tommy said it could be buggy because you are the only member.
class arenacreate_login : public PlayerScript
{
public:
arenacreate_login() : PlayerScript("arenacreate_login") {}
void OnLogin(Player* player, bool firstLogin)
{
if (player->GetTotalPlayedTime() < 3)
{
int i = 1;
std::stringstream teamName;
teamName << player->GetName();
do
{
if (sArenaTeamMgr->GetArenaTeamByName(teamName.str()) != NULL) // teamname exist, so choose another name
{
teamName.str(std::string());
teamName << player->GetName() << i++;
}
else
break;
} while (i < 100); // should never happen
// Create arena team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(player->GetGUID(), ARENA_TEAM_5v5, teamName.str(), 4283124816, 45, 4294242303, 5, 4294705149))
{
delete arenaTeam;
return false;
}
// Register arena team
sArenaTeamMgr->AddArenaTeam(arenaTeam);
arenaTeam->AddMember(player->GetGUID());
return true;
}
}
};
void AddSC_arenacreate_login()
{
new arenacreate_login;
}
#include "ScriptPCH.h"
#include "ArenaTeam.h"
#include "ArenaTeamMgr.h"
class arenacreate_login : public PlayerScript
{
public:
arenacreate_login() : PlayerScript("arenacreate_login") { }
std::string GetArenaTeamName(std::string const& playerName)
{
// Use player name as team name
std::string teamName = playerName;
for (int i = 1; i <= 1000; ++i)
{
// Is free team name, return it
if (!sArenaTeamMgr->GetArenaTeamByName(teamName))
return teamName;
// Increase number at end of team name
teamName = playerName;
teamName += i;
}
// Return empty string if couldnt find a free team name
return "";
}
void OnLogin(Player* player, bool firstLogin) override
{
// Error, not first login
if (!firstLogin)
return;
std::string teamName = GetArenaTeamName(player->GetName());
// Error, no free name found. Need to handle this!
if (teamName.empty())
return;
// Create arena team, leader is added automatically to team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(player->GetGUID(), ARENA_TEAM_5v5, teamName, 4283124816, 45, 4294242303, 5, 4294705149))
{
// Error, couldnt create arena team. Invalid name? Need to handle this!
delete arenaTeam;
return;
}
// Register arena team
sArenaTeamMgr->AddArenaTeam(arenaTeam);
}
};
void AddSC_arenacreate_login()
{
new arenacreate_login();
}
I already disabled arena team invites for that arena type. And is possible to add same team names for every arena team (example: Arena Team name of every player will be like: 1vs1 Arena Team ) ?