Raised This Month: $ Target: $400
 0% 

New vs static for deathmsg


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mforce
Member
Join Date: Jan 2015
Old 10-14-2015 , 03:57   New vs static for deathmsg
Reply With Quote #1

New vs static for deathmsg
What's better for deathmsg?

PHP Code:
public plugin_init() {
    
register_event("DeathMsg""halal""a")
}

public 
halal() {
    static 
killervictimheadshotweapon[32];
    
killer read_data(1);
    
victim read_data(2);
    
headshot read_data(3);
    
read_data(4weaponcharsmax(weapon));
    
    if (!
is_user_connected(killer) || !is_user_connected(victim) || killer == victim || get_user_team(killer) == get_user_team(victim)) return;
    
    if(
killer != victim && headshot) {
        if (
containi(weapon"awp")) player_data[killer][AWP_KILLS] += HEADSHOT_POINT;
        else if (
containi(weapon"scout")) player_data[killer][SCOUT_KILLS] += HEADSHOT_POINT;
        else if (
containi(weapon"deagle")) player_data[killer][DEAGLE_KILLS] += HEADSHOT_POINT;
        else if (
containi(weapon"usp")) player_data[killer][USP_KILLS] += HEADSHOT_POINT;
        else if (
containi(weapon"glock")) player_data[killer][GLOCK_KILLS] += HEADSHOT_POINT;
        else if (
containi(weapon"knife")) player_data[killer][KNIFE_KILLS] += HEADSHOT_POINT;
        
set_hudmessage(02550, -0.90.1506.01.0);
        
show_hudmessage(killer"+%i Pont"HEADSHOT_POINT);
    }
    else if(
killer != victim) {
        if (
containi(weapon"awp")) player_data[killer][AWP_KILLS] += KILL_POINT;
        else if (
containi(weapon"scout")) player_data[killer][SCOUT_KILLS] += KILL_POINT;
        else if (
containi(weapon"deagle")) player_data[killer][DEAGLE_KILLS] += KILL_POINT;
        else if (
containi(weapon"usp")) player_data[killer][USP_KILLS] += KILL_POINT;
        else if (
containi(weapon"glock")) player_data[killer][GLOCK_KILLS] += KILL_POINT;
        else if (
containi(weapon"knife")) player_data[killer][KNIFE_KILLS] += KILL_POINT;
        
set_hudmessage(02550, -0.90.1506.01.0);
        
show_hudmessage(killer"+%i Pont"KILL_POINT);
    }

mforce is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 10-14-2015 , 04:57   Re: New vs static for deathmsg
Reply With Quote #2

Why are you checking if killer != victim, if you checked it in the statement above?
And consider using tries instead of various "if" checks.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
mforce
Member
Join Date: Jan 2015
Old 10-14-2015 , 05:50   Re: New vs static for deathmsg
Reply With Quote #3

PHP Code:
public halal() {
    static 
killervictimheadshotweapon[32];
    
killer read_data(1);
    
victim read_data(2);
    
headshot read_data(3);
    
read_data(4weaponcharsmax(weapon));
    
    if (!
is_user_connected(killer) || !is_user_connected(victim) || killer == victim || get_user_team(killer) == get_user_team(victim)) return;
    
    if(
headshot) {
        if (
equali(weapon"awp")) player_data[killer][AWP_KILLS] += HEADSHOT_POINT;
        else if (
equali(weapon"scout")) player_data[killer][SCOUT_KILLS] += HEADSHOT_POINT;
        else if (
equali(weapon"deagle")) player_data[killer][DEAGLE_KILLS] += HEADSHOT_POINT;
        else if (
equali(weapon"usp")) player_data[killer][USP_KILLS] += HEADSHOT_POINT;
        else if (
equali(weapon"glock18")) player_data[killer][GLOCK_KILLS] += HEADSHOT_POINT;
        else if (
equali(weapon"knife")) player_data[killer][KNIFE_KILLS] += HEADSHOT_POINT;
        
        
set_hudmessage(02550, -0.90.1506.01.0);
        
show_hudmessage(killer"+%i Pont"HEADSHOT_POINT);
    }
    else {
        if (
containi(weapon"awp")) player_data[killer][AWP_KILLS] += KILL_POINT;
        else if (
equali(weapon"scout")) player_data[killer][SCOUT_KILLS] += KILL_POINT;
        else if (
equali(weapon"deagle")) player_data[killer][DEAGLE_KILLS] += KILL_POINT;
        else if (
equali(weapon"usp")) player_data[killer][USP_KILLS] += KILL_POINT;
        else if (
equali(weapon"glock18")) player_data[killer][GLOCK_KILLS] += KILL_POINT;
        else if (
equali(weapon"knife")) player_data[killer][KNIFE_KILLS] += KILL_POINT;
        
        
set_hudmessage(02550, -0.90.1506.01.0);
        
show_hudmessage(killer"+%i Pont"KILL_POINT);
    }


Last edited by mforce; 10-14-2015 at 13:41. Reason: changed to equali
mforce is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-14-2015 , 09:07   Re: New vs static for deathmsg
Reply With Quote #4

Quote:
Originally Posted by mforce View Post
New vs static for deathmsg
What's better for deathmsg?
It's unlikely to matter because DeathMsg isn't called all that often.
__________________
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-14-2015 , 09:41   Re: New vs static for deathmsg
Reply With Quote #5

Anything which is not called per frame is not called often, so using "new" is fine, but "static" could be used on large array depending how often it's called.
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

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 22:17.


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