Raised This Month: $ Target: $400
 0% 

[HELP] Random Selections


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 03-22-2011 , 20:02   [HELP] Random Selections
Reply With Quote #1

How would I code something to randomly pick ONE person out of both teams (CS 1.6) and put him on a team by himself against the rest of the people who werent selected

+karma for help!
__________________
Ayyylmao
malec321 is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 03-23-2011 , 17:42   Re: [HELP] Random Selections
Reply With Quote #2

Try this:

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"




#define OFFSET_TEAM 114
#define fm_get_user_team(%1) get_pdata_int(%1, OFFSET_TEAM)


new g_msg_teaminfo


enum
{
    
CS_TEAM_UNASSIGNED 0,
    
CS_TEAM_T,
    
CS_TEAM_CT,
    
CS_TEAM_SPECTATOR
}


new const 
g_teaminfo[][] = 

    
"UNASSIGNED"
    
"TERRORIST",
    
"CT",
    
"SPECTATOR" 
}


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("nowa_runda"2"1=Round_Start")
    
g_msg_teaminfo get_user_msgid("TeamInfo")

}



public 
nowa_runda(){
    new  
graczelosowanie
    gracze
=get_playersnum()
    static 
players[32], pnum
    get_players
(playerspnum"a")
    if(
pnum>0)
    
losowanie=players[random(pnum)]
    for(new 
id=0id<=graczeid++){
        if(
is_user_connected(id) && is_user_alive(id) && id==losowanie){
            
fm_set_user_team(idCS_TEAM_CT)
        }
        else{
            if(
is_user_connected(id) && is_user_alive(id)){
            
fm_set_user_team(idCS_TEAM_T)
        }
    }
}

    
}


stock fm_set_user_team(indexteamupdate 1)
{
    
set_pdata_int(indexOFFSET_TEAMteam)
    if(
update)
    {
        
emessage_begin(MSG_ALLg_msg_teaminfo)
        
ewrite_byte(index)
        
ewrite_string(g_teaminfo[team])
        
emessage_end()
    }
    return 
1

lis_16 is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 03-23-2011 , 21:30   Re: [HELP] Random Selections
Reply With Quote #3

Thanks a lot dude, and what if I wanted to edit what happens when the player is picked?
__________________
Ayyylmao
malec321 is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 03-24-2011 , 07:48   Re: [HELP] Random Selections
Reply With Quote #4

PHP Code:
 for(new id=0id<=graczeid++){
        if(
is_user_connected(id) && is_user_alive(id) && id==losowanie){
            
fm_set_user_team(idCS_TEAM_CT)
        } 
Here is pickied player moved to CT team (add some cool staff here). You can add new global variable like

picked[33]

and set it as true to picked player and u can do everything what you want in any event just adding if(picked[id]) do (...)
lis_16 is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 03-24-2011 , 22:02   Re: [HELP] Random Selections
Reply With Quote #5

Code:
new Float:speed = get_user_maxspeed(id) + 85.0
new Float:vamphp = get_user_health(id) + 14900.0

            set_user_health (id, hp)
        set_user_maxspeed(id, speed)
        set_user_gravity (id, Float:gravity = 0.5 )
Giving many errors on the gravity line and the HP line? why

And also lis, sry for the trouble but how can i make it so it waits 10 seconds before the selected person is picked

so its like

Round start,
10 seconds,
Player is picked
__________________
Ayyylmao

Last edited by malec321; 03-24-2011 at 22:19.
malec321 is offline
lis_16
Senior Member
Join Date: Feb 2008
Old 03-26-2011 , 08:48   Re: [HELP] Random Selections
Reply With Quote #6

1. Adding 10s delay:

Change name of event nowa_runda to fe. new_round, and a task in new_round: set_task(10.0, "nowa_runda").

2. Errors:

Use integral not a float to health: fe. set_user_healt(id, 1000)
Gravity- use like this: set_user_gravity(id, 0.5). This is 0.5*800, if you set 1.0 gravity is setting to normal-800. You can also do like this

new Float: gravity=0.5
set_user_gravity(id, gravity)
lis_16 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 14:34.


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