AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ Help ] Choose Random 1 "T" (https://forums.alliedmods.net/showthread.php?t=308226)

Fuck For Fun 06-11-2018 15:24

[ Help ] Choose Random 1 "T"
 
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;
}


Napoleon_be 06-11-2018 16:52

Re: [ Help ] Choose Random 1 "T"
 
what is it exactly that you want to do.

maqi 06-11-2018 18:31

Re: [ Help ] Choose Random 1 "T"
 
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 :D Please tell us more.

Fuck For Fun 06-12-2018 07:57

Re: [ Help ] Choose Random 1 "T"
 
Quote:

Originally Posted by Napoleon_be (Post 2596437)
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 (Post 2596444)
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 :D 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.

instinctpt1 06-12-2018 08:01

Re: [ Help ] Choose Random 1 "T"
 
You should explain - What you are upto.. in your post's description
So acc to your title :

Quote:

Originally Posted by maqi (Post 2596444)
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 :D Please tell us more.

This is the best answer !

Fuck For Fun 06-12-2018 09:20

Re: [ Help ] Choose Random 1 "T"
 
Quote:

Originally Posted by instinctpt1 (Post 2596518)
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

maqi 06-12-2018 11:42

Re: [ Help ] Choose Random 1 "T"
 
Still kinda confused maybe this will help idk really :D
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.

Napoleon_be 06-12-2018 18:43

Re: [ Help ] Choose Random 1 "T"
 
Maqi's answer should help you out.


All times are GMT -4. The time now is 04:37.

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