Raised This Month: $66 Target: $400
 16% 

Survival Frags


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose        Approver:   Hawk552 (427)
3Di
Member
Join Date: Sep 2009
Location: #php_title
Old 09-20-2009 , 17:59   Survival Frags
Reply With Quote #1

Survival Frags
Version 0.3 | Counter-Strike 1.6


Description
When either team wins the round, all of the alive players are awarded an extra Survival Frag.

Cvars
amx_sf - Allows admins to enable or disable Survival Frags.
Default: 1

amx_sf_frags - Amount of extra frags for a round survival.
Default: 1

amx_sf_max - If a players frags are over this number, they will not receive Survival Frags.
Default: 15

amx_sf_message -
Allows admins to enable or disable the message announcing Survival Frags.
Default: 1

Changelog
Version 0.1
  • First release.
Version 0.2
  • Optimized code for faster performance.
  • Added an extra check for alive players.
  • Removed grammar checking.
  • Fixed print_chat bug.
Version 0.3
  • Removed extra check for alive players.
  • Directly inserted get_user_frags( id ); into if statement.
  • Removed 'fun module'.

Extra Notes:
Open to suggestions, coding optimizations and comments.
Attached Files
File Type: sma Get Plugin or Get Source (Survival_Frags.sma - 2138 views - 1.2 KB)

Last edited by 3Di; 09-21-2009 at 17:50. Reason: Version 0.3 uploaded
3Di is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-20-2009 , 18:21   Re: Survival Frags
Reply With Quote #2

Just so you know, you can add an integer to a float, this way you can use get_pcvar_num for the frag amount to add, and then use %d in the chat print.
This way you won't have that amxx bug that prints "1." when you use %.0f.
The bug has been pre-corrected in the svn but it's not released yet.
__________________
- tired and retired -
ConnorMcLeod is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 09-20-2009 , 18:25   Re: Survival Frags
Reply With Quote #3

PHP Code:
if ( applyFrag )

// 

if ( applyFrag == 
It's also called 0 frags.

or for simplicity you could just:

PHP Code:

if ( applyFrag == // Now we're getting into the grammar, hehe.
{
    
client_printidprint_chat"[SF] You have survived the round and gained %0f frag."applyFrag );
}
    
else
{
    
client_printidprint_chat"[SF] You have survived the round and gained %0f frags."applyFrag );
}

// ->

client_printidprint_chat"[SF] You have survived the round and gained %0f frag%s."applyFragapplyFrag == "s" "" ); 

Last edited by Jon; 09-20-2009 at 18:30.
Jon is offline
3Di
Member
Join Date: Sep 2009
Location: #php_title
Old 09-20-2009 , 18:25   Re: Survival Frags
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
Just so you know, you can add an integer to a float, this way you can use get_pcvar_num for the frag amount to add, and then use %d in the chat print.
This way you won't have that amxx bug that prints "1." when you use %.0f.
The bug has been pre-corrected in the svn but it's not released yet.
I noticed that it prints 1. every time the message appears, and I was wondering why. I'll convert the integer into a float as you said.
3Di is offline
3Di
Member
Join Date: Sep 2009
Location: #php_title
Old 09-20-2009 , 18:37   Re: Survival Frags
Reply With Quote #5

Uploaded Version 0.2!
3Di is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-20-2009 , 18:44   Re: Survival Frags
Reply With Quote #6

I was just saying that :

pFrags += 1.0

does the same thing as

pFrags += 1
__________________
- tired and retired -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-20-2009 , 18:47   Re: Survival Frags
Reply With Quote #7

- catchTeamWin() : You use is_user_alive() in the loop when you have already a list of alive player.
- applyFrags() : Not a big deal, pKills is used only one time, you could use directly the cvar without creating a var.
- If I remember frag is not updated right away on the scoreboard, you may want to update with ScoreInfo event.
- You should use get_user_frags/set_user_frags(), no need to work with pev_ and float and you could use directly the cvar.
__________________

Last edited by Arkshine; 09-20-2009 at 18:50.
Arkshine is offline
3Di
Member
Join Date: Sep 2009
Location: #php_title
Old 09-20-2009 , 18:57   Re: Survival Frags
Reply With Quote #8

Uploaded Version 0.3!

Arkshine, see the changelog for fixes and updates.

Also, I didn't update with ScoreInfo event because the engine updates the players score two seconds before the new round starts, so I don't see any need to add ScoreInfo.

I use 'pevs' because I tried with set_user_frags( ) and get_user_frags( ) and it would never correctly add the extra frag.
3Di is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 09-20-2009 , 19:04   Re: Survival Frags
Reply With Quote #9

A rly simple plugin but original idea... i like it, good job.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
3Di
Member
Join Date: Sep 2009
Location: #php_title
Old 09-20-2009 , 19:06   Re: Survival Frags
Reply With Quote #10

Thank you.
3Di 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 01:41.


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