AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Survival Frags (https://forums.alliedmods.net/showthread.php?t=104195)

3Di 09-20-2009 16:59

Survival Frags
 
1 Attachment(s)
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.

ConnorMcLeod 09-20-2009 17:21

Re: Survival Frags
 
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.

Jon 09-20-2009 17:25

Re: Survival Frags
 
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" "" ); 


3Di 09-20-2009 17:25

Re: Survival Frags
 
Quote:

Originally Posted by ConnorMcLeod (Post 938990)
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 09-20-2009 17:37

Re: Survival Frags
 
Uploaded Version 0.2!

ConnorMcLeod 09-20-2009 17:44

Re: Survival Frags
 
I was just saying that :

pFrags += 1.0

does the same thing as

pFrags += 1

Arkshine 09-20-2009 17:47

Re: Survival Frags
 
- 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.

3Di 09-20-2009 17:57

Re: Survival Frags
 
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.

Alucard^ 09-20-2009 18:04

Re: Survival Frags
 
A rly simple plugin but original idea... i like it, good job.

3Di 09-20-2009 18:06

Re: Survival Frags
 
Thank you.


All times are GMT -4. The time now is 12:44.

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