Raised This Month: $51 Target: $400
 12% 

Disconnect & Connected detection


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 10-02-2020 , 18:18   Disconnect & Connected detection
Reply With Quote #1

Quote:
Before all the strange questions how it's supposed to work according to 2 alive people then countdown and the running game that needs to transmit the virus and then last survives and wins, and again countdown
ill did SET_TASK check online about enough player to keep run or not enough if someone Left the game at run the game just stopped automatic and start task of new game, that should randomly infected any from alive if there is +1 Alive the disease, the problem that it doesn't work: doesn't continue from the last the moment he broke away
Even when someone connect on to SERVER, on game running sometimes that make again Task Countdown as begin like new roundrestart
I don't find the problem it could be putinserver
disconnect
checkOnline not configured correctly
HTML Code:
		LogEventHook_RoundEnd(); 
		LogEventHook_RoundStart();
That there's no particular test there

How did I check?
For example there is
Game will start in 15 Second
and i kick a bot , at countdown/or not Will start recounting and will not continue the game

Code:
enum (+= 35)	{
	TASK_ID_INFECT,
	TASK_ID_TIMELEFT,
	TASK_ID_SELECT,
	TASK_ID_GAMESTART,
	TASK_ID_GAMEEND,
	TASK_ID_VOTE_DAY_MODE_TIMER,

	TASK_INDEX_SHOW_INFORMER,
	TASK_INDEX_WAVE,
	TASK_INDEX_SPAWN,
	TASK_FIREWORKS
};

new g_iPlayer;
new g_iGame = -1;
Code:
#include <amxmodx>
#include <reapi>

public plugin_init()
{
    RegisterHookChain( RG_RoundEnd, "RoundEnd", 0 );
}

public RoundEnd( WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay )
{
    if ( event == ROUND_GAME_COMMENCE )
    {
        set_member_game( m_bGameStarted, true );
        SetHookChainReturn( ATYPE_INTEGER, false );

        return(HC_SUPERCEDE);
    }

    return(HC_CONTINUE);
}
Someone was told to use it for blocking those who enter in the middle game but does not help

if you need more info from code i will edit:

PHP Code:
public client_putinserver(id)
{
    if(
is_user_bot(id))
        return;
    
    if(
g_iGame > -1)
        
set_task(1.0"main_informer"id+TASK_INDEX_SHOW_INFORMER__"b");
    
loadUser(id);
    
block_user_spawn(id);
    
    
NextCashTimeid ] = get_gametime();
}

