AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   RegisterHam Problem (https://forums.alliedmods.net/showthread.php?t=128779)

GXLZPGX 06-05-2010 10:35

RegisterHam Problem
 
Alright, I've been using:

PHP Code:

RegisterHam(Ham_Spawn"player""player_spawned"1

To execute commands when a player is spawned.

Then I use:

PHP Code:

public player_spawned(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_T)
    { 

To execute the command depending on what team. But it will only set the rendering on the player within 3 seconds of being spawned, then they go completely visible. So its like this:

PHP Code:

public player_spawned(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_T)
    {
        
fm_set_user_rendering(idkRenderFxNone255255255kRenderTransAlpha0); 

Why is it doing this? I want the invisibility to last the whole round.

Bugsy 06-05-2010 10:56

Re: RegisterHam Problem
 
Try
PHP Code:

public player_spawnediPlayer )
{
    if ( 
is_user_aliveiPlayer ) && ( cs_get_user_teamiPlayer ) == CS_TEAM_T ) )
    {
        
fm_set_user_renderingiPlayer kRenderFxNone000kRenderTransAlpha0);  
    }



GXLZPGX 06-05-2010 11:03

Re: RegisterHam Problem
 
Quote:

Originally Posted by Bugsy (Post 1200423)
Try
PHP Code:

public player_spawnediPlayer )
{
    if ( 
is_user_aliveiPlayer ) && ( cs_get_user_teamiPlayer ) == CS_TEAM_T ) )
    {
        
fm_set_user_renderingiPlayer kRenderFxNone000kRenderTransAlpha0);  
    }



I don't need to use "is_user_alive" though because I am executing Ham_Spawn so they should be spawned already right?

Bugsy 06-05-2010 11:05

Re: RegisterHam Problem
 
No, the is_user_alive() check is required to detect spawn in Ham_Spawn post.

GXLZPGX 06-05-2010 11:05

Re: RegisterHam Problem
 
Quote:

Originally Posted by Bugsy (Post 1200440)
No, the is_user_alive() check is required to detect spawn in Ham_Spawn post.

Thank you. Never knew that.

Now since I'm executing commands on different teams, can I do this?

PHP Code:

public player_spawned(iPlayer)
{
    if(
is_user_alive(iPlayer)
    {
        if(
cs_get_user_team(iPlayer) == CS_TEAM_T)
        {
            
fm_set_user_rendering(iPlayerkRenderFxNone255255255kRenderTransAlpha0);
        }
        if(
cs_get_user_team(iPlayer) == CS_TEAM_CT)
        {
            
give_item(iPlayer"weapon_hegrenade");
            
give_item(iPlayer"weapon_knife");
            
set_user_armor(iPlayerget_pcvar_num(humanarmor));
        }
    }



Backstabnoob 06-05-2010 11:22

Re: RegisterHam Problem
 
PHP Code:

if(is_user_alive(iPlayer

=>
PHP Code:

if(is_user_alive(iPlayer)) 

Also, you can switch() the cs_get_user_team function or at least use else if.

GXLZPGX 06-05-2010 11:29

Re: RegisterHam Problem
 
Quote:

Originally Posted by Backstabnoob (Post 1200461)
PHP Code:

if(is_user_alive(iPlayer

=>
PHP Code:

if(is_user_alive(iPlayer)) 

Also, you can switch() the cs_get_user_team function or at least use else if.

I have no experience with else if :/ Would you please use an example?

Bugsy 06-05-2010 11:31

Re: RegisterHam Problem
 
As backstab noob said... Also, you can user set_user_rendering() since you are using fun module. You also should use cs_set_user_armor().
PHP Code:

public player_spawned(iPlayer)
{
    if( 
is_user_aliveiPlayer ) )
    {
        if( 
cs_get_user_team(iPlayer) == CS_TEAM_T )
        {    
            
set_user_renderingiPlayer kRenderFxNone 255 255 255 kRenderTransAlpha );
        }
        else
        {
            
give_itemiPlayer "weapon_hegrenade" );
            
give_itemiPlayer "weapon_knife" );
            
set_user_armoriPlayer get_pcvar_numhumanarmor ) );
        }
    }




All times are GMT -4. The time now is 05:22.

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