Raised This Month: $ Target: $400
 0% 

if user die


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Groven
AlliedModders Donor
Join Date: Apr 2011
Location: Sweden
Old 05-07-2011 , 19:26   if user die
Reply With Quote #1

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);
                }
            }
        }
    } 
Groven is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-07-2011 , 20:09   Re: if user die
Reply With Quote #2

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.
__________________

Last edited by fysiks; 05-07-2011 at 20:13.
fysiks is offline
Groven
AlliedModders Donor
Join Date: Apr 2011
Location: Sweden
Old 05-07-2011 , 20:23   Re: if user die
Reply With Quote #3

Like this?

PHP Code:
else if( victim != killer )
                    {
                        {
                            
gCM[suicide] += gpoints_suicide
                            
Print(suicide"You lost %d Points for Suicide!"gpoints_suicide );
                        } 
Groven is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-07-2011 , 22:14   Re: if user die
Reply With Quote #4

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);
        }
        
    } 
__________________

Last edited by fysiks; 05-07-2011 at 22:22.
fysiks is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 05-08-2011 , 06:39   Re: if user die
Reply With Quote #5

Can't killer be also 0 if the player commits suicide?
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
Groven
AlliedModders Donor
Join Date: Apr 2011
Location: Sweden
Old 05-08-2011 , 10:12   Re: if user die
Reply With Quote #6

The suicide when a people step on a death block or die for falling they lose 1 point.
Groven is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-08-2011 , 10:26   Re: if user die
Reply With Quote #7

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.
__________________

SonicSonedit is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-08-2011 , 12:12   Re: if user die
Reply With Quote #8

Quote:
Originally Posted by SonicSonedit View Post
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.
__________________
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:19.


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