Raised This Month: $ Target: $400
 0% 

Random Player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Merc3y
Member
Join Date: Dec 2009
Old 01-01-2010 , 04:20   Random Player
Reply With Quote #1

What wrong with this ?

I wanted to make 1 random player to be a stalker instead it giving me more than 1

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <amxmisc>

new cvar_delay

new Night_StalkerMaxPlayers

public plugin_init( )
{
    
register_plugin"Night Stalker Mod""1.0""Merc3y" )

    
register_logevent"logevent_round_start"2"1=Round_Start" 
    
register_logevent"logevent_round_end"2"1=Round_End" 
    
    
register_concmd"amx_nightstalker""Toggle"ADMIN_LEVEL_D" < 1 = on | 0 = off >" )
    
register_cvar"nightstalker_toggle""0" )

    
cvar_delay register_cvar"ns_delay""10.0" )

    
MaxPlayers get_maxplayers( )
}

public 
Game_Startid )
{
        new 
players32 ], num
        get_players
playersnum"a" )
        
Night_Stalker playersrandom_num1num ) ]
        
StatsNight_Stalker )
}

public 
Statsid )
{
        
fm_set_user_healthNight_Stalker250 )
        
fm_set_user_gravityNight_Stalker0.7 )


public 
Toggleidlevelcid )
{
    if ( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED
    
}
    new 
arg132 ]
    
read_argv1arg131 )
    if ( 
str_to_numarg1 ) )
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    } 

    else
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    }       
    return 
PLUGIN_HANDLED
}

public 
logevent_round_start( )
{
    for ( new 
1<= MaxPlayersi++ )
    {
        if ( 
get_cvar_num"nightstalker_toggle" ) == )
        {
            
set_taskget_pcvar_floatcvar_delay ), "Game_Start" )
        }

        else if ( 
get_cvar_num"nightstalker_toggle" ) == )
        {
            
remove_task)
        }
    }
}

public 
logevent_round_end( )
{
    for ( new 
1<= MaxPlayersi++ )
    {
        
remove_task)
    }

Help needed.
__________________
How I Wish That I Can Host Without Any Problem.

Last edited by Merc3y; 01-01-2010 at 04:49.
Merc3y is offline
wyrda
Member
Join Date: Nov 2009
Old 01-01-2010 , 11:30   Re: Random Player
Reply With Quote #2

If you want only one player to have his health and gravity changed after that delay this is the code:
PHP Code:
#include <amxmodx>
#include <fun>
#include <amxmisc>

new cvar_delay

new Night_Stalker

public plugin_init( )
{
    
register_plugin"Night Stalker Mod""1.0""Merc3y" )

    
register_logevent"logevent_round_start"2"1=Round_Start" 
    
register_logevent"logevent_round_end"2"1=Round_End" 
    
    
register_concmd"amx_nightstalker""Toggle"ADMIN_LEVEL_D" < 1 = on | 0 = off >" )
    
register_cvar"nightstalker_toggle""0" )

    
cvar_delay register_cvar"ns_delay""10.0" )

    
}

public 
Game_Startid )
{
    new 
players32 ], num
    get_players
playersnum"a" )
    
Night_Stalker playersrandom_num0num-) ]
    if(
is_user_alive(Night_Stalker))
        
StatsNight_Stalker )
}

public 
Statsid )
{
    
set_user_healthNight_Stalker250 )
    
set_user_gravityNight_Stalker0.7 )


public 
Toggleidlevelcid )
{
    if ( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED
    
}
    new 
arg132 ]
    
read_argv1arg131 )
    if ( 
str_to_numarg1 ) )
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    } 

    else
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    }       
    return 
PLUGIN_HANDLED
}

public 
logevent_round_start( )
{    
        if ( 
get_cvar_num"nightstalker_toggle" ) == )
        {
            
set_taskget_pcvar_floatcvar_delay ), "Game_Start" )
        }   
}

public 
logevent_round_end( )
{
   public 
logevent_round_end( )
{
    
is_user_connected(Night_Stalker)
    {
        if(
is_user_alive(Night_Stalker))
            
set_user_healthNight_Stalker100 )
        
set_user_gravityNight_Stalker1.0 )
    }
}

also at the end of the round if he is alive his life will be restored to 100(even I think that this is not necessary)
__________________

Last edited by wyrda; 01-01-2010 at 11:55.
wyrda is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-01-2010 , 12:15   Re: Random Player
Reply With Quote #3

Quote:
Originally Posted by wyrda View Post
If you want only one player to have his health and gravity changed after that delay this is the code:
PHP Code:
#include <amxmodx>
#include <fun>
#include <amxmisc>
 
new cvar_delay
 
new Night_Stalker
 
public plugin_init( )
{
    
register_plugin"Night Stalker Mod""1.0""Merc3y" )
 
    
register_logevent"logevent_round_start"2"1=Round_Start" 
    
register_logevent"logevent_round_end"2"1=Round_End" 
 
    
register_concmd"amx_nightstalker""Toggle"ADMIN_LEVEL_D" < 1 = on | 0 = off >" )
    
register_cvar"nightstalker_toggle""0" )
 
    
cvar_delay register_cvar"ns_delay""10.0" )
 
 
}
 
public 
Game_Startid )
{
    new 
players32 ], num
    get_players
playersnum"a" )
    
Night_Stalker playersrandom_num0num-) ]
    if(
is_user_alive(Night_Stalker))
        
StatsNight_Stalker )
}
 
public 
Statsid )
{
    
set_user_healthNight_Stalker250 )
    
set_user_gravityNight_Stalker0.7 )

 
public 
Toggleidlevelcid )
{
    if ( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED
    
}
    new 
arg132 ]
    
read_argv1arg131 )
    if ( 
str_to_numarg1 ) )
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    } 
 
    else
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    }       
    return 
PLUGIN_HANDLED
}
 
public 
logevent_round_start( )
{    
        if ( 
get_cvar_num"nightstalker_toggle" ) == )
        {
            
set_taskget_pcvar_floatcvar_delay ), "Game_Start" )
        }   
}
 
public 
logevent_round_end( )
{
   public 
logevent_round_end( )
{
    
is_user_connected(Night_Stalker)
    {
        if(
is_user_alive(Night_Stalker))
            
set_user_healthNight_Stalker100 )
        
set_user_gravityNight_Stalker1.0 )
    }
}

also at the end of the round if he is alive his life will be restored to 100(even I think that this is not necessary)
Sorry about the MaxPlayers thing. that was not the full code.

"even I think that this is not necessary" Yeah.

Haven't test the code yet. EDIT: Still instead of 1 it make all player stalker.
__________________
How I Wish That I Can Host Without Any Problem.

Last edited by Merc3y; 01-01-2010 at 12:28.
Merc3y is offline
wyrda
Member
Join Date: Nov 2009
Old 01-01-2010 , 15:13   Re: Random Player
Reply With Quote #4

I attached the file that I tested on my server. It worked for my well.
I think that you didn't replace the old plugin because your code make all player stalker.
P.S. I changed this register_cvar( "nightstalker_toggle", "0" ) to register_cvar( "nightstalker_toggle", "1" ) :p
Attached Files
File Type: sma Get Plugin or Get Source (stalker.sma - 626 views - 1.7 KB)
__________________
wyrda is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-01-2010 , 15:26   Re: Random Player
Reply With Quote #5

Quote:
Originally Posted by wyrda View Post
I attached the file that I tested on my server. It worked for my well.
I think that you didn't replace the old plugin because your code make all player stalker.
P.S. I changed this register_cvar( "nightstalker_toggle", "0" ) to register_cvar( "nightstalker_toggle", "1" ) :p
This is my code:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <amxmisc>
 
