AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [L4D] Achievement Notifier (https://forums.alliedmods.net/showthread.php?t=81992)

Fexii 12-14-2008 22:10

[L4D] Achievement Notifier
 
6 Attachment(s)
Left 4 Dead Achievement Notifier
by Fexii

Description


Achievements can be frustrating to complete because many of them require you to finish the entire campaign before finding out whether or not you've succeeded. This plugin patches this by providing messages as soon as an infraction against achievement completion occurs.

Current Achievements Tracked
SAFETY FIRST
Play an entire campaign with no Survivors taking friendly fire damage.

STOMACH UPSET
All Survivors complete a campaign without being vomited on.

UNTOUCHABLES
No Survivors take damage after contacting the rescue vehicle.
Install

Place "achievementnotifier.smx" in your left4dead/addons/sourcemod/plugins folder.
Place "achievementnotifier.phrases.txt" in your left4dead/addons/sourcemod/translations folder.

Usage

The plugin is automatically enabled when the server starts a campaign mode map. Whenever an achievement is prevented, a message with details will appear to all players.

Saying "!achievements" during the game will show which achievements have been prevented and which are still attainable. This is disabled during versus mode.

sm_achievement_notify <0/1> - Toggles the plugin. Requires a map restart when changed.
sm_achievement_notify_connect_message <0/1> - Display a message when the user connects that tells them about the "!achievements" command.

Changelog

Version 1.0
- Initial Release with Safety First, Stomach Upset, Untouchables
- Fixed repeated hooks when the round starts
- Now registers the command sm_achievements
- Fixed leftover debug code that caused chat to appear whenever a player is hurt

Notes

Please let me know about bugs in this thread. The achievements system is somewhat buggy to begin with, but I'll do my best to model this plugin after the actual achievement requirements based on feedback.

I plan to add more achievements over time, starting with the more frustrating ones first.


Antithasys 12-14-2008 22:16

Re: [L4D] Achievement Notifier
 
This is very helpful. Good job.

One thing to note after a quick look. It looks like you hook events in round start and unhook when map ends... If round start occurs more than once in a map you will stack event hooks. Not a good thing.

Fexii 12-14-2008 22:59

Re: [L4D] Achievement Notifier
 
Quote:

Originally Posted by Antithasys (Post 727553)
This is very helpful. Good job.

One thing to note after a quick look. It looks like you hook events in round start and unhook when map ends... If round start occurs more than once in a map you will stack event hooks. Not a good thing.

You're right, that's a problem I'll fix soon. Thanks!

Edit: I added a one-liner since I already had the boolean sitting around whenever I hook. Hopefully that fixes it.

Antithasys 12-15-2008 00:44

Re: [L4D] Achievement Notifier
 
Further suggestions. I always wonder why people hook the say command when all they want is the chat trigger. Sourcemod does all this for you. Creating your own console command is the way to go.

Replace:
PHP Code:

RegConsoleCmd("say"Command_SayChat);
 
public 
Action:Command_SayChat(clientargs)

 
decl String:text[192];
 if (!
GetConVarBool(cvPluginEnabled) ||
     
IsChatTrigger() ||
  
GetCmdArgString(textsizeof(text)) < 1)
  return 
Plugin_Continue;
 
 
ReplaceString(textsizeof(text), "\"""");
 
ReplaceString(textsizeof(text), " """);
 
 if (
StrEqual(text"!achievements"))
 {
  
DisplayAchievements(client);
  return 
Plugin_Handled;
 }
 
 return 
Plugin_Continue;


With:

PHP Code:

RegConsoleCmd("sm_achievements"Command_DisplayAchievements"Display Achievements");
 
public 
Action:Command_DisplayAchievements(clientargs)

 if (
GetConVarBool(cvPluginEnabled))
     
DisplayAchievements(client);
 return 
Plugin_Handled;



Fexii 12-15-2008 01:50

Re: [L4D] Achievement Notifier
 
Quote:

Originally Posted by Antithasys (Post 727599)
Further suggestions. I always wonder why people hook the say command when all they want is the chat trigger. Sourcemod does all this for you. Creating your own console command is the way to go.

That's great! I literally found out about SourceMod yesterday, so thanks for pointing out newbie mistakes. Riding off examples only gets me so far and I appreciate the specific coding feedback. :mrgreen:

Posting update with the new console command hook.

Antithasys 12-15-2008 15:37

Re: [L4D] Achievement Notifier
 
One last suggestion. As an author I always like to track how many servers use my plugins. You can do this with a public cvar.

PHP Code:

public OnPluginStart()
{
  
CreateConVar("achnotifier_version"PLUGIN_VERSION"Achievement Notifier"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);


That way the stats part of the forums and game-monitor.com will be able to track what servers, and how many of them, are using your plugin.

A public cvar is not required, thou i think it should be :), to be approved. Just a suggestion.

I will wait a bit to approve this in case you decide to do it, as if you do it later it has to go thru the approval process again.

Fexii 12-15-2008 18:10

Re: [L4D] Achievement Notifier
 
Quote:

Originally Posted by Antithasys (Post 727859)
One last suggestion. As an author I always like to track how many servers use my plugins. You can do this with a public cvar.

Thank you again :)

Now that "public cvar" field makes much more sense!

L4DHelp 12-17-2008 08:26

Re: [L4D] Achievement Notifier
 
This is a brilliant idea! I am deffinatly going to use this on my server, thank you Fexii :D

+1

Zigian 12-22-2008 13:25

Re: [L4D] Achievement Notifier
 
Any work going on to get this to monitor the "Nothing Special" achievement?

Fexii 12-22-2008 23:17

Re: [L4D] Achievement Notifier
 
Quote:

Originally Posted by Zigian (Post 731512)
Any work going on to get this to monitor the "Nothing Special" achievement?

I've been taking finals recently, so I haven't been able to add achievements yet. Nothing Special is definitely highest on my priority list. I tried implementing it about a week ago with problems.

I'm having trouble detecting players getting hurt by boomers by the boomer sliming the player then having other zombies attack her. It counts against the Nothing Special achievement, but I don't see a straightforward way to detect it using Game Events. If any other SourceMod coders have advice I'd appreciate it :mrgreen:


All times are GMT -4. The time now is 03:43.

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