Hello all,
So I am having a little problem,
some information:
I need 2 players that get randomly selected from a vector stand next to each other so they can battle, the vector saves the player guid whenever a player signs up with a command ( this is already done before the teleporting) I got this:
bool placement = false;
int max = players - 1;
for(uint32 i = 2; i < 1; i--)
{
uint32 random = urand (0,max);
if(!placement)
{
Contestors.push_back(Contestors[random]);
Contestors.erase(Contestors.begin()+random);
Player* selected = sObjectAccessor->FindPlayer(Contestors[max + 1]);
selected->TeleportTo(1, -3737.089600f, 1093.636475f, 131.969437f, 3.150863f);
max--;
placement = true;
}
else
{
Contestors.push_back(Contestors[random]);
Contestors.erase(Contestors.begin()+random);
Player* selected = sObjectAccessor->FindPlayer(Contestors[max + 1]);
selected->TeleportTo(1, -3774.096924f, 1096.924805f, 131.969269f, 6.176457f);
max--;
}
I want to loop 2 times cause I made an event of it that will be called everytime when a 1v1 battle must start, so thats why the i = 2.
the placement bool is just for other teleporting coordinates, I made a scenario if the random number was 0 and it should work, only its not, no crash but no teleport either.
It should work, I made my own scenario if the random number = 0
so when random = 0, there will be added a new element with the push.back, element number 1 since I tested it on my own and I am element 0, so the new element ( number 1) got the GUID of element 0 so element 0 and 1 are both me, then element number 0 gets erased with the erase cause Contestors.begin() + random would still be 0 since random is 0, then the objectaccessor should find the player with the guid that is in element max +1, which is players - 1, I only signed up so players = 1, so that will make the calculation 1 - 1 + 1 = 1, so it should find the player with the guid of element 1, which is me, and then teleport me, but like I said this doenst work.