Raised This Month: $ Target: $400
 0% 

Get a random player in each team.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 01-07-2014 , 13:26   Get a random player in each team.
Reply With Quote #1

Hello guys,

I would like to ask you for help, because I don't know how to get a random player in each team.
I have got this code
Code:
public Losuj_Kapitanow(id){
new players[32],numCT, numTT
if(!Kapitan_CTbool){
    get_players(players, numCT, "che", "CT")
    Kapitan_CT[id]=players[random(numCT)]
}
if(!Kapitan_TTbool){
    get_players(players, numTT, "che", "TERRORIST")
    Kapitan_TT[id]=players[random(numTT)]
}
CountDown()
if(Czas_Odliczania == 0){
    if(is_user_connected(id) && get_user_team(id) == 1 && !Kapitan_TTbool){
        set_hudmessage(255, 0, 0, -1.0, 0.01)
        show_hudmessage(id, "Wybrano Kapitanow!^nKapitan TT: %s", Kapitan_TT[id])
        Kapitan_TTbool=true;
    }
    if(is_user_connected(id) && get_user_team(id) == 2 && !Kapitan_CTbool){
        set_hudmessage(0, 255, 0, -1.0, 0.01)
        show_hudmessage(id, "Wybrano Kapitanow!^nKapitan CT: %s", Kapitan_CT[id])
        Kapitan_CTbool=true;
    }
}
}
And it doesn't work and gives me an error.
Code:
L 01/07/2014 - 19:24:24: Start of error session.
L 01/07/2014 - 19:24:24: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20140107.log")
L 01/07/2014 - 19:24:24: [AMXX] Displaying debug trace (plugin "kapitanowie.amxx")
L 01/07/2014 - 19:24:24: [AMXX] Run time error 4: index out of bounds 
L 01/07/2014 - 19:24:24: [AMXX]    [0] kapitanowie.sma::Losuj_Kapitanow (line 52)
It doesn't get a random player.
52 line is a "Kapitan_CT[id]=players[random(numCT)]"

Thanks for any help.
danonix is offline
 



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 10:05.


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