simple attempt to fix potential teleport bug by excluding all non surf maps

This commit is contained in:
jenz 2022-01-16 15:45:38 +01:00
parent ab8a2359d8
commit ae9ea5083a

View File

@ -12,8 +12,8 @@ public Plugin myinfo =
version = "1.0", version = "1.0",
url = "www.unloze.com" url = "www.unloze.com"
}; };
float bot_finished_surf_coords[MAXPLAYERS][3]; float bot_finished_surf_coords[MAXPLAYERS + 1][3] ;
bool is_forward_called[MAXPLAYERS]; bool is_forward_called[MAXPLAYERS + 1];
char map_coorindates[65][256]; char map_coorindates[65][256];
char map_recordname[65][256]; char map_recordname[65][256];
Database g_dDatabase; Database g_dDatabase;
@ -69,17 +69,24 @@ public void reset_client(int client)
//BotMimic_IsPlayerMimicing() is true in update_mimic_coords before the BotMimic_OnPlayerMimicLoops forward is called //BotMimic_IsPlayerMimicing() is true in update_mimic_coords before the BotMimic_OnPlayerMimicLoops forward is called
public int BotMimic_OnPlayerMimicLoops(int client) public int BotMimic_OnPlayerMimicLoops(int client)
{ {
//PrintToChatAll("BotMimic_OnPlayerMimicLoops bot_finished_surf_coords[client][0]: %f", bot_finished_surf_coords[client][0]); char map_name[256];
if (bot_finished_surf_coords[client][0] != 0.0) GetCurrentMap(map_name, sizeof(map_name));
if (!is_bot_player(client) || StrContains(map_name, "ze_surf", false) == -1)
{ {
BotMimic_StopPlayerMimic(client);
//on ze2 they were teleported to end of world or maybe 0.0 0.0 0.0
TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR);
reset_client(client); reset_client(client);
} }
else else
{ {
is_forward_called[client] = true; if (bot_finished_surf_coords[client][0] != 0.0)
{
BotMimic_StopPlayerMimic(client);
TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR);
reset_client(client);
}
else
{
is_forward_called[client] = true;
}
} }
} }
@ -199,9 +206,11 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[]
public void OnMapStart() public void OnMapStart()
{ {
char map_name[256];
GetCurrentMap(map_name, sizeof(map_name));
if (!g_dDatabase) if (!g_dDatabase)
Database.Connect(SQL_OnDatabaseConnect, "bot_surfing"); Database.Connect(SQL_OnDatabaseConnect, "bot_surfing");
else else if(StrContains(map_name, "ze_surf", false) != -1)
{ {
select_map_related_surfs(); select_map_related_surfs();
CreateTimer(0.30, update_mimic_coords, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(0.30, update_mimic_coords, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
@ -244,8 +253,13 @@ public void SQL_FinishedQuery_creating_tables(Database db, DBResultSet results,
{ {
LogError("Query error: %s", error); LogError("Query error: %s", error);
} }
select_map_related_surfs(); char map_name[256];
CreateTimer(0.30, update_mimic_coords, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); GetCurrentMap(map_name, sizeof(map_name));
if (StrContains(map_name, "ze_surf", false) != -1)
{
select_map_related_surfs();
CreateTimer(0.30, update_mimic_coords, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
} }