19/09/2021, 10:14 PM
(Última modificación: 21/09/2021, 10:34 PM por Null2020. Edited 1 time in total.)
Saludos a todos, actualmente estoy usando el Bot Spectating de OsweRRR;.
https://amxmodx-es.com/showthread.php?tid=21057
El error que tengo es que me tumba el servidor, al ponerlo funciona perfecto pero al cambiar de mapa se cae y me tira error tengo que desactivar el plugin para que el servidor pueda arrancar bien. aquí dejo el error que tira para ver si alguien podría ayudarme se lo agradecería de antemano.
(map "de_dust2") GetClient_t: invalid id provided: -256156849 no solo pasa con dust2, pasa con los demas mapas.
Aqui les dejo el codigo.
https://amxmodx-es.com/showthread.php?tid=21057
El error que tengo es que me tumba el servidor, al ponerlo funciona perfecto pero al cambiar de mapa se cae y me tira error tengo que desactivar el plugin para que el servidor pueda arrancar bien. aquí dejo el error que tira para ver si alguien podría ayudarme se lo agradecería de antemano.
(map "de_dust2") GetClient_t: invalid id provided: -256156849 no solo pasa con dust2, pasa con los demas mapas.
Aqui les dejo el codigo.
Código PHP:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <engine>
new const BOT_CLASSNAME[] = "BOT_ENT"
new ent_think
new pCvar_MaxPlayers
new Count_Players
new Count_Bots
new const Bot_Names[][] =
{
"bot 1",
"bot 2",
"bot 3",
"bot 4",
"bot 5"
}
public plugin_init()
{
register_plugin("Bots Spectators", "1.0", "OsweRRR;")
pCvar_MaxPlayers = register_cvar("bot_maxplayers", "20")
register_forward(FM_ClientDisconnect, "pfn_Client_Disconnect")
ent_think = create_entity("info_target")
if(ent_think)
{
entity_set_string(ent_think, EV_SZ_classname, BOT_CLASSNAME)
register_think(BOT_CLASSNAME, "pfn_Bot_Task")
}
}
public plugin_cfg()
{
new i
while(i < sizeof Bot_Names)
{
CS_Create_Bot(i++)
}
}
public client_putinserver(id)
{
if(is_user_bot(id))
{
Count_Bots++
return
}
Count_Players++
entity_set_float(ent_think, EV_FL_nextthink, get_gametime() + 1.0)
}
public pfn_Client_Disconnect(id)
{
if(is_user_bot(id))
{
Count_Bots--
return
}
Count_Players--
entity_set_float(ent_think, EV_FL_nextthink, get_gametime() + 1.0)
}
public pfn_Bot_Task(ent)
{
if(!is_valid_ent(ent))
{
return
}
if(Count_Players >= get_pcvar_num(pCvar_MaxPlayers))
{
static MaxPlayers, i
if(!MaxPlayers)
{
MaxPlayers = get_maxplayers()
}
for(i = 1; i <= MaxPlayers; i++)
{
if(is_user_connected(i) && is_user_bot(i))
{
server_cmd("kick #%d ^"Server full.^"", get_user_userid(i))
}
}
}
else
{
if(Count_Bots != sizeof Bot_Names)
{
plugin_cfg()
}
}
}
CS_Create_Bot(const name_id)
{
new id = engfunc(EngFunc_CreateFakeClient, Bot_Names[name_id])
if(pev_valid(id))
{
engfunc(EngFunc_FreeEntPrivateData, id)
dllfunc(MetaFunc_CallGameEntity, "player", id)
set_pev(id, pev_flags, pev(id, pev_flags) | FL_FAKECLIENT)
dllfunc(DLLFunc_ClientConnect, id, Bot_Names[name_id], "127.0.0.1")
dllfunc(DLLFunc_ClientPutInServer, id)
engclient_cmd(id, "jointeam", "6")
}
return id
}