On an 8coop server, I'm trying to teleport the client once he has taken over a bot. The coordinates are retrieved from the first client found who is alive and not a fakeclient.
Problem
The player takes control of the bot, but he isn't teleported. (to the group) He is still spawned at the beginning of the map.
Everything works except the teleport part itself.
PHP Code:
public Action:TimerJoinTeamSurvivors(Handle:timer, any:client)
{
if (IsClientConnected(client))
{
if (IsClientInGame(client))
{
FakeClientCommand(client, "jointeam %i", TEAM_SURVIVOR);
// teleport client to the position of any alive client
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
continue;
}
if (GetClientTeam(i) == TEAM_SURVIVOR)
{
continue;
}
if (!IsFakeClient(i))
{
continue;
}
if (IsPlayerAlive(i))
{
continue;
}
// get the position coordinates of any active living player
new Float:coordinates[3];
GetClientAbsOrigin(i, coordinates);
TeleportEntity(client, coordinates, NULL_VECTOR, NULL_VECTOR);
break;
}
}
}
return Plugin_Stop;
}
For more code click here; the event determining when a fakeclient needs to be created and when the player can be switch to the survivor team.