Raised This Month: $ Target: $400
 0% 

Disconnect & Connected detection


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 10-10-2020 , 06:05   Re: Disconnect & Connected detection
Reply With Quote #3

Quote:
Originally Posted by DJEarthQuake View Post
Change_task instead of remove_task if I follow your condrumdrum. The subject line made it seem illusively easy as I believe one may already know there are both client_connect and client_disconnect functions to make works from.
that line:
Code:
selectPlayer(0, 0, .bMsg = true, .bTask = true, .bSound = true);
Hope I explained correctly is what causes the function to choose a character for the virus
Code:
stock selectPlayer(pId, pLastHitler, bool:bMsg, bool:bTask, bool:bSound)
{
	if(!pId)
	{
		new iPlayers[32], iNum; 
		iNum = _get_players(iPlayers, .bAlive = true);
		
		if(iNum < 2)
		{
			client_print_color(0, print_team_red, "%s Game requires^4 2 ^1players to start.", PREFIX);
			g_bGameStart = false;
			set_task(15.0, "LogEventHook_RoundStart", TASK_ID_GAMESTART);
			return;
		}

		pId = iPlayers[random(iNum)];
	}

	if(!is_user_alive(pId))
		return;

	createEffect(pId);
	
	if(is_user_alive(g_iPlayer))
	{
		fm_set_rendering(g_iPlayer, kRenderFxNone, 0, 0, 0, kRenderNormal, 0);
	}
	
	g_iLastHiter = pLastHitler;
	g_iPlayer = pId;
	get_user_name(pId, g_szName, charsmax(g_szName));
	fm_set_rendering(pId, kRenderFxGlowShell, random_num(0, 255), random_num(0, 255), random_num(0, 255), kRenderTransAlpha, 25);
	cs_set_player_model(pId, g_szInfectedModel);

	if(task_exists(TASK_ID_SELECT))
		remove_task(TASK_ID_SELECT);
	if(bTask)
	{
		if(task_exists(TASK_ID_TIMELEFT))
			remove_task(TASK_ID_TIMELEFT);
		
		g_fTimeLeft = 20.0;
		set_task(0.1, "taskTimeleft", TASK_ID_TIMELEFT, _, _, "b");
	}
	
	if(bMsg) 
	{
		if(g_iLastHiter) 
		{
			new szAttacker[MAX_NAME_LENGTH];
			get_user_name(g_iLastHiter, szAttacker, charsmax(szAttacker));
			cs_reset_player_model(g_iLastHiter);
	
			new iOrigin[2][3];
			get_user_origin(g_iPlayer, iOrigin[0]);
			get_user_origin(g_iLastHiter, iOrigin[1]);
			new iFeet = get_real_distance( iOrigin[ 0 ] , iOrigin[ 1 ] , Measure_Feet );
	
			new Float:fVec[ 3 ];
			IVecFVec( iOrigin[ 1 ] , fVec );
	
			client_print_color(0, print_team_red, "%s ^3%s ^1hit ^3%s ^1from units [ ^4%d ^1] in ^1[ ^4%.1f Seconds ^1].", PREFIX, szAttacker, g_szName, iFeet, g_fTimeLeft);
			CREATE_BEAMENTPOINT(pId, fVec, g_pSpriteLgtning, 0, 1, 1, 50, 50, random(255), random(255), random(255), 180, _);
		} 
		else
			client_print_color(0, print_team_red, "%s ^3%s ^1was randomly selected as the ^4infected!", PREFIX, g_szName);
	}
	
	if(bSound)
		client_cmd(pId, "spk %s", g_szInfecteSounds[random(sizeof(g_szInfecteSounds))]);
}
Now I've been sitting on it for a few days and I've kicked out the option of
set_task(0.1, "checkOnline");

Because in general from there comes the problems that it makes checking whether to finish the game or continue

Having removed it, could say that 90% of everything works except every time someone left the game in the middle of a game it doesn't show the ad in the chat and also the game keeps running without stopping because there is no CHECK ONLINE

Last edited by Fuck For Fun; 10-10-2020 at 06:06.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode