Raised This Month: $12 Target: $400
 3% 

Random player problem


Post New Thread Reply   
 
Thread Tools Display Modes
kostov
Member
Join Date: Jan 2010
Location: Bulgaria, Sofia
Old 04-30-2010 , 04:23   Re: Random player problem
Reply With Quote #11

Example:

PHP Code:
#include <amxmodx>
#include <cstrike>

public plugin_init()
{
    
set_task20.0"Func"___"b" )
}

public 
Func(id)
{
    
//some code ...
    
Game_Start()
}

public 
Game_Start()
{
    static 
players[32], pnumi
    get_players
(playerspnum"a")
    
i=0;
    while(
i<pnum){
        if(
cs_get_user_team(players[i])!=CS_TEAM_CT)
            
players[i] = players[--pnum]
        else
            
i++
    }
    if(
pnum<=0){
        
//there are no cts alive
        
return
    }
    
cs_set_user_team(players[random(pnum)], CS_TEAM_T)

And choose whole team and not a one terrorist
kostov is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 04-30-2010 , 05:43   Re: Random player problem
Reply With Quote #12

this plugin moves one ct to terro every 20 seconds.

If it moves all players at once then it's a fault of:
PHP Code:
    //some code ... 
__________________
Impossible is Nothing
Sylwester is offline
kostov
Member
Join Date: Jan 2010
Location: Bulgaria, Sofia
Old 05-04-2010 , 03:47   Re: Random player problem
Reply With Quote #13

Sorry my mistake, now works but I have another problem. How do I do after I moved to terrorist moves in the base of terrorist without dying?

Edit:
Sample of:
PHP Code:
cs_user_spawn(players[random(pnum)])
and
spawn(players[random(pnum)]) 
and 
ExecuteHamB(Ham_CS_RoundRespawnplayers[random(pnum)]) 
but doesn't working

Last edited by kostov; 05-04-2010 at 03:50.
kostov is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-04-2010 , 03:48   Re: Random player problem
Reply With Quote #14

Show your code.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 05-04-2010 , 09:02   Re: Random player problem
Reply With Quote #15

I have wrote one(un-test)
correct me if it's wrong :
PHP Code:
myfunction()
{
    static 
id
    id 
random_num(132)
    if (
is_user_connected(id))
    {
        
//do something here
    
}

__________________
QQ:116268742

Last edited by K.K.Lv; 05-04-2010 at 09:11.
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-04-2010 , 09:34   Re: Random player problem
Reply With Quote #16

Quote:
Originally Posted by K.K.Lv View Post
correct me if it's wrong :
Ok. To correct your mistake delete your post, because you have no idea what is going on in this thread and by posting some random pieces of code you may only mislead less experienced users.
__________________
Impossible is Nothing
Sylwester is offline
kostov
Member
Join Date: Jan 2010
Location: Bulgaria, Sofia
Old 05-04-2010 , 11:45   Re: Random player problem
Reply With Quote #17

Quote:
Originally Posted by kostov View Post
Sorry my mistake, now works but I have another problem. How do I do after I moved to terrorist moves in the base of terrorist without dying?

Edit:
Sample of:
PHP Code:
cs_user_spawn(players[random(pnum)])
and
spawn(players[random(pnum)]) 
and 
ExecuteHamB(Ham_CS_RoundRespawnplayers[random(pnum)]) 
but doesn't working
But my question?
kostov is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-04-2010 , 13:14   Re: Random player problem
Reply With Quote #18

Didn't you read this? :
Quote:
Originally Posted by Exolent[jNr] View Post
Show your code.
With the previous example it would be like this:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>

public plugin_init()
{
    
set_task20.0"Func"___"b" )
}

public 
Func(id)
{
    
//some code ...
    
Game_Start()
}

public 
Game_Start()
{
    static 
players[32], pnumirandom_ct
    get_players
(playerspnum"a")
    
i=0;
    while(
i<pnum){
        if(
cs_get_user_team(players[i])!=CS_TEAM_CT)
            
players[i] = players[--pnum]
        else
            
i++
    }
    if(
pnum<=0){
        
//there are no cts alive
        
return
    }

    
random_ct players[random(pnum)]
    
cs_set_user_team(random_ctCS_TEAM_T)
    
ExecuteHam(Ham_CS_RoundRespawnrandom_ct)

__________________
Impossible is Nothing
Sylwester 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 18:24.


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