Raised This Month: $ Target: $400
 0% 

[HELP] Randomly select three terrorist


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
quLeryuzz
Member
Join Date: May 2010
Location: Istanbul
Old 11-18-2011 , 02:57   [HELP] Randomly select three terrorist
Reply With Quote #1

Hello, The following code selects random 3 live terrorist.I would like to choose the dead players.How can I do?

PHP Code:
            new Players[32], iCountrasgele1rasgele2rasgele3
            get_players
(Players,iCount,"ae","TERRORIST")
            if(
iCount 2)
            {
                
rasgele1 Playersrandom_num(0iCount) ]
                
rasgele2 Playersrandom_num(0iCount) ]
                
rasgele3 Playersrandom_num(0iCount) ]
                while( 
rasgele2 == rasgele3 || rasgele2 == rasgele1)
                {
                    
rasgele2 Playersrandom_num(0iCount) ]    
                }
                while( 
rasgele3 == rasgele1)
                {
                    
rasgele3 Playersrandom_num(0iCount) ]    
                }
                new 
terr1[64],terr2[64],terr3[64]
                
get_user_name(rasgele1terr163)
                
get_user_name(rasgele2terr263)
                
get_user_name(rasgele3terr363)
                
set_hudmessage(2552552550.030.6006.05.0,_,_,21)
                
show_hudmessage(0"Rasgele 3 Mahkum :^n%s^n%s^n%s",terr1,terr2,terr3
__________________

csduragi.com

Last edited by quLeryuzz; 11-18-2011 at 03:46.
quLeryuzz is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-18-2011 , 04:31   Re: [HELP] Randomly select three terrorist
Reply With Quote #2

Your code is very inefficient, this is how you should do it:
PHP Code:
            new Players[32], iCount
            get_players
(Players,iCount,"be","TERRORIST")
            
            new 
terr_id[3], terr_cntrandcache[96], posname[32]
            while(
iCount && terr_cnt 3)
            {
                
terr_id[terr_cnt] = Players[rand random(iCount)]
                
Players[rand] = Players[--iCount]
                
                
get_user_name(terr_id[terr_cnt], namesizeof(name)-1)
                
pos += formatex(cache[pos], sizeof(cache)-pos-1"^n%s"name)
                
                
terr_cnt++
            }
            
set_hudmessage(2552552550.030.6006.05.0,_,_,21)
            
show_hudmessage(0"Rasgele %d Mahkum :%s"terr_cntcache
__________________
Impossible is Nothing

Last edited by Sylwester; 11-18-2011 at 04:33.
Sylwester is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 11-18-2011 , 05:37   Re: [HELP] Randomly select three terrorist
Reply With Quote #3

Use charsmax instead of sizeof -1
Devil259 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-18-2011 , 06:04   Re: [HELP] Randomly select three terrorist
Reply With Quote #4

Quote:
Originally Posted by Devil259 View Post
Use charsmax instead of sizeof -1
Doesn't matter, it's the same thing.

string.inc:
Code:
#define charsmax(%1) (sizeof(%1)-1)
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
quLeryuzz
Member
Join Date: May 2010
Location: Istanbul
Old 11-18-2011 , 11:01   Re: [HELP] Randomly select three terrorist
Reply With Quote #5

I guess I could not tell.I want to randomly select 3 players different from each other.I gave my players not dead code.I would like to take this to the players dead
__________________

csduragi.com
quLeryuzz is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-18-2011 , 11:28   Re: [HELP] Randomly select three terrorist
Reply With Quote #6

Did you check my code? It should do what you requested (randomly selects up to 3 dead terrorists).
__________________
Impossible is Nothing
Sylwester is offline
quLeryuzz
Member
Join Date: May 2010
Location: Istanbul
Old 11-18-2011 , 11:33   Re: [HELP] Randomly select three terrorist
Reply With Quote #7

@Sylwester
I tried yours."Rasgele 0 Mahkum : ----" I do not get a result.
__________________

csduragi.com
quLeryuzz is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-18-2011 , 12:07   Re: [HELP] Randomly select three terrorist
Reply With Quote #8

To get results you need to have dead terrorists on your server.
__________________
Impossible is Nothing
Sylwester is offline
quLeryuzz
Member
Join Date: May 2010
Location: Istanbul
Old 11-18-2011 , 12:12   Re: [HELP] Randomly select three terrorist
Reply With Quote #9

For both live and dead I wanted to make a selection.
__________________

csduragi.com
quLeryuzz is offline
quLeryuzz
Member
Join Date: May 2010
Location: Istanbul
Old 11-18-2011 , 12:21   Re: [HELP] Randomly select three terrorist
Reply With Quote #10

I solved the problem.Thank those who help

PHP Code:
            get_players(Players,iCount,"be","TERRORIST"
>

PHP Code:
            get_players(Players,iCount,"e","TERRORIST"
__________________

csduragi.com

Last edited by quLeryuzz; 11-18-2011 at 12:22.
quLeryuzz is offline
Reply


Thread Tools
Display Modes

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 08:34.


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