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

[L4D(2)] Approval-related Snippets


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Downtown1
Veteran Member
Join Date: Mar 2004
Old 12-30-2009 , 22:43   [L4D(2)] Approval-related Snippets
Reply With Quote #1

There's a few L4D(2)-specific approval requirements now for approving new plugins over at http://forums.alliedmods.net/showthread.php?t=57142

To make life a little bit easier for everyone, I will be posting some code snippets that you can copy and paste into your plugin. Of course feel free to use your own code instead, this is just meant to make things easier.


Check game folder name for L4D1/L4D2, fail to load if it's not
PHP Code:
public OnPluginStart()
{
    
// Require Left 4 Dead (2)
    
decl String:game_name[64];
    
GetGameFolderName(game_namesizeof(game_name));
    if (!
StrEqual(game_name"left4dead"false
      && !
StrEqual(game_name"left4dead2"false))
    {
        
SetFailState("Plugin supports Left 4 Dead or Left 4 Dead 2 only.");
    }



Save/restore CVARs to their old values

PHP Code:
new iInitialGhostTimeMin;

public 
OnPluginStart()
{
    
iInitialGhostTimeMin GetConVarInt(FindConVar("z_ghost_delay_min"));
}

public 
OnPluginEnd()
{
    
SetConVarInt(FindConVar("z_ghost_delay_min"), iInitialGhostTimeMin);

Downtown1 is offline
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 13:16.


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