[Modificare plugin] KGB Bots

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
Stai..Ce?
Membru, skill +1
Membru, skill +1
Posts: 366
Joined: 03 Jun 2017, 18:56
Detinator Steam: Da
CS Status: N/A
Detinator server CS: FUN.LALEAGANE.RO
SteamID: jetski_fun
Fond eXtream: 0
Location: str. îngustă, nr. sub fustă.

24 Mar 2018, 10:57

Am o problema cu pluginul kgb bots, si anume:
- Nu imi scoate botii cand serverul este full, dar nici nu ii readauga dupa ce se goleste. P.s: Ca sa-i scot trebuie sa le dau eu kick manual..
Sursa:
Aici | Afiseaza codul
#include < amxmodx >
#include < cstrike >
#include < fakemeta >

enum Cvars
{
	botname1,
	botname2,
        botname3,
	minplayers,
	starttime,
	endtime,
	onecon,
	onebot,
	norounds
};

new const cvar_names[ Cvars ][] =
{
	"amx_botname1",
	"amx_botname2",
        "amx_botname3",
	"amx_minplayers",
	"amx_starttime",
	"amx_endtime",
	"amx_onecon",
	"amx_onebot",
	"amx_norounds"
};

new const cvar_defaults[ Cvars ][] =
{
	"Bot 1",
	"Bot 2",
        "Bot 3",
	"19",
	"00",
	"12",
	"0",
	"0",
	"0"
};

new cvar_pointer[ Cvars ];
new bool:g_isTime = false;
new bool:g_ePlayers = false;
new g_BotNum = 0, g_maxplayers, g_bID1, g_bID2 ,g_bID3;

new const g_ConfigFile[] = "addons/amxmodx/configs/kgbbots.cfg"

public plugin_init() 
{
	register_plugin("KGB Bots", "2.3", "OvidiuS & Desikac")
	register_cvar("kgbbots", "1" , (FCVAR_SERVER|FCVAR_SPONLY))
	
	for ( new Cvars:i = botname1 ; i < Cvars ; i++ )
		cvar_pointer[ i ] = register_cvar( cvar_names[ i ] , cvar_defaults[ i ] );
	
	g_maxplayers = get_maxplayers();
	server_cmd("exec %s", g_ConfigFile)
        set_task(2.0,"CheckConditions")
	//set_task(3.0, "isit")
}

//public isit() {
//	if(get_pcvar_num(cvar_pointer[norounds]))
//		set_task(10.0, "CheckConditions",0,"",0,"b")
//}

public plugin_precache() 
{
	if(!file_exists(g_ConfigFile)) 
	{
		write_file(g_ConfigFile, "KGB Bots - Podesavanja^n")
		write_file(g_ConfigFile, "amx_botname ^"KGB Bot1^"   //Ime 1 bota")
		write_file(g_ConfigFile, "amx_botname2 ^"KGB Bot2^"   //Ime 2 bota")
                write_file(g_ConfigFile, "amx_botname3 ^"KGB Bot3^"   //Ime 3 bota")
		write_file(g_ConfigFile, "amx_minplayers ^"19^"   //Botovi ce biti ubaceni samo ako je broj igraca manji od ove vrednosti.")
		write_file(g_ConfigFile, "amx_starttime ^"0^"   //Od koliko sati da botovi budu na serveru?")
		write_file(g_ConfigFile, "amx_endtime ^"12^"   //Do koliko sati da botovi budu na serveru?")
		write_file(g_ConfigFile, "amx_onecon ^"0^"   //Da li treba da bude ispunjen samo jedan uslov da bi se dodali botovi?")
		write_file(g_ConfigFile, "amx_onebot ^"0^"   //Da li da plugin ubacuje samo jednog bota?")
		write_file(g_ConfigFile, "amx_norounds ^"0^"   //Da li se na ovom serveru ne zavrsava runda?")
	}
}

