Raised This Month: $51 Target: $400
 12% 

Hero: Streak


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-15-2011 , 03:50   Hero: Streak
Reply With Quote #1

Streak

Description
Get an M4A1 which does more damage and when killing 3, 5, 7 or more with headshots in a row, you get bonus XP.

shconfig.cfg CVARS
Code:
//Streak
streak_level 5     //Level needed for this hero
streak_3 50     //XP to give after 3 headshots in a row
streak_5 100     //XP to give after 5 headshots in a row
streak_7 175     //XP to give after 7 headshots in a row
streak_additional 75     //After 7 headshots in a row give this amount of XP
streak_M4Mult 2     //Multiplier for the M4A1
Code:
/* Changelog:
* v1.3 - Jelle - 11/01/12
       - Fixed a huge bug where it could give 10k+ XP
* v1.2 - Jelle - 07/15/12
       - Even more bug fixes
* v1.1 - Jelle - 09/15/11
*      - Bug fixes
* v1.0 - Jelle - 09/15/11
*      - Initial release
*/


**SuperHero Mod 1.2.0 & up ONLY**


Credits:
My mind
Fr33m@n
G-Dog
Attached Files
File Type: sma Get Plugin or Get Source (sh_streak.sma - 190 views - 3.0 KB)
__________________
No idea what to write here...

Last edited by Jelle; 11-01-2012 at 18:41.
Jelle is offline
Send a message via MSN to Jelle
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 09-15-2011 , 07:14   Re: Hero: Streak
Reply With Quote #2

PHP Code:
if ( !gHasHero[victim] || !gHasHero[attacker] ) return 
non sense and big mistake.
with that the attacker can killstreak only if BOTH of them have the hero.

others smaller mistakes. But i will not list them, it's to the coder to test if his hero work correctly ingame.
Sorry if i'm hard but this is badly done.
Fr33m@n is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 09-15-2011 , 09:47   Re: Hero: Streak
Reply With Quote #3

@Fr33m@n: your mixing up the difference between && and ||