public 
client_disconnected(id
{
    
remove_task(id+TASK_INDEX_SHOW_INFORMER);
    
remove_task(id+TASK_INDEX_WAVE);
    
remove_task(id+TASK_FIREWORKS);
    
saveUser(id);
    
    if(
id == g_iPlayer || task_exists(id+TASK_ID_TIMELEFT))
    {
        
client_print_color(0print_team_default"%s ^3^"%n^3^" ^1left the^4 game^1"PREFIXid);
        
        if(
_get_alive_players() > 2)
        
// what im trying to do remain the infected after player disconnected
        // What I'm trying to do here, once there's a SET TASK test and it recognizes that PLAYER DISCONNCETED?
        // Then continue SelectPlayer as Infected and do not do AGAIN COUNTDOWN 15 SEC
        
{
            
remove_task(id+TASK_ID_SELECT);
            
remove_task(id+TASK_ID_INFECT);
            
            
client_print_color(0print_team_default"%s ^3%n^1 was the infected and has ^4disconnected^1."PREFIXg_iPlayer);
            
client_print_color(0print_team_default"%s Selecting new^4 random infected^1 in ^3%.1f seconds^1!"PREFIXSELECT_PLAYER_DELAY);
            
selectPlayer(00, .bMsg true, .bTask true, .bSound true); // there i want it remain and not show countdown 15 second
        
}
        else
        {
            
client_print_color(0print_team_default"%s Game has been^4 stopped ^1because there is only^4 1 alive^1"PREFIX);
            
remove_task(id+TASK_ID_TIMELEFT);
        }
    }
    
    for(new 
0<= HIGH_SPEEDi++)
        
g_bUserExtra[id][i] = false;

    for(new 
0<= TOTAL_PLAYED_Ri++)
        
g_iUserRounds[id][i] = 0;

    
set_task(0.1"checkOnline");
}

public 
checkOnline()
{
    
//What I'm trying to do here, once there's a SET TASK test and it recognizes that PLAYER DISCONNCETED?
    //Then continue SelectPlayer as Infected and do not do AGAIN COUNTDOWN 15 SEC
    
if (_get_alive_players() >= && g_bGameStart// Game wont stop if there is 2 > + Alive, check g_bGameStart
    
{
        
LogEventHook_RoundEnd();
        
LogEventHook_RoundStart();
    }
    else
    {
        
taskGameend();
    }
    
//client_print(0, 3, "%s", g_bGameStart ? "true" : "false"); // is always false
    /*if(_get_alive_players() < 1)
    {
    if(g_bGameStart)
            taskGameend();
        
        else {
            LogEventHook_RoundEnd();
            LogEventHook_RoundStart();
        }
    }*/
}

public 
LogEventHook_RoundStart()
{
    if(
g_iGame > -1)
        
set_task(1.0"main_informer"TASK_INDEX_SHOW_INFORMER__"b");
        
    for(new 
1<= g_iMaxPlayersi++)
    {
        if(!
is_user_connected(i)) 
            continue;
        
        if(
task_exists(i+TASK_INDEX_WAVE))
            
remove_task(i+TASK_INDEX_WAVE);

        
remove_task(i+TASK_FIREWORKS);
    }
    
    if(
task_exists(TASK_ID_GAMEEND))
        
remove_task(TASK_ID_GAMEEND);
        
    
client_cmd(0"mp3 stop");
    
set_lights("m");
    
g_iTimeToStart 15;

    if(
g_iDay SPECIAL_DAY != 0)
    {
        if(
_get_alive_players() > 1)
        {
            
g_szText "";
            
set_task(1.0"taskInfect"TASK_ID_INFECT__"a"g_iCountDown g_iTimeToStart 1);
        }else
        {
            
client_print_color(0print_team_red"%s The game can't start at least^3 2^1 players are required!"PREFIX);
            
set_task(10.0"LogEventHook_RoundStart"TASK_ID_GAMESTART); // default is 10.0
        
}
    }
    return 
PLUGIN_CONTINUE;
}

public 
LogEventHook_RoundEnd() {
    for(new 
1<= g_iMaxPlayersi++)
    {
        if(!
is_user_connected(i)) 
            continue;
        
        if(
task_exists(i+TASK_INDEX_SHOW_INFORMER))
            
remove_task(i+TASK_INDEX_SHOW_INFORMER);
        
        if(
task_exists(i+TASK_INDEX_WAVE))
            
remove_task(i+TASK_INDEX_WAVE);

        
//remove_task(i+TASK_FIREWORKS);
        
        
if(pev(ipev_renderfx) != kRenderFxNone || pev(ipev_rendermode) != kRenderNormal) {
            
fm_set_rendering(ikRenderFxNone000kRenderNormal0);
        }

        
g_iUserRounds[i][PLAYED_R] += 1;
        
g_iUserRounds[i][TOTAL_PLAYED_R] += 1;

        for(new 
0<= HIGH_SPEEDj++)
            
g_bUserExtra[i][j] = false;
    }
    
    
g_bIsNoScopeRound false;
    
invisibil false;
    
g_bGameStart false;
    
g_iLastHiter 0;
    
g_iPlayer 0;
    
g_szName "";
    if (
g_iGame == 1)
        
CreateFog(01281281280.0018true);
    
set_lights("m");
    
    
remove_task(TASK_ID_SELECT);
    
remove_task(TASK_ID_INFECT);
    
remove_task(TASK_ID_TIMELEFT);
    
remove_task(TASK_ID_GAMESTART);
    
remove_task(TASK_ID_GAMEEND);
    
remove_task(TASK_ID_VOTE_DAY_MODE_TIMER);
}

public 
LogEventHook_RestartGame()
{
    if(!
g_bGameRestart)
        
g_iDay 0;

    
g_bGameRestart false;
    
LogEventHook_RoundEnd();

Code:
stock _get_alive_players()
{
	new players[32], pnum;
	get_players(players, pnum, "a");
	return pnum;
}
PHP Code:
stock selectPlayer(pIdpLastHitlerbool:bMsgbool:bTaskbool:bSound)
{
    if(!
pId)
    {
        new 
iPlayers[32], iNum
        
iNum _get_players(iPlayers, .bAlive true);
        
        if(
iNum 2)
        {
            
client_print_color(0print_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_iPlayerkRenderFxNone000kRenderNormal0);
    }
    
    
g_iLastHiter pLastHitler;
    
g_iPlayer pId;
    
get_user_name(pIdg_szNamecharsmax(g_szName));
    
fm_set_rendering(pIdkRenderFxGlowShellrandom_num(0255), random_num(0255), random_num(0255), kRenderTransAlpha25);
    
cs_set_player_model(pIdg_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_iLastHiterszAttackercharsmax(szAttacker));
            
cs_reset_player_model(g_iLastHiter);
    
            new 
iOrigin[2][3];
            
get_user_origin(g_iPlayeriOrigin[0]);
            
get_user_origin(g_iLastHiteriOrigin[1]);
            new 
iFeet get_real_distanceiOrigin] , iOrigin] , Measure_Feet );
    
            new 
Float:fVec];
            
IVecFVeciOrigin] , fVec );
    
            
client_print_color(0print_team_red"%s ^3%s ^1hit ^3%s ^1from units [ ^4%d ^1] in ^1[ ^4%.1f Seconds ^1]."PREFIXszAttackerg_szNameiFeetg_fTimeLeft);
            
