Raised This Month: $ Target: $400
 0% 

Any idea why this code doesn't work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 01-22-2013 , 11:59   Any idea why this code doesn't work?
Reply With Quote #1

PHP Code:
public fw_player_killed(victimattackershouldgibid)
{
    if(
get_user_team(attacker) == 1)
    {
        
g_jbpacks[attacker] += get_pcvar_num(g_killjp
        
        if(
get_pdata_int(victim75) == HIT_HEAD)
        {
            
g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
        }
    }
    
    else if (
get_user_team(attacker) == && !(get_user_flags(id) & ADMIN_LEVEL_H))
    {
        
g_jbpacks[attacker] += get_pcvar_num(g_killjpvip
        
        if(
get_pdata_int(victim75) == HIT_HEAD)
        {
            
g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
        }
    }

__________________
DeLiriuM is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-22-2013 , 12:47   Re: Any idea why this code doesn't work?
Reply With Quote #2

What doesn't work? You need to find which part doesn't work specifically. Is the function being called? What part of the code does and does not execute?

Also, your elseif will never be executed. You should combine the two and only change the part where the two codes differ.
__________________

Last edited by fysiks; 01-22-2013 at 12:49.
fysiks is offline
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 01-22-2013 , 13:40   Re: Any idea why this code doesn't work?
Reply With Quote #3

Normal users should recieve X amount of jbpacks + Z amount (if killed with HS), VIP users (ADMIN_LEVEL_H) should recieve Y amount of jbpacks + Z amount (if killed with HS), but they don't.
Would you give me an example?
__________________

Last edited by DeLiriuM; 01-25-2013 at 05:58.
DeLiriuM is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-22-2013 , 15:29   Re: Any idea why this code doesn't work?
Reply With Quote #4

Try:
Code:
public fw_player_killed(victim, attacker, shouldgib, id)
{
    if(get_user_team(attacker) == 1 && !(get_user_flags(id) & ADMIN_LEVEL_H))
    {
        g_jbpacks[attacker] += get_pcvar_num(g_killjp) 
        
        if(get_pdata_int(victim, 75) == HIT_HEAD)
        {
            g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
        }
    }
    
    else if (get_user_team(attacker) == 1 && (get_user_flags(id) & ADMIN_LEVEL_H))
    {
        g_jbpacks[attacker] += get_pcvar_num(g_killjpvip) 
        
        if(get_pdata_int(victim, 75) == HIT_HEAD)
        {
            g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
        }
    }
}
__________________
Jhob94 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-22-2013 , 20:45   Re: Any idea why this code doesn't work?
Reply With Quote #5

Quote:
Originally Posted by DeLiriuM View Post
Normal users should recieve XX amount of jbpacks + X amount (if killed with HS), VIP users (ADMIN_LEVEL_H) should recieve YY amount of jbpacks + X amount (if killed with HS), but they don't.
Would you give me an example?
Honestly, I don't care what you are trying to do. I'm trying to help you help yourself so that you can either fix this problem (and many others) yourself or get a better idea of what you are actually needing help with.

When something "doesn't work," you should always first check what code is actually being executed. If the whole function is not getting called at all then it doesn't do any good to change your code.

So, you should find out what code is actually being executed. I typically do this by adding in server_print() statements describing what part just got executed (you can also use log_amx).

Code:
function()
{
    server_print("function just got executed")
    if( g_bBoolean )
    {
        server_print("g_bBoolean is true")
    }
    else
    {
        server_print("g_bBoolean is false")
    }
    server_print("function finished executing")
    // etc.
}
The problem may be simpler to solve than this but a process like this will help you figure out where to look. Most likely, you will be able to solve your own problems this way (by knowing what is actually happening step-by-step).

E.g. If you never see anything print then you know that function() is not even being executed and you now know to look into why it's not being executed instead of looking inside the function which at that point would be irrelevant. If don't see what you expect to see from certain parts of the function then you know where to look into.

So, after this process, you should not ever say "it doesn't work" because you should have it narrowed down to what does not work.
__________________
fysiks is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 01-23-2013 , 15:15   Re: Any idea why this code doesn't work?
Reply With Quote #6

i think Ham_Killed forward have only 3 params and you made it with 4 params :S
TheDS1337 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-23-2013 , 15:17   Re: Any idea why this code doesn't work?
Reply With Quote #7

He didnt said what happens with him version so we cant help him 100%

But i think i know what him problem. He said he want for vips Y+Z and for who isnt vip X+Z
Y= JBPACKS per kill of vips
Z= JBPACKS per HS Kill
X= JBPACKS per kill of normal user

And i think what he says that is wrong is because he thinks this: g_jbpacks[attacker] += get_pcvar_num(g_killhsjp) is JBPACKS NORMAL/VIP + HS but in fact is just HS JBPACKS so what he should make is:

Code:
public fw_player_killed(victim, attacker, shouldgib, id)
{
    if(get_user_team(attacker) == 1 && !(get_user_flags(id) & ADMIN_LEVEL_H))
    {
        g_jbpacks[attacker] += get_pcvar_num(g_killjp) 
        
        if(get_pdata_int(victim, 75) == HIT_HEAD)
        {
            g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
        }
    }
    
    else if (get_user_team(attacker) == 1 && (get_user_flags(id) & ADMIN_LEVEL_H))
    {
        g_jbpacks[attacker] += get_pcvar_num(g_killjpvip) 
        
        if(get_pdata_int(victim, 75) == HIT_HEAD)
        {
            g_jbpacks[attacker] += get_pcvar_num(g_killhsjpvip)
        }
    }
}
So if player isnt VIP will receive:
- Per kill g_killjp
- Per HS g_killhsjp

And if player is VIP will receive:
- Per kill g_killjpvip
- Per HS g_killhsjpvip

So if you want normal jp amount 10, you set g_killjp to 10, and if want hs 15 you set g_killhsjp to 15 and normal user will receive 15 jp per hs. Same thing to vip cvars
Note: dont forget add the cvar g_killhsjpvip because that is wasnt on your code.

And on your code, you had it changed, you had user get vip amount and vip get user amount, so use the version of this post ;)
__________________

Last edited by Jhob94; 01-23-2013 at 15:41. Reason: adding code
Jhob94 is offline
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 01-25-2013 , 05:49   Re: Any idea why this code doesn't work?
Reply With Quote #8

X = Amount of jbpacks for normal users
Y = Amount of jpbacks for VIP users
Z = HS kill amount.
In all cases "Z" is a constant.

@Jhob94 - why do you add "ADMIN_LEVEL_H" in both situations? And no. I didn't have it changed. In both situations players recieved "X" amount of jbpacks.
__________________

Last edited by DeLiriuM; 01-25-2013 at 06:40.
DeLiriuM is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 01-26-2013 , 06:58   Re: Any idea why this code doesn't work?
Reply With Quote #9

Listen i didnt add both is both situations, if you see, the first one have "!" before read the admin level, and that means if user isnt admin_level_h. And yes you had it changed because for vip you had normal jb amounts and for users you had vip amounts. Just read my post again and use the code, you will see that will work perfectly
__________________
Jhob94 is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 01-30-2013 , 10:34   Re: Any idea why this code doesn't work?
Reply With Quote #10

Code:
public fw_player_killed( iVictim, iAttacker ) {     if( get_user_team( iAttacker ) == 1 )     {                   new iKillNormal = ( ( get_user_flags( iAttacker ) & ADMIN_LEVEL_H ) ? get_pcvar_num( g_killjpvip ) : get_pcvar_num( g_killjp ) )                 g_jbpacks[ iAttacker ] += ( get_pdata_int( iVictim, 75 ) == HIT_HEAD ) ?  ( iKillNormal + get_pcvar_num( g_killhsjp ) ) : iKillNormal     } }

Last edited by Backstabnoob; 01-30-2013 at 11:21.
Backstabnoob 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 20:39.


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