@Jelle: while he was wrong about why that's bad it is still bad because a player without the hero can still get the streak bonus as long as the victim has it the way you have it now. I would suggest making a separate check for each i.e.
PHP Code:
public sh_client_death(victimattackerheadshot)
{
    if ( 
victim == attacker ) return
    
    if ( 
get_user_weapon(attacker) != CSW_M4A1 ) return
    
    if( 
gHasHero[victim] )
    {
        
gStreak[victim] = 0
        
        hud_message_end
(victim)        //why do we show both a print message and a hud message saying the streak ended?
        
        
client_print(victimprint_chat"[SH] Steak has been reset")
    }
    
    if ( 
gHasHero[attacker] )
    {
    
        if ( 
headshot )
        {
            new 
streak = ++gStreak[attacker]    //indexed arrays take longer to lookup so its faster to store to a temp variable and use that
            
client_print(attackerprint_chat"[SH] HS Steak: %i"streak)    //since your passing a interger in your format you need to put %i not %s
            
            
if ( streak == )
            {
                
sh_set_user_xp(attackerget_pcvar_num(pcvar3XP), true)
                
client_print(attackerprint_chat"[SH] Added %i for your 3 HS streak"get_pcvar_num(pcvar3XP))
            }
            else if ( 
streak == )
            {
                
sh_set_user_xp(attackerget_pcvar_num(pcvar5XP), true)
                
client_print(attackerprint_chat"[SH] Added %i for your 5 HS streak"get_pcvar_num(pcvar5XP))
            }
            else if ( 
streak == )
            {
                
sh_set_user_xp(attackerget_pcvar_num(pcvar7XP), true)
                
client_print(attackerprint_chat"[SH] Added %i for your 7 HS streak"get_pcvar_num(pcvar7XP))
            }
            
            else if ( 
gStreak[attacker] > )
            {
                
sh_set_user_xp(attackergStreak[attacker] * get_pcvar_num(pcvarAdditional), true)
                
client_print(attackerprint_chat"[SH] Added %i for your %i HS streak"streak get_pcvar_num(pcvarAdditional), streak)
            }
        }
    }

__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 09-15-2011 , 10:36   Re: Hero: Streak
Reply With Quote #4

Just a question here, isn't it always "smarter" to use if ( CONDITIONS ) {} instead of if ( CONDITIONS ) return, ohwell, I mean, as it's easier to get things mixed up or actually to forget to add stuff, what I mean is if you use return for example gHasHero, it the codeblock after it does not gets executed if the user hasn't got the hero, if you use {} it only runs it if the user HAS GOT the hero. I mean, there's really no difference to it other than that you have to remember exactly what conditions in certain forwards you want to return, instead of just knowing the ones you want to check if true (those are often less than the ones that you don't want I think)? I don't really use it that way in LUA but as I'm coming back to Pawn just a question here :p
__________________
The Art of War is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-15-2011 , 10:42   Re: Hero: Streak
Reply With Quote #5

Quote:
Originally Posted by Fr33m@n View Post
PHP Code:
if ( !gHasHero[victim] || !gHasHero[attacker] ) return 
non sense and big mistake.
with that the attacker can killstreak only if BOTH of them have the hero.

others smaller mistakes. But i will not list them, it's to the coder to test if his hero work correctly ingame.
Sorry if i'm hard but this is badly done.
Quote:
Originally Posted by G-Dog View Post
@Fr33m@n: your mixing up the difference between && and ||

@Jelle: while he was wrong about why that's bad it is still bad because a player without the hero can still get the streak bonus as long as the victim has it the way you have it now. I would suggest making a separate check for each i.e.
PHP Code:
public sh_client_death(victimattackerheadshot)
{
    if ( 
victim == attacker ) return
    
    if ( 
get_user_weapon(attacker) != CSW_M4A1 ) return
    
    if( 
gHasHero[victim] )
    {
        
gStreak[victim] = 0
        
        hud_message_end
(victim)        //why do we show both a print message and a hud message saying the streak ended?
        
        
client_print(victimprint_chat"[SH] Steak has been reset")
    }
    
    if ( 
gHasHero[attacker] )
    {
    
        if ( 
headshot )
        {
            new 
streak = ++gStreak[attacker]    //indexed arrays take longer to lookup so its faster to store to a temp variable and use that
            
client_print(attackerprint_chat"[SH] HS Steak: %i"streak)    //since your passing a interger in your format you need to put %i not %s
            
            
if ( streak == )
            {
                
sh_set_user_xp(attackerget_pcvar_num(pcvar3XP), true)
                
client_print(attackerprint_chat"[SH] Added %i for your 3 HS streak"get_pcvar_num(pcvar3XP))
            }
            else if ( 
streak == )
            {
                
sh_set_user_xp(attackerget_pcvar_num(pcvar5XP), true)
                
client_print(attackerprint_chat"[SH] Added %i for your 5 HS streak"get_pcvar_num(pcvar5XP))
            }
            else if ( 
streak == )
            {
                
sh_set_user_xp(attackerget_pcvar_num(pcvar7XP), true)
                
client_print(attackerprint_chat"[SH] Added %i for your 7 HS streak"get_pcvar_num(pcvar7XP))
            }
            
            else if ( 
gStreak[attacker] > )
            {
                
sh_set_user_xp(attackergStreak[attacker] * get_pcvar_num(pcvarAdditional), true)
                
client_print(attackerprint_chat"[SH] Added %i for your %i HS streak"streak get_pcvar_num(pcvarAdditional), streak)
            }
        }
    }

Thanks to you both, I have edited it.

Quote:
Originally Posted by The Art of War View Post
Just a question here, isn't it always "smarter" to use if ( CONDITIONS ) {} instead of if ( CONDITIONS ) return, ohwell, I mean, as it's easier to get things mixed up or actually to forget to add stuff, what I mean is if you use return for example gHasHero, it the codeblock after it does not gets executed if the user hasn't got the hero, if you use {} it only runs it if the user HAS GOT the hero. I mean, there's really no difference to it other than that you have to remember exactly what conditions in certain forwards you want to return, instead of just knowing the ones you want to check if true (those are often less than the ones that you don't want I think)? I don't really use it that way in LUA but as I'm coming back to Pawn just a question here :p
If you want to execute something on both people who has and who doesn't have the hero, it is a bad idea to use return rather than a block of code.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 09-15-2011 , 21:49   Re: Hero: Streak
Reply With Quote #6

Quote:
Originally Posted by G-Dog View Post
@Fr33m@n: your mixing up the difference between && and ||
Haha we see that i didn't really code since 6 month
My bad, sorry, i read the code too quickly, and so, said bullshit, quick answer without using my brain correctly.
I was focus on !gHasHero[victim] and !gHasHero[attacker] in the same return condition witch in a killstreak, not a good option.
anyway the code wasn't good.

Jelle, if you want my point of view, it's better to have a killstreak sh compatible plugin outside an hero as a third part plugin. with xp streak management and so on.

Last edited by Fr33m@n; 09-15-2011 at 21:55.
Fr33m@n is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-16-2011 , 02:10   Re: Hero: Streak
Reply With Quote #7

Quote:
Originally Posted by Fr33m@n View Post
Jelle, if you want my point of view, it's better to have a killstreak sh compatible plugin outside an hero as a third part plugin. with xp streak management and so on.
I was actually thinking of that, but I decided to make it one gun only (M4A1 in this case) and give that a bit extra power. With a plugin it would be redundant to raise the damage of a weapon.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
PsIIh21
Junior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-19-2011 , 10:39   Re: Hero: Streak
Reply With Quote #8

Quote:
it's better to have a kill streak sh compatible plugin outside an hero as a third part plugin.
Maybe not bad idea, and create such plugin it wouldn't be, so hard, but i think with such hero more fun to play, then with third part plugin
__________________
My creations only for me and only for my server players
PsIIh21 is offline
Send a message via Skype™ to PsIIh21
ShiiTake
Member
Join Date: May 2010
Old 09-20-2011 , 17:33   Re: Hero: Streak
Reply With Quote #9

Nice HERO , more XP and DMG.

One question...

The hero is working perfectly?

I liked the idea. I'll test it and maybe implement the server.
__________________

Last edited by ShiiTake; 09-20-2011 at 17:35.
ShiiTake is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 09-20-2011 , 17:36   Re: Hero: Streak
Reply With Quote #10

Quote:
Originally Posted by Jelle View Post
I was actually thinking of that, but I decided to make it one gun only (M4A1 in this case) and give that a bit extra power. With a plugin it would be redundant to raise the damage of a weapon.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
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 14:30.


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