AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Randomly select players (https://forums.alliedmods.net/showthread.php?t=74231)

elpouletorange 07-14-2008 14:10

Randomly select players
 
Hi, I want to select (1/4) of player playing each 5 rounds and make them have special ability (too they are tranfered in Ts team and all orther in CTs team). But I have really no idea how to make this. Can someone please make me a the basic of this.

Thanks :up:

Exolent[jNr] 07-14-2008 17:01

Re: Randomly select players
 
Code:
new g_Rounds; public plugin_init() {     register_event("HLTV", "eventNewRound", "a", "1=0", "2=0");         return PLUGIN_CONTINUE; } public eventNewRound() {     if( ++g_Rounds < 5 )     {         return PLUGIN_CONTINUE;     }         g_Rounds = 0;         new players[32], pnum;     get_players(players, pnum, "c");         // calculate total players being picked     new count = floatround(float(pnum) * 0.25, floatround_ceil);     new i, j;         new specialppl[8], total; // the special people chosen     while( total < count )     {         i = random(pnum); // choose a random player and save         specialppl[total++] = players[i];                 // shift the players down 1 to remove the player just picked         for( j = i; j < pnum; j++ )         {             if( (j + 1) == pnum )             {                 players[j] = 0;             }             else             {                 players[j] = players[j + 1];             }         }     }         new id;     for( new i = 0; i < total; i++ )     {         id = specialppl[i];                 cs_set_user_team(id, CS_TEAM_T);         // you can do other stuff with id as well     }         for( new i = 0; i < pnum; i++ )     {         id = players[i];                 cs_set_user_team(id, CS_TEAM_CT);         // you can do other stuff with id as well     }         return PLUGIN_CONTINUE; }

elpouletorange 07-18-2008 16:59

Re: Randomly select players
 
Do the selected players are transfered and Ts team and all orther in Cts one ?
Where do I put the special ability ? (exemple: set_user_armor(id, "255")

Thanks a lot!

Exolent[jNr] 07-18-2008 17:15

Re: Randomly select players
 
Edited code for an example for what you want.
Also, I think you should read and understand the code before you use it.
That way, you can try stuff yourself :)


All times are GMT -4. The time now is 05:36.

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