new cvar_delay
 
new Night_Stalker
 
public plugin_init( )
{
    
register_plugin"Night Stalker Mod""1.0""Merc3y" )
 
    
register_logevent"logevent_round_start"2"1=Round_Start" 
    
register_logevent"logevent_round_end"2"1=Round_End" )
 
    
register_concmd"amx_nightstalker""Toggle"ADMIN_LEVEL_D" < 1 = on | 0 = off >" )
    
register_cvar"nightstalker_toggle""0" )
    
cvar_delay register_cvar"ns_delay""10.0" )
}
 
public 
Game_Startid )
{
    new 
players32 ], num
    get_players
playersnum"a" )
    
Night_Stalker playersrandom_num0num-) ]
 
    if ( 
is_user_aliveNight_Stalker ) )
    {
        
StatsNight_Stalker )
    }
}
 
public 
Statsid )
{    
    
fm_set_user_healthNight_Stalker200 )
    
fm_set_user_gravityNight_Stalker200 )

 
public 
Toggleidlevelcid )
{
    if ( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED
    
}
    new 
arg132 ]
    
read_argv1arg131 )
    if ( 
str_to_numarg1 ) )
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    } 
    else
    {
            
set_cvar_num"nightstalker_toggle")
            
server_cmd"sv_restartround 10" )
    }       
    return 
PLUGIN_HANDLED
}
 
public 
logevent_round_start( )
{
        if ( 
get_cvar_num"nightstalker_toggle" ) == )
        {
            
set_taskget_pcvar_floatcvar_delay ), "Game_Start" )
        }
        else if ( 
get_cvar_num"nightstalker_toggle" ) == )
        {
            
remove_task)
        }
}
 
public 
logevent_round_end( )
{
        
remove_task)

And it still giving me more than 1 stalker instead of 1 ?
__________________
How I Wish That I Can Host Without Any Problem.
Merc3y is offline
wyrda
Member
Join Date: Nov 2009
Old 01-01-2010 , 17:34   Re: Random Player
Reply With Quote #6

I didn''t test your code because this functions fm_set_user_health,fm_set_user_gravity does not exists(I think that you wrote them or maybe is an older version of amxmodx) and it should work.
__________________
wyrda is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-02-2010 , 01:42   Re: Random Player
Reply With Quote #7

Quote:
Originally Posted by wyrda View Post
I didn''t test your code because this functions fm_set_user_health,fm_set_user_gravity does not exists(I think that you wrote them or maybe is an older version of amxmodx) and it should work.
Like i say this is not the full code. Just add like this ?

PHP Code:
stock fm_set_user_health(indexhealth) {
 
health set_pev(indexpev_healthfloat(health)) : dllfunc(DLLFunc_ClientKillindex);
 return 
1;
}

stock fm_set_user_gravity(indexFloat:gravity 1.0) {
 
set_pev(indexpev_gravitygravity);
 return 
1;

__________________
How I Wish That I Can Host Without Any Problem.
Merc3y is offline
wyrda
Member
Join Date: Nov 2009
Old 01-02-2010 , 05:34   Re: Random Player
Reply With Quote #8

I didn't use set_pev so I can not say what is wrong.Still I don't understand why don't you use set_user_health when I works well.
__________________
wyrda is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-02-2010 , 08:42   Re: Random Player
Reply With Quote #9

Quote:
Originally Posted by wyrda View Post
I didn't use set_pev so I can not say what is wrong.Still I don't understand why don't you use set_user_health when I works well.
Reduce include.
__________________
How I Wish That I Can Host Without Any Problem.
Merc3y is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2010 , 15:21   Re: Random Player
Reply With Quote #10

Quote:
Originally Posted by Merc3y View Post
Reduce include.
Doesn't make it any better. Use the most efficient function. set_user_health() is more efficient.
__________________
fysiks 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 04:07.


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