AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Rand player (https://forums.alliedmods.net/showthread.php?t=159948)

usaexelent 06-23-2011 13:49

[Help] Rand player
 
Hi all i want to know how to pick up a random player to get boost.

This is what i trayied:


new maxplayers = get_maxplayers()
new rand = random_num(1,maxplayers)
client_cmd(rand, "say boost")

It happens on new round.


Code:

public Boost(id)
{
new pinigai = cs_get_user_money(id)
        if (prasidejo == true)
        {
                if (aktiv == false)
                {
                        if(pinigai >= get_pcvar_num(kaina))
                        {
                        client_print_color(id, GREY, "^4[Boost]^3 You just bought boost!")
                        set_user_health(id, ( get_user_health(id)+15 ) );
                        set_user_gravity(id,Float:0.9)
                        set_user_maxspeed(id, -1)
                        new pinigu_praradimas = pinigai - get_pcvar_num(kaina)
                        cs_set_user_money(id, pinigu_praradimas)
                        aktiv = true
                        client_cmd(id, "spk ^"sound/boost.wav^"")
                        }
                        else
                        {
                        client_print_color(id, GREY, "^4[Boost]^3 You dont have that much money!")
                        }
                }
                else
                {
                client_print_color(id, GREY, "^4[Boost]^3 You already have boost!")
                }
        }
        else
        {
        client_print_color(id, GREY, "^4[Boost]^3 Round hasn't started yet.")
        }
}

And this is the main function, it happens when some one says boost

I don't really know why people uses this array, player[33]

I know that this some how affects the players to know their id :/


And BTW i want to make that player enter one team and the others transfer to other team.

fysiks 06-23-2011 15:54

Re: [Help] Rand player
 
PHP Code:

new iPlayers[32], iNumPlayers
get_players
(iPlayersiNumPlayers)
new 
randomplayerid iPlayers[random(iNumPlayers)] // will include all players regardless of team status (spec, unassigned, ct, t) 


usaexelent 06-24-2011 05:21

Re: [Help] Rand player
 
Thanks :)


All times are GMT -4. The time now is 23:32.

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