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

[help] doubt FreeRun


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MR10
Junior Member
Join Date: Apr 2014
Old 04-21-2014 , 11:32   [help] doubt FreeRun
Reply With Quote #1

Well hello, I have a question em I wanted to know if the FreeRun (DR) can add a vote for the round to be free in the same command that the vote is, if someone could modify this Plugins I would greatly appreciate it

Code:
#include < amxmodx >
#include < cstrike >
#include < fakemeta >
#include < hamsandwich >

const m_toggle_state = 41;

#define TASK_VOTE  237439

enum _:VOTES {
	VOTE_YES,
	VOTE_NO
};

new g_iVotes[ VOTES ];
new bool:g_bVoted[ 33 ];
new bool:g_bFreeRound;
new bool:g_bWillFree;
new bool:g_bVoting;
new g_iCountdown;
new g_iRounds;
new g_iPrinted;
new g_iMenuID;
new g_iMaxplayers;
new g_iMsgSayText;
new g_pWaitRounds;

public plugin_init( ) {
	new const VERSION[ ] = "1.0";
	
	register_plugin( "Deathrun: Free Round", VERSION, "xPaw" );
	
	new p = register_cvar( "deathrun_freeround", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
	set_pcvar_string( p, VERSION );
	
	g_pWaitRounds = register_cvar( "freerun_wait_rounds", "5" );
	g_iMaxplayers = get_maxplayers( );
	g_iMsgSayText = get_user_msgid( "SayText" );
	g_iMenuID     = register_menuid( "DrunFreeRoundVote" );
	
	register_menucmd( g_iMenuID, ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0 ), "HandleVote" );
	
	register_clcmd( "say /free",      "CmdFreeRound" );
	register_clcmd( "say /freeround", "CmdFreeRound" );
	
	RegisterHam( Ham_Use, "func_rot_button", "FwdHamUse_Button" );
	RegisterHam( Ham_Use, "func_button",     "FwdHamUse_Button" );
	RegisterHam( Ham_Use, "button_target",   "FwdHamUse_Button" );
	
	register_event( "CurWeapon", "EventCurWeapon", "be", "1=1", "2!29" );
	register_event( "HLTV",      "EventNewRound",  "a",  "1=0", "2=0" );
	register_event( "TextMsg",   "EventRestart",   "a",  "2&#Game_C", "2&#Game_w" );
}

public EventNewRound( ) {
	if( g_bFreeRound ) {
		g_bFreeRound = false;
		g_iRounds    = 0;
		g_iPrinted   = 0;
		
		return;
	}
	else if( g_bWillFree ) {
		g_iRounds    = 0;
		g_iPrinted   = 0;
		g_bWillFree  = false;
		g_bFreeRound = true;
		
		set_task( 2.0, "PrintMessage" );
		
		return;
	}
	
	g_iRounds++;
	
	if( g_iPrinted < 4 && g_iRounds >= get_pcvar_num( g_pWaitRounds ) ) {
		GreenPrint( 0, "escribe^4 /free^1 para iniciar una votacion!" );
		
		g_iPrinted++;
	}
}

public EventRestart( ) {
	g_bFreeRound = false;
	g_bWillFree  = false;
	g_bVoting    = false;
	g_iPrinted   = 0;
	g_iRounds    = 0;
	
	remove_task( TASK_VOTE );
}

public EventCurWeapon( id )
	if( g_bFreeRound )
		engclient_cmd( id, "weapon_knife" );

