AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Suicide experience (https://forums.alliedmods.net/showthread.php?t=212608)

wEEk 04-04-2013 20:24

[Help] Suicide experience
 
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)



Blizzard_87 04-04-2013 20:49

Re: [Help] Suicide experience
 
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



wEEk 04-04-2013 23:52

Re: [Help] Suicide experience
 
Hi, thanks I tried it but instead of that gain experience gives me two bone frags, I duplicated the experience

EpicMonkey 04-05-2013 04:38

Re: [Help] Suicide experience
 
PHP Code:

if(victim == attacker)
        return 
PLUGIN_HANDLED

to

PHP Code:

if(attacker == || attacker == victim)
{
        return 
PLUGIN_HANDLED;



didoWEE 04-05-2013 07:14

Re: [Help] Suicide experience
 
Quote:

Originally Posted by EpicMonkey (Post 1926639)
PHP Code:

if(attacker == || attacker == victim)
        return 
PLUGIN_HANDLED


-->
PHP Code:

if(!attacker || attacker == victim)
        return 
PLUGIN_HANDLED


hornet 04-05-2013 07:32

Re: [Help] Suicide experience
 
@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 (Post 1926692)
-->
PHP Code:

if(!attacker || attacker == victim)
        return 
PLUGIN_HANDLED


No difference.

Blizzard_87 04-05-2013 07:51

Re: [Help] Suicide experience
 
Quote:

Originally Posted by hornet (Post 1926705)
@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.


All times are GMT -4. The time now is 08:49.

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