Raised This Month: $32 Target: $400
 8% 

[ Help ] Choose Random 1 "T"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 06-11-2018 , 15:24   [ Help ] Choose Random 1 "T"
Reply With Quote #1

How do I define a random player to be infected a certain skin precache_model (with 8000 HP) and all terrorits 100 HP?
Code:
public CmdRandomWinner()
{
	if( get_pcvar_num( pCvarToggle ) == 0 )
		return PLUGIN_CONTINUE;
	
	/*new stPlayers[32], iPlayersCount, pPlayer;
	get_players(stPlayers, iPlayersCount, "ae", "TERRORIST");*/
	
	new Spk[10];
	num_to_word(gTimer, Spk, charsmax(Spk));
	client_cmd(0, "spk ^"vox/%s^"", Spk);
	
	MakeDisco();
	
	set_hudmessage( 255, 0, 0, -1.0, 0.43, 0, 1.0, 1.0 );
	show_hudmessage( 0, "The Event Starts in %i Seconds", gTimer );

	/*for (new i = 0; i < iPlayersCount; i++)
	{
		pPlayer = stPlayers[i];
		
		set_pev(pPlayer, pev_flags, (pev(pPlayer, pev_flags) | FL_FROZEN)); // Frozen Players
	}*/
	
	gTimer--;
	
	if( gTimer <= 0 )
	{
		static Players[ 32 ], iNum;
		get_players( Players, iNum, "ach" );
		new randPlayer = RandomPlayer();
			
		ColorChat( 0, NORMAL,"^4[AMXX] ^1All ^3Terrorits ^1is Chosen to be ^3Zombie for event^1." );

		for( new i = 0 ; i < iNum ; i++ )
		{
			randPlayer = Players[ i ];
			
			strip_user_weapons( randPlayer );
			
			//set_pev(pPlayer, pev_flags, (pev(pPlayer, pev_flags) & ~FL_FROZEN)); // UnFrozen Players
			
			if( !is_user_alive( randPlayer ) || !is_user_connected( randPlayer ) )
				continue;
		
			switch ( cs_get_user_team( randPlayer ) )
			{
				case CS_TEAM_T:
				{
					cs_set_user_model( randPlayer, "P_ZOMBIE" );
					give_item( randPlayer, "weapon_knife" );
					set_user_health( randPlayer, 8000 );    
				}          
				case CS_TEAM_CT:
				{
					set_user_health( randPlayer, 100 );   
					give_item( randPlayer,"weapon_ak47")
					give_item( randPlayer,"weapon_m4a1")
					cs_set_user_bpammo( randPlayer, CSW_M4A1, 180 )
					cs_set_user_bpammo( randPlayer, CSW_AK47, 180 )
				}
			}
		}
	
		gTimer = get_pcvar_num( pCvarTimer );
		g_rwActive = false;
		
		remove_task();

		}
	else
	{
		set_task( 1.0, "CmdRandomWinner" );
	}
	
	return PLUGIN_CONTINUE;
}

Last edited by Fuck For Fun; 06-12-2018 at 09:20.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-11-2018 , 16:52   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #2

what is it exactly that you want to do.
__________________

Last edited by Napoleon_be; 06-11-2018 at 16:52.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-11-2018 , 18:31   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #3

To get a random terrorist player you can use something like

PHP Code:
new iPlayers[32], iNumget_playersiPlayersiNum"che""TERRORIST" )
new 
iRandomPlayer iPlayers[randomiNum )]; 
Thats what i can answer ( judging from the title ), I don't understand what you are trying to do really Please tell us more.

Last edited by maqi; 06-11-2018 at 18:45.
maqi is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 06-12-2018 , 07:57   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #4

Quote:
Originally Posted by Napoleon_be View Post
what is it exactly that you want to do.
i tried to give all "Terrorits" a Guns AK/M4a1 but only 1 person will be infected and get a Zombie model with 8K HP.

so 1 person infected random and others no.
Quote:
Originally Posted by maqi View Post
To get a random terrorist player you can use something like

PHP Code:
new iPlayers[32], iNumget_playersiPlayersiNum"che""TERRORIST" )
new 
iRandomPlayer iPlayers[randomiNum )]; 
Thats what i can answer ( judging from the title ), I don't understand what you are trying to do really Please tell us more.
1 Person to be chosen by Random iNum, and other be with 100 hp + guns.

but nevermind i change my idea.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 06-12-2018 , 08:01   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #5

You should explain - What you are upto.. in your post's description
So acc to your title :

Quote:
Originally Posted by maqi View Post
To get a random terrorist player you can use something like

PHP Code:
new iPlayers[32], iNumget_playersiPlayersiNum"che""TERRORIST" )
new 
iRandomPlayer iPlayers[randomiNum )]; 
Thats what i can answer ( judging from the title ), I don't understand what you are trying to do really Please tell us more.
This is the best answer !

Last edited by instinctpt1; 06-12-2018 at 08:02.
instinctpt1 is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 06-12-2018 , 09:20   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #6

Quote:
Originally Posted by instinctpt1 View Post
You should explain - What you are upto.. in your post's description
So acc to your title :



This is the best answer !
https://forums.alliedmods.net/showpo...16&postcount=4

i update my first post, and i put a code
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-12-2018 , 11:42   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #7

Still kinda confused maybe this will help idk really
PHP Code:
new iPlayers[32], iNum

get_playersiPlayersiNum"che""TERRORIST" )
new 
iRandomPlayer iPlayers[randomiNum )];
get_playersiPlayersiNum"ch" )

for( new 
0iNumi++ )
{
    case(
iPlayers[i])
    {
        case 
iRandomPlayer:
        {
               
// Do stuff to random player 
        
}
        default:
        {
            
// Do stuff to ALL other players
        
}

Note:

Idk: why you are doing this
Code:
randPlayer = Players[ i ];
In a loop alfter you already selected a random player, this will pretty much do the same thing to all players and ignore the randomPlayer you choose, as its is overwritten.

Last edited by maqi; 06-12-2018 at 12:03.
maqi is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-12-2018 , 18:43   Re: [ Help ] Choose Random 1 "T"
Reply With Quote #8

Maqi's answer should help you out.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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:16.


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