Naja bei den was du kopiert hast hab ich nur ein ">" vergessen~
Richtig:
this->Char->user_class = toInt(packet[1]);
Char->MapPoint.map = this->Char->MapPoint.map;
und so wie es ist läuft dieser Source teil bei Sons of Erenia~
bei
this->Char->user_class = toInt(packet[1]);
ändert er den char seine klasse auf das packet und wird in der db und im spiel gespeichert das heißt er kann map wechsel machen und er bleibt z.b. mager ö_ö
hier wird einfach abgefragt wohin er teleportiert wird
Char->MapPoint.map = this->Char->MapPoint.map;
"this->Char->MapPoint.map;" = momentane position des Chars~
Natürlich könnte man nun in den teil noch reinhauen falls wer schon ein job hat das sieht dann ca. so aus
Code:
if (packet[0] == "$Class_change" && packet.size() == 2)
{
if(packet[1] == "0")
{
ss << "say 0 0 11 Du kannst nicht wieder Abenteurer werden!";
ss.str("");
Char->Send(ss.str());
}
else if(this->Char->user_class > 0)
{
ss << "say 0 0 11 Du hast bereits dein Job gewechselt";
ss.str("");
Char->Send(ss.str());
}
else if(packet[1] == "1")
{
this->Char->user_class = toInt(packet[1]);
Map::MapIOPool->RemoveFromMap(Char);
Char->MapPoint.map = this->Char->MapPoint.map;
Char->MapPoint.x = this->Char->MapPoint.x;
Char->MapPoint.y = this->Char->MapPoint.y;
Map::MapIOPool->AddToMap(Char);
ss << "say 0 0 11 Du bist nun Schwertkämpfer";
Char->Send(ss.str());
ss.str("");
ss << "tit " << (this->Char->user_class==0?"Abenteurer":(this->Char->user_class==1?"Schwertkämpfer":(this->Char->user_class==2?"Bogenschütze":"Magier"))) << " " <<this->Char->name;
this->Send(ss.str());
ss.str("");
ss << "UPDATE tbl_chars SET Class = "<< this->Char->user_class << " WHERE Char_ID = " << this->Char->id;
MySql::db->doQuery(ss.str());
ss.str("");
ss << "in 1 " << Char->name << " - " << Char->id << " " << Char->MapPoint.x << " " << Char->MapPoint.y << " " << Char->dir<< " " << (Char->isGm?2:0)<< " " << Char->sex << " " << Char->Hair.style << " " << Char->Hair.color << " " << Char->user_class << " " << Char->Equip.Head << "." << Char->Equip.Armor.id << "." << Char->Equip.Weapon.id << "." << Char->Equip.Weapon2.id << "." << Char->Equip.Mask << ".-1 " << HMath::percent(Char->Stat.CurrentHp, Char->Stat.MaxHp) <<" "<< HMath::percent(Char->Stat.CurrentMp, Char->Stat.CurrentMp) <<" 0 -1 4 4 " << Char->Equip.Fee1 << " " << Char->Equip.Fee << " 0 " << (Char->Sp.inUsing?Char->Sp.sprite:0) << " 0 0 -1 - " << Char->Reputation_Icon << " 0 " << (Char->Sp.inUsing?Char->Sp.upgrade:0) << " 0 " << (Char->Sp.inUsing?Char->Sp.wings:0) << " " << Char->Level.Level << " 0 " << (Char->Sp.wings_arena?1:0);
Map::MapIOPool->SendMap(this->Char,ss.str(),false);
ss.str("");
}
else if(packet[1] == "2")
{
this->Char->user_class = toInt(packet[1]);
Map::MapIOPool->RemoveFromMap(Char);
Char->MapPoint.map = this->Char->MapPoint.map;
Char->MapPoint.x = this->Char->MapPoint.x;
Char->MapPoint.y = this->Char->MapPoint.y;
Map::MapIOPool->AddToMap(Char);
ss << "say 0 0 11 Du bist nun Bogenschütze";
Char->Send(ss.str());
ss.str("");
ss << "tit " << (this->Char->user_class==0?"Abenteurer":(this->Char->user_class==1?"Schwertkämpfer":(this->Char->user_class==2?"Bogenschütze":"Magier"))) << " " <<this->Char->name;
this->Send(ss.str());
ss.str("");
ss << "UPDATE tbl_chars SET Class = "<< this->Char->user_class << " WHERE Char_ID = " << this->Char->id;
MySql::db->doQuery(ss.str());
ss.str("");
ss << "in 1 " << Char->name << " - " << Char->id << " " << Char->MapPoint.x << " " << Char->MapPoint.y << " " << Char->dir<< " " << (Char->isGm?2:0)<< " " << Char->sex << " " << Char->Hair.style << " " << Char->Hair.color << " " << Char->user_class << " " << Char->Equip.Head << "." << Char->Equip.Armor.id << "." << Char->Equip.Weapon.id << "." << Char->Equip.Weapon2.id << "." << Char->Equip.Mask << ".-1 " << HMath::percent(Char->Stat.CurrentHp, Char->Stat.MaxHp) <<" "<< HMath::percent(Char->Stat.CurrentMp, Char->Stat.CurrentMp) <<" 0 -1 4 4 " << Char->Equip.Fee1 << " " << Char->Equip.Fee << " 0 " << (Char->Sp.inUsing?Char->Sp.sprite:0) << " 0 0 -1 - " << Char->Reputation_Icon << " 0 " << (Char->Sp.inUsing?Char->Sp.upgrade:0) << " 0 " << (Char->Sp.inUsing?Char->Sp.wings:0) << " " << Char->Level.Level << " 0 " << (Char->Sp.wings_arena?1:0);
Map::MapIOPool->SendMap(this->Char,ss.str(),false);
ss.str("");
}
else if(packet[1] == "3")
{
this->Char->user_class = toInt(packet[1]);
ss << "say 0 0 11 Du bist nun Magier";
Char->Send(ss.str());
ss.str("");
ss << "tit " << (this->Char->user_class==0?"Abenteurer":(this->Char->user_class==1?"Schwertkämpfer":(this->Char->user_class==2?"Bogenschütze":"Magier"))) << " " <<this->Char->name;
this->Send(ss.str());
ss.str("");
ss << "UPDATE tbl_chars SET Class = "<< this->Char->user_class << " WHERE Char_ID = " << this->Char->id;
MySql::db->doQuery(ss.str());
ss.str("");
ss << "in 1 " << Char->name << " - " << Char->id << " " << Char->MapPoint.x << " " << Char->MapPoint.y << " " << Char->dir<< " " << (Char->isGm?2:0)<< " " << Char->sex << " " << Char->Hair.style << " " << Char->Hair.color << " " << Char->user_class << " " << Char->Equip.Head << "." << Char->Equip.Armor.id << "." << Char->Equip.Weapon.id << "." << Char->Equip.Weapon2.id << "." << Char->Equip.Mask << ".-1 " << HMath::percent(Char->Stat.CurrentHp, Char->Stat.MaxHp) <<" "<< HMath::percent(Char->Stat.CurrentMp, Char->Stat.CurrentMp) <<" 0 -1 4 4 " << Char->Equip.Fee1 << " " << Char->Equip.Fee << " 0 " << (Char->Sp.inUsing?Char->Sp.sprite:0) << " 0 0 -1 - " << Char->Reputation_Icon << " 0 " << (Char->Sp.inUsing?Char->Sp.upgrade:0) << " 0 " << (Char->Sp.inUsing?Char->Sp.wings:0) << " " << Char->Level.Level << " 0 " << (Char->Sp.wings_arena?1:0);
Map::MapIOPool->SendMap(this->Char,ss.str(),false);
ss.str("");
}
}
edit: hier her kommt "Char"
Code:
if(packet[0] == "select" && packet.size()==2)
{
if(toInt(packet[1]) >= 0 && toInt(packet[1]) <= 2)
{
ss << "SELECT * FROM tbl_chars WHERE Account_ID=" << this->Acount->Id << " AND Pos=" << packet[1] << ";";
MySql::ResultSet *res = MySql::db->executeQuery(ss.str());
if(res->RowCount() != 0)
{
res->Next();
this->Char->id = res->getInt(0);
this->Char->name = res->getString(3);
this->Char->sex = res->getInt(4);
this->Char->Hair.style = res->getInt(5);
this->Char->Hair.color = res->getInt(6);
this->Char->user_class = res->getInt(7);
this->Char->Level.Level = res->getInt(8);
this->Char->Level.jobLevel = res->getInt(9);
this->Char->MapPoint.map = res->getInt(10);
this->Char->MapPoint.x = res->getInt(11);
this->Char->MapPoint.y = res->getInt(12);
this->Char->Sp.inUsing = false;
this->Char->Reputation = res->getInt(34);
this->Char->miniland = res->getInt(36);
this->Char->Reputation_Icon = ReputationIconLoad(Char->Reputation);
this->Char->isGm = this->Acount->isGm;
this->Char->Equip.Fee = res->getInt(17);
this->Char->Equip.Fee1 = res->getInt(18);
this->Char->Equip.Weapon.id = res->getInt(19);
this->Char->Equip.Armor.id = res->getInt(20);
this->Char->Equip.Head = res->getInt(21);
this->Char->Equip.Hand = res->getInt(22);
this->Char->Equip.Shoe = res->getInt(23);
this->Char->Equip.Weapon2.id = res->getInt(24);
this->Char->Equip.Neck = res->getInt(25);
this->Char->Equip.Ring1 = res->getInt(26);
this->Char->Equip.Ring2 = res->getInt(27);
this->Char->Equip.Mask = res->getInt(28);
this->Char->Equip.Fairy = res->getInt(29);
this->Char->Equip.Amu = res->getInt(30);
this->Char->Sp.sprite = res->getInt(31);
this->Char->Equip.Event_Dress = res->getInt(32);
this->Char->Equip.Event_Hat = res->getInt(33);
this->Char->speed = 11;
this->Char->LastPortal = 0;
this->Char->Stat.CurrentHp = res->getInt(15);
this->Char->Stat.CurrentMp = res->getInt(16);
this->Char->Stat.MaxHp = Player::StatHandler->GetHp(Char);
this->Char->Stat.MaxMp = Player::StatHandler->GetMp(Char);
this->Char->inGroup = false;
this->Char->LastPulse = clock() / (double)CLOCKS_PER_SEC;
this->Char->PulseNum = 0;
this->Char->inv0 = HCrypto::split(res->getString(13),' ')[0];
this->Char->inv1 = HCrypto::split(res->getString(13),' ')[1];
this->Char->inv2 = HCrypto::split(res->getString(13),' ')[2];
this->Char->gold = res->getInt(14);
this->Char->dir = 0;
this->Char->Partner.vnum = res->getInt(36);
this->Char->Partner.id = res->getInt(37);
this->Char->Partner.name = res->getInt(38);
this->Char->Familie.name = res->getInt(40);
this->Char->Familie.position = res->getInt(41);
this->inGame = true;
this->Char->Sp.wings_arena = Char->rested = false;
this->LoadGame();
res->Free();
}
else
{
res->Free();
this->Kill();
}
}
else
this->Kill();
}
Edit: Class Change Update~