Raised This Month: $ Target: $400
 0% 

pick random, then loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 08-21-2005 , 09:34   pick random, then loop
Reply With Quote #1

can someone give me an code snippet @ how to pick an random player and then make an loop that affects everybody but that person?

example:
everybody affected says "i was affected"

Code:
client_cmd(id,"I was affected by the loop")
Obbin is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 08-21-2005 , 09:38  
Reply With Quote #2

Code:
public MyFunc(id) {     new iRand = random_num(1,get_maxplayers())     if( is_user_connected(iRand) )     {         client_print(iRand,print_chat,"I was affected by teh func")     }     else     {         MyFunc(id)     } }
Bah, that's how I would do it.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 08-21-2005 , 10:02  
Reply With Quote #3

thx v3x but i wanted to make the opposit!
everybody exept one!

example:

players: 4/4 (george, bill, john, richard)
---> Function satrts and radndomly picks jhon!
bill: I was affected
richard: I was affected
george: I was affected
jhon: I was not affected
__________________
Sig(h)!
Obbin is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-21-2005 , 15:08  
Reply With Quote #4

shame shame, v3x, that could take forever when the game is running 3 / 32 players.

Code:
new players[32], num, i; get_players(players,num); new free = players[random_num(0,num-1)]; for(i=0;i<num;i++) {    if(players[i] != free) {       client_cmd(players[i],"say ^"Anais Anais smells so good!^"");    } }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 08-21-2005 , 19:29  
Reply With Quote #5

Ah yes, shame upon me.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
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 14:35.


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