public CmdFreeRound( id ) {
	if( cs_get_user_team( id ) != CS_TEAM_T ) {
		GreenPrint( id, "Este comando es solo para terroristas!" );
		
		return PLUGIN_CONTINUE;
	}
	else if( g_bFreeRound ) {
		GreenPrint( id, "Ya se esta jugando una ronda libre!" );
		
		return PLUGIN_CONTINUE;
	}
	else if( g_bVoting ) {
		GreenPrint( id, "La votacion ya esta en proceso!" );
		
		return PLUGIN_CONTINUE;
	}
	else if( g_bWillFree ) {
		GreenPrint( id, "La siguiente ronda sera libre!" );
		
		return PLUGIN_CONTINUE;
	}
	
	new iWaitRounds = get_pcvar_num( g_pWaitRounds ) - g_iRounds;
	
	if( iWaitRounds > 0 ) {
		GreenPrint( id, "Tienes que esperar^3 %i^1 rondas para iniciar una votacion!", iWaitRounds );
		
		return PLUGIN_CONTINUE;
	}
	
	new szName[ 32 ];
	get_user_name( id, szName, 31 );
	
	GreenPrint( 0, "La votacion ha sido iniciada por^3 %s^1.", szName );
	
	set_hudmessage( 222, 70, 0, -1.0, 0.3, 1, 3.0, 3.0, 2.0, 1.0, -1 );
	show_hudmessage( 0, "%s ah iniciado una votacion para ronda libre!^nLa votacion se iniciara en breve.", szName );
	
	g_iVotes[ VOTE_YES ] = 0;
	g_iVotes[ VOTE_NO ] = 0;
	g_iRounds = 0;
	g_bVoting = true;
	g_iPrinted = 0;
	g_bWillFree = false;
	
	arrayset( g_bVoted, false, 32 );
	
	remove_task( TASK_VOTE );
	g_iCountdown = 15;
	
	set_task( 3.5, "PreTask", TASK_VOTE );
	
	return PLUGIN_CONTINUE;
}

public PrintMessage( ) {
	GreenPrint( 0, "Esto es una^4 Ronda Libre!^1, no armas, no trampas!" );
	
	set_hudmessage( 0, 90, 0, -1.0, 0.35, 1, 3.0, 3.0, 2.0, 1.0, -1 );
	show_hudmessage( 0, "RONDA LIBRE!" );
}

public PreTask( ) {
	remove_task( TASK_VOTE );
	
	set_task( 1.0, "TaskVoteTimer", TASK_VOTE, _, _, "b" );
}

public TaskVoteTimer( ) {
	g_iCountdown--;
	
	if ( !g_iCountdown ) {
		remove_task( TASK_VOTE );
		
		g_bVoting = false;
		
		new iVotes, iHighVotes, iHighVotesID;
		
		for( new i; i < VOTES; i++ ) {
			iVotes = g_iVotes[ i ];
			
			if( iVotes >= iHighVotes ) {
				iHighVotes = iVotes;
				iHighVotesID = i;
			}
		}
		
		if( iHighVotes > 0 ) {
			if( iHighVotesID == VOTE_YES )
				g_bWillFree = true;
			
			GreenPrint( 0, "Votacion finalizada. %s^1 [^3 %i^1 votos (^4%i%%) ^1]", g_bWillFree ? "La siguiente ronda sera Libre!" : "La siguiente ronda no sera Libre!", iHighVotes, GetPercent( g_iVotes[ iHighVotesID ], g_iVotes[ VOTE_YES ] + g_iVotes[ VOTE_NO ] ) );
		} else
			GreenPrint( 0, "Votacion finalizada. Nadie voto." );
		
		for( new i = 1; i <= g_iMaxplayers; i++ )
			if( is_user_connected( i ) )
				ShowVoteMenu( i, 1 );
	} else {
		for( new i = 1; i <= g_iMaxplayers; i++ )
			if( is_user_connected( i ) )
				ShowVoteMenu( i, 0 );
	}
}

