AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Random Selections (https://forums.alliedmods.net/showthread.php?t=153397)

malec321 03-22-2011 20:02

[HELP] Random Selections
 
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!

lis_16 03-23-2011 17:42

Re: [HELP] Random Selections
 
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



malec321 03-23-2011 21:30

Re: [HELP] Random Selections
 
Thanks a lot dude, and what if I wanted to edit what happens when the player is picked?

lis_16 03-24-2011 07:48

Re: [HELP] Random Selections
 
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 (...)

malec321 03-24-2011 22:02

Re: [HELP] Random Selections
 
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

lis_16 03-26-2011 08:48

Re: [HELP] Random Selections
 
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)


All times are GMT -4. The time now is 14:34.

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