Raised This Month: $ Target: $400
 0% 

Choose random player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-03-2012 , 13:16   Choose random player
Reply With Quote #1

title say all..

i've thought of this which wont work i guess...
PHP Code:
new players[32], count
get_players
(playerscount"a")

players[random(count)] 
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-03-2012 , 13:18   Re: Choose random player
Reply With Quote #2

It will work, just assign it to a variable.
__________________
<VeCo> is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-03-2012 , 13:19   Re: Choose random player
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
It will work, just assign it to a variable.
new randomplayer = players[random(count)] ?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-03-2012 , 13:20   Re: Choose random player
Reply With Quote #4

Yes, then that will be the index of the random player.
__________________

Last edited by <VeCo>; 05-03-2012 at 13:21.
<VeCo> is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-03-2012 , 13:24   Re: Choose random player
Reply With Quote #5

PHP Code:
public Cmd_KillVip(id) {
    
    new 
players[32], tsct
    get_players
(playersts"a""TERRORIST")
    
get_players(playersct"a""CT")
    
    new 
randomtsplayer players[random(ts)]
    new 
randomctplayer players[random(ct)]
    
    
set_user_health(randomtsplayer300)
    
set_user_health(randomctplayer300)
    
    
ColorChat(idGREEN"[%s] Objective:^1 Kill the opposite VIP!"szPrefix)
    
ColorChat(idGREEN"[%s]^1 The current round is:^4 Kill the VIP!"szPrefix)

Will this work?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-03-2012 , 13:29   Re: Choose random player
Reply With Quote #6

You don't need 2 variables if you only use the indexes for this.

PHP Code:
new players[32], countrandomplayer
 
get_players
(players,count,"ae","TERRORIST")
randomplayer players[random(count)]
set_user_health(randomplayer,300)
// if you need the random T index after this code, then you should make 2 variables, because we are getting the CT index in the same variable.......
 
get_players(players,count,"ae","CT")
randomplayer players[random(count)]
set_user_health(randomplayer,300)
 
ColorChat(idGREEN"[%s] Objective:^1 Kill the opposite VIP!"szPrefix)
ColorChat(idGREEN"[%s]^1 The current round is:^4 Kill the VIP!"szPrefix
Also, you need the "e" flag for the specific team in get_players.
__________________

Last edited by <VeCo>; 05-03-2012 at 13:30.
<VeCo> is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-03-2012 , 13:36   Re: Choose random player
Reply With Quote #7

ohh, thanks
__________________
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 00:19.


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