ShowVoteMenu( id, bResults = 0 ) {
	new iMenu = GetUserMenu( id );
	
	if( ( iMenu && iMenu != g_iMenuID ) && g_iCountdown <= 14 )
		return;
	
	menu_cancel( id ); // Radios and other piece of shit bug fix :D
	
	new szMenu[ 196 ], iLen;
	
	if( bResults )
		iLen = formatex( szMenu, charsmax( szMenu ), "\rResultados de la votacion:^n^n" );
	else
		iLen = formatex( szMenu, charsmax( szMenu ), "\rProxima Ronda Libre!?^n^n" );
	
	new iVotesTotal = g_iVotes[ VOTE_YES ] + g_iVotes[ VOTE_NO ];
	
	iLen += formatex( szMenu[ iLen ], charsmax( szMenu ) - 1, "\r1. \wSi \d(%i%%)^n", GetPercent( g_iVotes[ VOTE_YES ], iVotesTotal ) );
	iLen += formatex( szMenu[ iLen ], charsmax( szMenu ) - 1, "\r2. \wNo \d(%i%%)^n^n", GetPercent( g_iVotes[ VOTE_NO ], iVotesTotal ) );
	
	if( bResults ) {
		if( g_bWillFree )
			iLen += formatex( szMenu[ iLen ], charsmax( szMenu ) - 1, "  \yLa siguiente ronda sera Libre!" );
		else {
			if( !iVotesTotal )
				iLen += formatex( szMenu[ iLen ], charsmax( szMenu ) - 1, "  \yNadie voto!" );
		}
		
		show_menu( id, ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0 ), szMenu, -1, "DrunFreeRoundVote" );
		
		set_task( 5.0, "CloseMenu", id );
	} else {
		iLen += formatex( szMenu[ iLen ], charsmax( szMenu ) - 1, "  \dSegundos restantes: \r%i", g_iCountdown );
		
		show_menu( id, ( MENU_KEY_1 | MENU_KEY_2 ), szMenu, -1, "DrunFreeRoundVote" );
	}
}

public CloseMenu( id )
	if( GetUserMenu( id ) == g_iMenuID )
		client_cmd( id, "slot1" );

GetUserMenu( id ) {
	new iMenu, iKeys;
	get_user_menu( id, iMenu, iKeys );
	
	return iMenu;
}

public HandleVote( id, iKey ) {
	if( !g_bVoting || !task_exists( TASK_VOTE ) )
		return;
	
	if( g_bVoted[ id ] ) {
		ShowVoteMenu( id, 0 );
		
		return;
	}
	
	if( iKey > 1 )
		return;
	
	new iVotes = ( /* get_user_flags( id ) & ADMIN_KICK ||*/ get_user_team( id ) == 1 ) ? 2 : 1;
	
	g_bVoted[ id ] = true;
	g_iVotes[ iKey ] += iVotes;
	
	new szName[ 32 ];
	get_user_name( id, szName, 31 );
	
	GreenPrint( 0, "^3%s^1 voto^4 %s^1. [^4+%i^1 voto%s]", szName, iKey == VOTE_YES ? "a favor" : "en contra", iVotes, iVotes == 1 ? "" : "s" );
	
	ShowVoteMenu( id, 0 );
}

public FwdHamUse_Button( iEntity, id, iActivator, iUseType, Float:flValue ) {
	if( g_bFreeRound && iUseType == 2 && flValue == 1.0 && is_user_alive( id )
	&&  get_user_team( id ) == 1 && get_pdata_int( iEntity, m_toggle_state, 4 ) == 1 ) {
		/* Oh hi this code actually happen! :D */
		
		set_hudmessage( 0, 100, 255, -1.0, 0.25, 0, 2.0, 2.0, 0.2, 0.2, 3 );
		show_hudmessage( id, "Es una ronda libre!^nNo se pueden activar las trampas!" );
		
		return HAM_SUPERCEDE;
	}
	
	return HAM_IGNORED;
}

GetPercent( is, of ) // Brad
	return ( of != 0 ) ? floatround( floatmul( float( is ) / float( of ), 100.0 ) ) : 0;

GreenPrint( id, const message[ ], any:... ) {
	static szMessage[ 192 ], iLen;
	if( !iLen )
		iLen = formatex( szMessage, 191, "^4[Only-Gamers]^1 " );
	
	vformat( szMessage[ iLen ], 191 - iLen, message, 3 );
	
	message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgSayText, _, id );
	write_byte( id ? id : 1 );
	write_string( szMessage );
	message_end( );
	
	return 1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/

Last edited by MR10; 04-21-2014 at 19:06.
MR10 is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 04-21-2014 , 12:02   Re: [help] do this?
Reply With Quote #2