CREATE_BEAMENTPOINT(pIdfVecg_pSpriteLgtning0115050random(255), random(255), random(255), 180_);
        } 
        else
            
client_print_color(0print_team_red"%s ^3%s ^1was randomly selected as the ^4infected!"PREFIXg_szName);
    }
    
    if(
bSound)
        
client_cmd(pId"spk %s"g_szInfecteSounds[random(sizeof(g_szInfecteSounds))]);

It's something I'm really sitting for a while

Last edited by Fuck For Fun; 10-02-2020 at 18:29.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-09-2020 , 18:06   Re: Disconnect & Connected detection
Reply With Quote #2

Quote:
// there i want it remain and not show countdown 15 second
Change_task instead of remove_task if I follow your conundrum. 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.
__________________

Last edited by DJEarthQuake; 10-13-2020 at 17:08. Reason: Obvious typo slipped my eye.
DJEarthQuake is offline
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
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 10-12-2020 , 01:38   Re: Disconnect & Connected detection
Reply With Quote #4

I think I fixed the problem, I hope.

I had to do an taskGameend(); check on that line.
PHP Code:
    if(id == g_iPlayer || task_exists(id+TASK_ID_TIMELEFT))
    {
        
client_print_color(0print_team_default"%s ^3^"%n^3^" ^1left the^4 game^1"PREFIXid);
        
        if(
_get_alive_players() > 2)
        
// What im trying to do remain the infected after player disconnected
        // What I'm trying to do here, once there's a SET TASK test and it recognizes that PLAYER DISCONNCETED?
        // Then continue SelectPlayer as Infected and do not do AGAIN COUNTDOWN 15 SEC
        
{
            
remove_task(id+TASK_ID_SELECT);
            
remove_task(id+TASK_ID_INFECT);
            
            
client_print_color(0print_team_default"%s ^3%n^1 was the infected and has ^4disconnected^1."PREFIXg_iPlayer);
            
client_print_color(0print_team_default"%s Selecting new^4 random infected^1 in ^3%.1f seconds^1!"PREFIXSELECT_PLAYER_DELAY);
            
// there i want it remain and not show countdown 15 second
            
selectPlayer(00, .bMsg true, .bTask true, .bSound true);
        }
        else
        {
            
client_print_color(0print_team_default"%s Game has been^4 stopped ^1because there is only^4 1 alive^1"PREFIX);
            
remove_task(id+TASK_ID_TIMELEFT);
            
            
taskGameend();
        }
    } 

Last edited by Fuck For Fun; 10-12-2020 at 01:39.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 10-12-2020 , 13:18   Re: Disconnect & Connected detection
Reply With Quote #5

Quote:
Originally Posted by Fuck For Fun View Post
I think I fixed the problem, I hope.

I had to do an taskGameend(); check on that line.
PHP Code:
    if(id == g_iPlayer || task_exists(id+TASK_ID_TIMELEFT))
    {
        
client_print_color(0print_team_default"%s ^3^"%n^3^" ^1left the^4 game^1"PREFIXid);
        
        if(
_get_alive_players() > 2)
        
// What im trying to do remain the infected after player disconnected
        // What I'm trying to do here, once there's a SET TASK test and it recognizes that PLAYER DISCONNCETED?
        // Then continue SelectPlayer as Infected and do not do AGAIN COUNTDOWN 15 SEC
        
{
            
remove_task(id+TASK_ID_SELECT);
            
remove_task(id+TASK_ID_INFECT);
            
            
client_print_color(0print_team_default"%s ^3%n^1 was the infected and has ^4disconnected^1."PREFIXg_iPlayer);
            
client_print_color(0print_team_default"%s Selecting new^4 random infected^1 in ^3%.1f seconds^1!"PREFIXSELECT_PLAYER_DELAY);
            
// there i want it remain and not show countdown 15 second
            
selectPlayer(00, .bMsg true, .bTask true, .bSound true);
        }
        else
        {
            
client_print_color(0print_team_default"%s Game has been^4 stopped ^1because there is only^4 1 alive^1"PREFIX);
            
remove_task(id+TASK_ID_TIMELEFT);
            
            
taskGameend();
        }
    } 
I think i had see something like this in zp mod I was have small problem on it but i have found the solve.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 10-12-2020 at 13:26.
Supremache is offline
Reply



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 22:27.


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