Raised This Month: $ Target: $400
 0% 

Reduce code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Eviatar Mor
Senior Member
Join Date: Jun 2014
Location: israel
Old 01-02-2015 , 08:08   Reduce code
Reply With Quote #1

hey,
i made this:
PHP Code:
public fw_PlayerKilled(victimattacker)  
{
    if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
    {
        
set_dhudmessage(random(256), random(256), random(256));
        
show_dhudmessage(0"%s Vs %s!"ctNametName)
        
client_cmd(0,"spk ^"vox/ %s vs %s^""ctNametName
    }
    
    if(
cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 0){
        
set_dhudmessage(random(256), random(256), random(256));
        
show_dhudmessage(0"%s The Last And Only!"tName)
    }
    if(
cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 1){
        
set_dhudmessage(random(256), random(256), random(256));
        
show_dhudmessage(0"%s The Last And Only!"tName)
        
client_cmd(read_data(2), "spk %s"g_szSoundVoice);
    }
    if(
cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 2){
        
set_dhudmessage(random(256), random(256), random(256));
        
show_dhudmessage(0"%s The Last And Only!"tName)
        
client_cmd(read_data(2), "spk %s"g_szSoundVoice1);
    }

and i want a way how to Reduce it.

Last edited by Eviatar Mor; 01-02-2015 at 08:09.
Eviatar Mor is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-02-2015 , 08:12   Re: Reduce code
Reply With Quote #2

Why? There is nothing wrong with that
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Eviatar Mor
Senior Member
Join Date: Jun 2014
Location: israel
Old 01-02-2015 , 08:17   Re: Reduce code
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
Why? There is nothing wrong with that
i can't make this smaller ?
PHP Code:
    if(cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 0){ 
        
set_dhudmessage(random(256), random(256), random(256)); 
        
show_dhudmessage(0"%s The Last And Only!"tName
    } 
    if(
cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 1){ 
        
set_dhudmessage(random(256), random(256), random(256)); 
        
show_dhudmessage(0"%s The Last And Only!"tName
        
client_cmd(read_data(2), "spk %s"g_szSoundVoice); 
    } 
    if(
cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 2){ 
        
set_dhudmessage(random(256), random(256), random(256)); 
        
show_dhudmessage(0"%s The Last And Only!"tName
        
client_cmd(read_data(2), "spk %s"g_szSoundVoice1); 
    } 
because i dont want to make always like that:
get_pcvar_num(toao_voice) == 0:
PHP Code:
if(cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 0){ 
        
set_dhudmessage(random(256), random(256), random(256)); 
        
show_dhudmessage(0"%s The Last And Only!"tName
    } 
get_pcvar_num(toao_voice) == 1:
PHP Code:
if(cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 1){ 
        
set_dhudmessage(random(256), random(256), random(256)); 
        
show_dhudmessage(0"%s The Last And Only!"tName
client_cmd(read_data(2), "spk %s"g_szSoundVoice);
    } 
get_pcvar_num(toao_voice) == 2:
PHP Code:
if(cs_get_terrorist_count(1) == && get_pcvar_num(toao_voice) == 2){ 
        
set_dhudmessage(random(256), random(256), random(256)); 
        
show_dhudmessage(0"%s The Last And Only!"tName
client_cmd(read_data(2), "spk %s"g_szSoundVoice1);
    } 
Eviatar Mor is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-02-2015 , 08:18   Re: Reduce code
Reply With Quote #4

With the code that you have shown us, no.

Again, why?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Eviatar Mor
Senior Member
Join Date: Jun 2014
Location: israel
Old 01-02-2015 , 08:20   Re: Reduce code
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
With the code that you have shown us, no.
okay thanks u.
Eviatar Mor is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 01-02-2015 , 08:35   Re: Reduce code
Reply With Quote #6

Something like that, if it's reduced enough?
PHP Code:
public fw_PlayerKilled(victimattacker)   

    
    if(
cs_get_counter_count(1) == 1)
    {
        
set_dhudmessage(random(256), random(256), random(256))
        
        if(
cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs %s!"ctNametName
            
client_cmd(0,"spk ^"vox/ %s vs %s^""ctNametName)
            return
        }
        
        
show_dhudmessage(0"%s The Last And Only!"tName
        if(
get_pcvar_num(toao_voice))
            
client_cmd(read_data(2), "spk %s"get_pcvar_num(toao_voice) == g_szSoundVoice g_szSoundVoice1); 
            
        return
        
    }

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Eviatar Mor
Senior Member
Join Date: Jun 2014
Location: israel
Old 01-02-2015 , 08:38   Re: Reduce code
Reply With Quote #7

Quote:
Originally Posted by Flick3rR View Post
Something like that, if it's reduced enough?
PHP Code:
public fw_PlayerKilled(victimattacker)   

    
    if(
cs_get_counter_count(1) == 1)
    {
        
set_dhudmessage(random(256), random(256), random(256))
        
        if(
cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs %s!"ctNametName
            
client_cmd(0,"spk ^"vox/ %s vs %s^""ctNametName)
            return
        }
        
        
show_dhudmessage(0"%s The Last And Only!"tName
        if(
get_pcvar_num(toao_voice))
            
client_cmd(read_data(2), "spk %s"get_pcvar_num(toao_voice) == g_szSoundVoice g_szSoundVoice1); 
            
        return
        
    }

yes it's good.
and flicker and this how can i reduce:
PHP Code:
if(get_pcvar_num(CVARenabled) == 1){
        
set_dhudmessage(random(256), random(256), random(256));
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs %s!"CTnameTname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs 2 Ct!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs 3 Ct!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs 4 Ct!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs 5 Ct!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 1)
        {
            
show_dhudmessage(0"%s Vs 6 Ct!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 2)
        {
            
show_dhudmessage(0"%s Vs 2 T!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 3)
        {
            
show_dhudmessage(0"%s Vs 3 T!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 4)
        {
            
show_dhudmessage(0"%s Vs 4 T!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 5)
        {
            
show_dhudmessage(0"%s Vs 5 T!"Tname)
        }
        if(
cs_get_counter_count(1) == && cs_get_terrorist_count(1) == 6)
        {
            
show_dhudmessage(0"%s Vs 6 T!"Tname)
        }
        
client_cmd(read_data(2), "spk %s"g_szSoundVoice);    
    } 
Eviatar Mor is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-02-2015 , 08:45   Re: Reduce code
Reply With Quote #8

Code:
if (get_pcvar_num(CVARenabled) == 1)
{ 
	set_dhudmessage(random(256), random(256), random(256)); 
	
	new iCT = cs_get_counter_count(1);
	new iT = cs_get_terrorist_count(1)
	
	if(iCT == 1 && iT == 1) 
	{ 
		show_dhudmessage(0, "%s Vs %s!", CTname, Tname) 
	} 
	else if(iT == 1) 
	{ 
		show_dhudmessage(0, "%s Vs %i Ct!", Tname, iCT) 
	} 
	else if(iCT == 1) 
	{ 
		show_dhudmessage(0, "%s Vs %i T!", Tname, iT) 
	} 
	
	client_cmd(read_data(2), "spk %s", g_szSoundVoice);     
}
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Eviatar Mor
Senior Member
Join Date: Jun 2014
Location: israel
Old 01-02-2015 , 08:48   Re: Reduce code
Reply With Quote #9

Quote:
Originally Posted by YamiKaitou View Post
Code:
if (get_pcvar_num(CVARenabled) == 1)
{ 
	set_dhudmessage(random(256), random(256), random(256)); 
	
	new iCT = cs_get_counter_count(1);
	new iT = cs_get_terrorist_count(1)
	
	if(iCT == 1 && iT == 1) 
	{ 
		show_dhudmessage(0, "%s Vs %s!", CTname, Tname) 
	} 
	else if(iT == 1) 
	{ 
		show_dhudmessage(0, "%s Vs %i Ct!", Tname, iCT) 
	} 
	else if(iCT == 1) 
	{ 
		show_dhudmessage(0, "%s Vs %i T!", Tname, iT) 
	} 
	
	client_cmd(read_data(2), "spk %s", g_szSoundVoice);     
}
oh, thank you
Eviatar Mor is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-02-2015 , 08:46   Re: Reduce code
Reply With Quote #10

I would go with this. Additionally, it will work for any number of players, not just up to 6!
PHP Code:
if(get_pcvar_num(CVARenabled) == 1)
{
    
set_dhudmessage(random(256), random(256), random(256));
    new 
iCTCount cs_get_counter_count(1);
    new 
iTCount cs_get_terrorist_count(1);
    
    if(
iCTCount == && iTCount == 1)
        
show_dhudmessage(0"%s Vs %s!"CTnameTname);
    else if(
iCTCount && iTCount == 1)
        
show_hudmessage(0"%s Vs %d Ct!"TnameiCTCount);
    else if(
iTCount && iCTCount == 1)
        
show_hudmessage(0"%s Vs %d T!"TnameiTCount); // Should this be CTname instead of Tname?
    
    
    
client_cmd(read_data(2), "spk %s"g_szSoundVoice);    

EDIT:
Yami ninja'd me... :/

Last edited by klippy; 01-02-2015 at 08:47.
klippy 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 15:17.


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