Raised This Month: $ Target: $400
 0% 

[Help] Suicide experience


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wEEk
Senior Member
Join Date: Sep 2012
Old 04-04-2013 , 20:24   [Help] Suicide experience
Reply With Quote #1

Hello, someone could help me because when they commit suicide either slay, kill and lasermine gain experience?

PHP Code:
public fw_PlayerKilled(victimattackershouldgib)

    if (
get_user_weapon(attacker) == CSW_HEGRENADE)
    {
        
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
        
client_print(attackerprint_chat,"You won  [1 Frags]")
    
        if(
get_pcvar_num(SaveXP) == 1
        { 
                
SaveData(attacker)
        }
    }
    
    if (
get_user_weapon(attacker) == CSW_KNIFE)
    {
        
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
        
client_print(attackerprint_chat"You won [1 Frags]")
    
        if(
get_pcvar_num(SaveXP) == 1
        { 
                
SaveData(attacker
        }
    }
    else
    {
        
PlayerXP[attacker] += get_pcvar_num(XP_Kill
        
client_print(attackerprint_chat"You won [1 Frags]")
        if(
get_pcvar_num(SaveXP) == 1
        { 
                
SaveData(attacker
        }
    }

    while(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) 
    { 
        
PlayerLevel[attacker]++
        
client_print(attackerprint_chat"You win a level: %d"PlayerLevel[attacker])

        if(
get_pcvar_num(SaveXP) == 1
        { 
            
SaveData(attacker
        }
    } 
    
SaveData(attacker)

wEEk is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-04-2013 , 20:49   Re: [Help] Suicide experience
Reply With Quote #2

PHP Code:
public fw_PlayerKilled(victimattackershouldgib
{  

    if(
victim == attacker)
        return 
PLUGIN_HANDLED;

    if (
get_user_weapon(attacker) == CSW_HEGRENADE
    { 
        
PlayerXP[attacker] += get_pcvar_num(XP_Hs
        
client_print(attackerprint_chat,"You won  [1 Frags]"
     
        if(
get_pcvar_num(SaveXP) == 1)  
        {  
                
SaveData(attacker
        } 
    } 
     
    if (
get_user_weapon(attacker) == CSW_KNIFE
    { 
        
PlayerXP[attacker] += get_pcvar_num(XP_Knife
        
client_print(attackerprint_chat"You won [1 Frags]"
     
        if(
get_pcvar_num(SaveXP) == 1)  
        {  
                
SaveData(attacker)  
        } 
    } 
    else 
    { 
        
PlayerXP[attacker] += get_pcvar_num(XP_Kill)  
        
client_print(attackerprint_chat"You won [1 Frags]"
        if(
get_pcvar_num(SaveXP) == 1)  
        {  
                
SaveData(attacker)  
        } 
    } 

    while(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])  
    {  
        
PlayerLevel[attacker]++ 
        
client_print(attackerprint_chat"You win a level: %d"PlayerLevel[attacker]) 

        if(
get_pcvar_num(SaveXP) == 1)  
        {  
            
SaveData(attacker)  
        } 
    }  
    
SaveData(attacker

__________________
Blizzard_87 is offline
wEEk
Senior Member
Join Date: Sep 2012
Old 04-04-2013 , 23:52   Re: [Help] Suicide experience
Reply With Quote #3

Hi, thanks I tried it but instead of that gain experience gives me two bone frags, I duplicated the experience
wEEk is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-05-2013 , 04:38   Re: [Help] Suicide experience
Reply With Quote #4

PHP Code:
if(victim == attacker)
        return 
PLUGIN_HANDLED
to

PHP Code:
if(attacker == || attacker == victim)
{
        return 
PLUGIN_HANDLED;


Last edited by EpicMonkey; 04-05-2013 at 04:38.
EpicMonkey is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-05-2013 , 07:14   Re: [Help] Suicide experience
Reply With Quote #5

Quote:
Originally Posted by EpicMonkey View Post
PHP Code:
if(attacker == || attacker == victim)
        return 
PLUGIN_HANDLED
-->
PHP Code:
if(!attacker || attacker == victim)
        return 
PLUGIN_HANDLED
didoWEE is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-05-2013 , 07:32   Re: [Help] Suicide experience
Reply With Quote #6

@wEEK & @Blizzard_87 you cannot use get_user_weapon() with grenades in this case ... that function returns the weapon that the player is holding ... meaning that if the player was killed by a grenade, the attacker would not still be holding one.
You should use DeathMsg instead, and read data 4, or use client_death() with CSX module which gives you the CSW_* constant.
The rest of your code could also be simplified.

Quote:
Originally Posted by didoWEE View Post
-->
PHP Code:
if(!attacker || attacker == victim)
        return 
PLUGIN_HANDLED
No difference.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-05-2013 , 07:51   Re: [Help] Suicide experience
Reply With Quote #7

Quote:
Originally Posted by hornet View Post
@wEEK & @Blizzard_87 you cannot use get_user_weapon() with grenades in this case ... that function returns the weapon that the player is holding ... meaning that if the player was killed by a grenade, the attacker would not still be holding one.
You should use DeathMsg instead, and read data 4, or use client_death() with CSX module which gives you the CSW_* constant.
The rest of your code could also be simplified.



No difference.
i was only going off what code he had.... without showing anymore i didnt know what function he was using...

i only added the if(victim == attacker) check.. rest of code was his.... i know the get_user_weapon wouldnt work but that was not the question he asked.
__________________
Blizzard_87 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 02:51.


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