AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   if user die (https://forums.alliedmods.net/showthread.php?t=156516)

Groven 05-07-2011 19:26

if user die
 
Hello,

I'm new at coding so i'm trying to add so if he commit suicide he lose 1 points.

PHP Code:

public eDeath() 
{
    new 
killer read_data(1);
    new 
victim read_data(2);
    new 
gpoints_kill get_pcvar_num(points_kill);
    new 
gpoints_hs get_pcvar_num(points_hs);
    new 
gpoints_suicide get_pcvar_num(points_suicide);
 
    if( 
IsPlayer(killer) && is_user_connected(killer) )
    {
        if( 
victim != killer )
        {
            if( 
cs_get_user_team(victim) != cs_get_user_team(killer) )
            {
                if( 
is_user_alive(killer) )
                {                    
                    if(!
read_data(3))
                    {
                        
gCM[killer] += gpoints_kill
                        
Print(killer"You gained %d Points!"gpoints_kill );
                    }
                    else if(
read_data(3))
                    {
                        
gCM[killer] += (gpoints_kill gpoints_hs);
                        Print(
killer"You gained %d Points!^x01 (Headshot)", (gpoints_hs gpoints_kill ) );
                    }
                    if( 
is_user_dead(suicide) )
                    {
                        if(!
read_data(3))
                        {
                            
gCM[suicide] += gpoints_suicide
                            
Print(suicide"You lost %d Points for Suicide!"gpoints_suicide );
                        }
    
                    
CheckLevel(killer);
                    
SaveData(killer);
                }
            }
        }
    } 


fysiks 05-07-2011 20:09

Re: if user die
 
Add an else clause to the if( victim != killer ) then subtract the point there.

You'll also need to move the save data to the end of the first if() statement.

Groven 05-07-2011 20:23

Re: if user die
 
Like this?

PHP Code:

else if( victim != killer )
                    {
                        {
                            
gCM[suicide] += gpoints_suicide
                            
Print(suicide"You lost %d Points for Suicide!"gpoints_suicide );
                        } 


fysiks 05-07-2011 22:14

Re: if user die
 
No. What is the variable "suicide"??

EDIT:

PHP Code:

public eDeath()
{
    new 
killer read_data(1);
    new 
victim read_data(2);
    new 
gpoints_kill get_pcvar_num(points_kill);
    new 
gpoints_hs get_pcvar_num(points_hs);
    new 
gpoints_suicide get_pcvar_num(points_suicide);

    if( 
IsPlayer(killer) && is_user_connected(killer) )
    {
        if( 
victim != killer )
        {
            if( 
cs_get_user_team(victim) != cs_get_user_team(killer) )
            {
                if( 
is_user_alive(killer) )
                {
                    if(
read_data(3))
                    {
                        
gCM[killer] += (gpoints_kill gpoints_hs);
                        Print(
killer"You gained %d Points!^x01 (Headshot)", (gpoints_hs gpoints_kill ) );
                    }
                    else
                    {
                        
gCM[killer] += gpoints_kill
                        
Print(killer"You gained %d Points!"gpoints_kill );
                    }
                    
CheckLevel(killer);
                    
SaveData(killer);
                }
            }
        }
        else
        {
            
// killer is equal to victim (player killed self)
            
gCM[killer] += gpoints_suicide
            
Print(killer"You lost %d Points for Suicide!", -gpoints_suicide)
            
CheckLevel(killer);
            
SaveData(killer);
        }
        
    } 


kotinha 05-08-2011 06:39

Re: if user die
 
Can't killer be also 0 if the player commits suicide?

Groven 05-08-2011 10:12

Re: if user die
 
The suicide when a people step on a death block or die for falling they lose 1 point.

SonicSonedit 05-08-2011 10:26

Re: if user die
 
kotinha
Quote:

Can't killer be also 0 if the player commits suicide?
Actually this means that player was killed by worldspawn but in most cases engine equals this to suicide.
Also death by trigger_hurt counts as suicide AFAIK.

fysiks 05-08-2011 12:12

Re: if user die
 
Quote:

Originally Posted by SonicSonedit (Post 1465562)
kotinha
Actually this means that player was killed by worldspawn but in most cases engine equals this to suicide.
Also death by trigger_hurt counts as suicide AFAIK.

I've seen times that the killer was greater than 32 from certain map elements too. I'm quite sure they were trigger_hurts.

I seems like he wants: "if you die by something other than a player then you lose 1 point" which would require different code.


All times are GMT -4. The time now is 04:19.

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