Raised This Month: $ Target: $400
 0% 

Random player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
purple nurple
Senior Member
Join Date: Jun 2007
Location: US Missouri
Old 10-14-2007 , 02:17   Random player
Reply With Quote #1

Can someone help me with this. I want a random person to be choosen at the beginning of the round or sometime around then. I want it like this so it chooses one person out of everyone in the server and gives them stuff.

PHP Code:
public event_round_start(id)
{
    
set_task(5.0,"random_person",id)
}

public 
random_person(id)
{
    
//random person code in here.
}

public 
person(id)
{
    
//e.g.
    
cs_set_user_health(id,1000)
    
//other stuff to

Thats how i want it. If you can help me thanks alot.
purple nurple is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-14-2007 , 02:41   Re: Random player
Reply With Quote #2

Humm, maybe something like :

Code:
    #include <amxmodx>     #include <fakemeta>     public plugin_init()     {         register_plugin( "", "1.0", "Amxx Community" );         register_event( "HLTV", "eNew_round", "a", "1=0", "2=0" );     }         public eNew_round()     {         give_extra( random_person() );     }         random_person()     {         new iRandom_id = random_num( 1, get_playersnum() );                 return is_user_alive( iRandom_id ) ? iRandom_id : random_person();     }         give_extra( id )     {         set_pev( id, pev_health, 1000.0 );     }

New Round is happen at the freeze time start.

Quote:
or sometime around then
Use that. You can choose an interval.

Code:
    public eNew_round()     {         set_task( random_float( 2.0, 6.0 ), "random_person" );     }



EDIT: hm. I have a doubt about something. You can use this if above doesn't work well.

Code:
    random_person()     {         new iPlayers[32], iNum         get_players( iPlayers, iNum, "a" );                 return iPlayers[ random( iNum ) ];     }
__________________

Last edited by Arkshine; 10-14-2007 at 03:23.
Arkshine is offline
Old 10-14-2007, 19:46
purple nurple
This message has been deleted by purple nurple. Reason: double post oops
purple nurple
Senior Member
Join Date: Jun 2007
Location: US Missouri
Old 10-14-2007 , 19:46   Re: Random player
Reply With Quote #4

Quote:
random_person()
{
new iPlayers[32], iNum
get_players( iPlayers, iNum, "a" );

return iPlayers[ random( iNum ) ];
}
could i have alittle more help on the second one you gave me how do I make it so it gives stuff to the random player?
purple nurple is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-14-2007 , 22:03   Re: Random player
Reply With Quote #5

It retrieves a player list (alive) and return a random player id.

Of course you have to replace this function by the other above.


Code:
    #include <amxmodx>     #include <fakemeta>     public plugin_init()     {         register_plugin( "", "1.0", "Amxx Community" );         register_event( "HLTV", "eNew_round", "a", "1=0", "2=0" );     }         public eNew_round()     {         give_extra( random_person() );     }         random_person()     {         new iPlayers[32], iNum         get_players( iPlayers, iNum, "a" );                 return iPlayers[ random( iNum ) ];     }         give_extra( id )     {         set_pev( id, pev_health, 1000.0 );     }
__________________
Arkshine 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 01:23.


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