Raised This Month: $32 Target: $400
 8% 

[CS|CZ] FriendlyFire Custom Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Event Related       
Mauricio Frb
Member
Join Date: Jul 2013
Old 07-13-2013 , 13:40   [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #1

PHP Code:
/*
    FFCustomDamage - https://forums.alliedmods.net/showthread.php?t=220703
    
    Plugin by Mauricio Frb - https://forums.alliedmods.net/showthread.php?t=220703

    Description: This plugin block Friendlyfire when round ends and game commencing or on a player that is planting/defusing bomb.
    
    Credits:
    Original plugin and idea by .MMYTH.: https://forums.alliedmods.net/showthread.php?t=147291
    Bomb Script tutorial by VEN: https://forums.alliedmods.net/showthread.php?t=40164
    New Round / End Round Script tutorial by VEN: https://forums.alliedmods.net/showthread.php?t=42159
    Scripting Help topic - Thanks who help: https://forums.alliedmods.net/showthread.php?t=221383
    
    Games supported:
    - Counter-Strike;
    - Condition Zero.

    Modules required:
    - Hamsandwich;
    - Cstrike.

    Cvar:
    amx_ffcdamage <(Default:3)>
    // 0 - Disable plugin;
    // 1 - Only works on end round and when game commencing;
    // 2 - Only works on a player that is planting/defusing bomb;
    // 3 - 1 & 2 options together.
    
    Changelog:
    1.3 - Fix some code.
    1.2 - Reformulated code.
    1.1 - Bad code reported.
    1.0 - First release.
*/ 
Attached Files
File Type: sma Get Plugin or Get Source (FFCustomDamage.sma - 850 views - 4.8 KB)

Last edited by Mauricio Frb; 08-11-2013 at 06:52.
Mauricio Frb is offline
Balck
Senior Member
Join Date: Apr 2013
Location: Kosova-Mitrovica
Old 07-13-2013 , 15:59   Re: FriendlyFire Custom Damage
Reply With Quote #2

Gj man
Balck is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-13-2013 , 19:12   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #3

Code is closed to https://forums.alliedmods.net/showthread.php?t=147291
You did the same mistake, TakeDamage returns an integer, not a float.
You should have credited the original author.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-13-2013 at 19:13.
ConnorMcLeod is offline
Mauricio Frb
Member
Join Date: Jul 2013
Old 07-13-2013 , 19:13   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #4

Sure, I will repair this.
Mauricio Frb is offline
Mauricio Frb
Member
Join Date: Jul 2013
Old 07-14-2013 , 08:06   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #5

Uh, if anybody else wants to make a suggestion or relate a bug I will be grateful.
Mauricio Frb is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Siiiiiiiiuu
Old 07-14-2013 , 08:35   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #6

At the end of round, isnt it more easy to just block people shooting?
Example:
PHP Code:
public plugin_init()
{
    
register_clcmd("+attack""Block_Shoot")
}

public 
event_newround()
{
    
Round_Ended false
}

public 
logevent_endround()
{
    
Round_Ended true
}

public 
Block_Shoot(id)
{
    if(
Round_Ended == true
    { 
        
client_print (idprint_center"ROUND ENDED YOU CANT SHOOT!")
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE


And
PHP Code:
public logevent_endround()
{
    if(
get_pcvar_num(cvar_mode) >= 1)
    {
        
EnableHamForward(HamForward);
    }

So if cvar is 2 works for end round too?
__________________
Jhob94 is offline
Mauricio Frb
Member
Join Date: Jul 2013
Old 07-14-2013 , 08:42   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #7

No, because I only block friendlyfire.
Mauricio Frb is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Siiiiiiiiuu
Old 07-14-2013 , 11:01   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #8

Oh... I should read all and pay more attention
__________________
Jhob94 is offline
BLacking98
Veteran Member
Join Date: Oct 2012
Location: California
Old 07-16-2013 , 11:47   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #9

Quote:
Originally Posted by Jhob94 View Post
At the end of round, isnt it more easy to just block people shooting?
In my opinion, Friendly Fire blocking is wayy better then blocking everyone from shooting when the round ends, It just gets a little stupid.
__________________
BLacking98 is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 07-16-2013 , 20:26   Re: [CS|CZ] FriendlyFire Custom Damage
Reply With Quote #10

Quote:
Originally Posted by Jhob94 View Post
At the end of round, isnt it more easy to just block people shooting?
Example:
PHP Code:
public plugin_init()
{
    
register_clcmd("+attack""Block_Shoot")
}

//... 
Blocking (or even hooking) + commands is not possible because those are client side commands. It is not helpful to provide broken examples or even snippets to starters with the implication of them working. I would ask you to do basic research on this if you are not 100% sure you can provide a tried and proven code example.



General suggestions:
  • Looking at the code your cvar option descriptions are lacking. Mode 2 does not do what I would have expected from the information.
  • Your cvar descriptions imply that you use a flag system where 1+2 combined is 3. In your code you only use >= checks. Currently you actually can't enable mode 2 without also using mode 1, because everything >= 2 is also >= 1 (obviously). This is inconvenient because the two modes do entirely different things. Look at how bitflags work to implement the system correctly.
  • Your forward enable/disable system (and by extension the whole event_newround function) is plain wrong. DisableHamForward should not be dependent on the cvar state on newround, only on whether the forward is active or not. Therefore customdamage_on needs to be true when you enable the forward, not when a teamattack is detected. If no teamattack happens after round_end and the administrator disables the plugin (setting the cvar to 0) your checks will fail and the forward will never be disabled. This is only safeguarded by the additional cvar check at the top of the ham_playertakedamage function. This is bad design.
  • logevent_planted_defused will break if the cvar state is changed at the wrong moment during gameplay. This function should take action depending on id_planting_defusing and not on the current cvar state.
  • The if statement in ham_playertakedamage will not work as you expect at all. If planting_defusing is true it will block all attacks for the team of the planter or defuser, not only teamattacks. This is because you never verify that id_planting_defusing is equal to id (if that is what you intended, hard to tell from the description). Also if mode is 2 the forward still blocks teamattacks for both teams because you do || (cs_get_user_team(id) == cs_get_user_team(idattacker)) which still applies even if planting_defusing is true.
  • You use !friendlyfire for checking friendlyfire. But this is only a cvar pointer, you have to use !get_pcvar_num(friendlyfire) instead.
  • If everything is fixed logevent_endround needs to reset planting_defusing so the two modes don't interfere with eachother.

Even in this short plugin there are a multitude of issues that strongly suggest that you are not at a level of experience where you can submit and support a quality plugin.

This is by no means a bad thing, but it is, not without good reason, stated that the first plugin you ever made is likely to not meet the requirements of approval in this community.

So I encourage you to go to the scripting help and tutorial sections and keep working on this. Don't copy paste too much code. Start small and go from there. Have a more serious attitude towards testing your creation. Bugs are to be expected in every software, this is - sadly - a huge part of programming. Still, some of the issues I mentioned you should have noticed with even the simplest of test cases (like the fact that your mp_friendlyfire check is not working).
__________________
In Flames we trust!
Nextra 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 08:03.


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