PHP Code:
public TaskVoteTimer( ) {
    
g_iCountdown--;
    
    if ( !
g_iCountdown ) {
        
remove_taskTASK_VOTE );
        
        
g_bVoting false;
        
        new 
iVotesiHighVotesiHighVotesID;
        
        for( new 
iVOTESi++ ) {
            
iVotes g_iVotes];
            
            if( 
iVotes >= iHighVotes ) {
                
iHighVotes iVotes;
                
iHighVotesID i;
            }
        }
        
        if( 
iHighVotes ) {
            if( 
iHighVotesID == VOTE_YES )
                
//g_bWillFree = true;  <--changed this :B
                
g_bFreeRound true;
            
            
GreenPrint0"Votacion finalizada. %s^1 [^3 %i^1 votos (^4%i%%) ^1]"g_bWillFree "La siguiente ronda sera Libre!" "La siguiente ronda no sera Libre!"iHighVotesGetPercentg_iVotesiHighVotesID ], g_iVotesVOTE_YES ] + g_iVotesVOTE_NO ] ) );
        } else
            
GreenPrint0"Votacion finalizada. Nadie voto." );
        
        for( new 
1<= g_iMaxplayersi++ )
            if( 
is_user_connected) )
                
ShowVoteMenui);
    } else {
        for( new 
1<= g_iMaxplayersi++ )
            if( 
is_user_connected) )
                
ShowVoteMenui);
    }

NikKOo31 is offline
Old 04-21-2014, 12:09
MR10
This message has been deleted by YamiKaitou. Reason: English Only
MR10
Junior Member
Join Date: Apr 2014
Old 04-21-2014 , 12:50   Re: [help] do this?
Reply With Quote #3

I mean it already, but nose and put that command in the same round
MR10 is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 04-21-2014 , 13:49   Re: [help] do this?
Reply With Quote #4

This part of the code is what you have to CHANGE

PHP Code:
if( iHighVotes ) { 
            if( 
iHighVotesID == VOTE_YES 
                
//g_bWillFree = true;  /*SIGUIENTE RONDA LIBRE*/
                
g_bFreeRound true/*ESTA RONDA LIBRE*/ 
And all the client prints will need corrections
For example:

PHP Code:
GreenPrint0"Votacion finalizada. %s^1 [^3 %i^1 votos (^4%i%%) ^1]"g_bWillFree "La siguiente ronda sera Libre!" "La siguiente ronda no sera Libre!"iHighVotesGetPercentg_iVotesiHighVotesID ], g_iVotesVOTE_YES ] + g_iVotesVOTE_NO ] ) ); 
Change to:
PHP Code:
GreenPrint0"Votacion finalizada. %s^1 [^3 %i^1 votos (^4%i%%) ^1]"g_bWillFree "Esta ronda sera Libre!" "Esta ronda no sera Libre!"iHighVotesGetPercentg_iVotesiHighVotesID ], g_iVotesVOTE_YES ] + g_iVotesVOTE_NO ] ) ); 
Cheers
NikKOo31 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-21-2014 , 16:03   Re: [help] do this?
Reply With Quote #5

The forum rules require that you use a descriptive topic title when you create threads. Please update the titles of your threads. If you fail to do so, you risk your topic being deleted.
__________________
fysiks is offline
MR10
Junior Member
Join Date: Apr 2014
Old 04-21-2014 , 19:04   Re: [help] do this?
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
The forum rules require that you use a descriptive topic title when you create threads. Please update the titles of your threads. If you fail to do so, you risk your topic being deleted.
Sorry, but I'm new and did not know, nor know how to modify it haha, but now I fixed
MR10 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-22-2014 , 01:30   Re: [help] do this?
Reply With Quote #7

Quote:
Originally Posted by MR10 View Post
Sorry, but I'm new and did not know, nor know how to modify it haha, but now I fixed
That is fine. Thanks for changing it. Now you'll know for the future.
__________________
fysiks 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 06:10.


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