public CheckConditions()
{
	static iHours, m, s
	time(iHours, m, s)

	new iMin = get_pcvar_num(cvar_pointer[ starttime ]);
	new iMax = get_pcvar_num(cvar_pointer[ endtime ]);
	
	if(iMin == iMax)
		g_isTime = true;
	else if(iMin > iMax) 
	{
		switch(iHours) 
		{
			case 0..11: 
			{
				if(iMin >= iHours && iMax > iHours)
					g_isTime = true;
			}
			case 12..23: 
			{
				if(iMin <= iHours && iMax < iHours)
					g_isTime = true;
			}
		}
	}
	else if(iMin <= iHours && iMax > iHours)
		g_isTime = true;
	else 
		g_isTime = false;
		
	new iNum, iPlayers[32];
	get_players(iPlayers, iNum, "c");
	
	if(iNum <= get_pcvar_num(cvar_pointer[minplayers]))
		g_ePlayers = true;
	else
		g_ePlayers = false;

	if(g_maxplayers - iNum < 3)
		g_ePlayers = false;
	
	if(get_pcvar_num(cvar_pointer[minplayers]) == 0)
		g_ePlayers = true
	
	new iCondition = get_pcvar_num(cvar_pointer[ onecon ]);
	if( (!g_ePlayers && g_isTime || !g_isTime && g_ePlayers) && iCondition) 
	{
		g_isTime = true;
		g_ePlayers = true;
	}
	
	
		
	if((g_isTime && g_ePlayers) && !g_BotNum)
	{
		if(!get_pcvar_num(cvar_pointer[onebot]))
			set_task(0.1, "Task_AddBot")
		set_task(0.1, "Task_AddBot")
		set_task(0.1, "Task_AddBot")
	}
	else if((!g_isTime || !g_ePlayers) && 0 < g_BotNum <= 3 )
	{
		g_BotNum = 0;
		server_cmd("kick #%d", g_bID1)
		server_cmd("kick #%d", g_bID2)
                server_cmd("kick #%d", g_bID3)
	}
}

public Task_AddBot()
{
	static iBot;
	new iBotName[35];
	
	switch(g_BotNum)
	{
		case 0: get_pcvar_string(cvar_pointer[ botname1 ], iBotName, charsmax( iBotName ));
		case 1:	get_pcvar_string(cvar_pointer[ botname2 ], iBotName, charsmax( iBotName ));
                case 2:	get_pcvar_string(cvar_pointer[ botname3 ], iBotName, charsmax( iBotName ));
		case 3: return;
	}

	iBot = engfunc( EngFunc_CreateFakeClient, iBotName );
	
	if(!iBot)
		return;
		
	dllfunc( MetaFunc_CallGameEntity, "player", iBot );
	set_pev( iBot, pev_flags, FL_FAKECLIENT );

	set_pev( iBot, pev_model, "" );
	set_pev( iBot, pev_viewmodel2, "" );
	set_pev( iBot, pev_modelindex, 0 );

	set_pev( iBot, pev_renderfx, kRenderFxNone );
	set_pev( iBot, pev_rendermode, kRenderTransAlpha );
	set_pev( iBot, pev_renderamt, 0.0 );

	set_pdata_int( iBot, 114, 3 );
	cs_set_user_team( iBot, CS_TEAM_UNASSIGNED );
	
	switch(g_BotNum) 
	{
		case 0: g_bID1 = get_user_userid(iBot);
		case 1: g_bID2 = get_user_userid(iBot);
                case 2: g_bID3 = get_user_userid(iBot);
	}
	g_BotNum++;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
kgbbots.cfg:
Aici | Afiseaza codul
amx_botname1 "DNS : " //Numele primului bot
amx_botname2 "IP : " //Numele celui de-al 2-lea bot
amx_botname3 "FORUM : " //Numele celui de-al 3-lea bot
amx_minplayers "19"
amx_starttime "00" //Nu modificati
amx_endtime "24" //Nu modificati
amx_onecon "0" //Nu modificati
amx_onebot "0" //0 - 2 boti / 1 - 1 bot
amx_norounds "0"
RoyalServer
N.A.S.A.
Membru, skill 0
Membru, skill 0
Posts: 95
Joined: 14 Feb 2018, 15:56
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Contact:

25 Mar 2018, 16:51

salut, si eu am avut aceas probelma dar am gasit un plugin care adauga 3 boti fara sa-i adaugi tu si i-va scoate cand este server-ul 20/32
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new bool:is_user_fake[33]
new fake_players[33]

new const name_of_bots[][] =
{
	"IP: IP TAU",
	"DNS:  DNS-UL TAU.COM",
        "FORUM: WWWEXTREAMCS.COM"
}

public plugin_init()
{
	register_plugin("boti", "1.0", "cyby")
	
	set_task(10.0, "make_bot")
}

public make_bot()
{
	new i;
	for(i = 0; i < sizeof name_of_bots; i++)
	{
		if(fake_players <= 2)
		{
			new FAKE_PLAYER = engfunc(EngFunc_CreateFakeClient,name_of_bots)
			
			dllfunc(DLLFunc_ClientConnect,FAKE_PLAYER)
			dllfunc(DLLFunc_ClientPutInServer,FAKE_PLAYER)
			set_pev(FAKE_PLAYER,pev_team,3)
			
			is_user_fake[FAKE_PLAYER] = true
			fake_players[FAKE_PLAYER] += 1
		}
	}
}


Last bumped by Stai..Ce? on 25 Mar 2018, 16:51.
Post Reply

Return to “Modificari pluginuri”

  • Information