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

[L4D2] Gifts Drop & Spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Aceleracion
Member
Join Date: Jul 2017
Location: Ecuador
Plugin ID:
5908
Plugin Version:
1.3.6.1
Plugin Category:
Fun Stuff
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Drop gifts when a special infected died and win points & special weapon
    Old 11-09-2017 , 01:50   [L4D2] Gifts Drop & Spawn
    Reply With Quote #1

    Info
    This plugin allows you to spawn gifts so that players can collect them and win points (if is enabled database) in addition to a special weapon in the event that a special gift is collected.

    Note:
    This plugin was first designed for coop servers where they manage a player stats system and win points for each gift collected. The top 10 servers currently have this system in conjunction with the gifts. But do not worry, at the request of some members, now the plugin does not need a database to save the points or a player stats system, but if you want to put it on an online server, it would be advisable.
    Now the plugin has its own named configuration present in databases.cfg.
    • Those special infected when dying sometimes spawn gifts
    • Two types of gifts: Standard and Special
    • The life of the gift normally lasts 60 seconds, after that it will disappear
    • The gifts rotate on their own axis
    • Different gift models are spawned with colors and aura (the models can be found in the file "data/l4d2_gifts.cfg")
    • The type, model and scala of the gift are configured in the file "data/l4d2_gifts.cfg" (Not all models of l4d2 accept scale).
    • There is probability of spawning of gifts of each type and in general, configurable by cvars.
    • The points and life of the gift are configurable by cvars
    • Console commands to see how many points you have won and how many gifts you have collected per map and round.
    • The plugin works with the database engine "MySQL", but it can work without the aforementioned.
    • The database can be the same one you have for the player stats or a new one. In the second case, change the value of the "database" key to the database that you want and it should be in the databases.cfg file.
      I have personally worked with the l4dstats database of the plugin https://forums.alliedmods.net/showthread.php?t = 115965 using the table "players".
      If you do not have that table in your database, the plugin will automatically create it.
    • Reload the file (data/l4d2_gifts.cfg) by means of a command
    • The gifts are spawned until the survivors have collected a maximum amount of gifts per round and / or map. This functionality is disabled by default.

    Images

    Name:  20170414012922_1.jpg
Views: 11734
Size:  81.8 KB
    Name:  20170414012808_1.jpg
Views: 11439
Size:  84.7 KB

    Special weapons of special gift
    Code:
    // Sintaxis: {"classname", "name weapon"}
    {"weapon_rifle_ak47", "rifle ak47"},
    {"weapon_rifle_m60", "rifle m60"},
    {"machete", "machete"},
    {"knife", "knife"},
    {"katana", "katana"},
    {"baseball_bat","baseball bat"},
    {"weapon_grenade_launcher", "grenade launcher"},
    {"weapon_sniper_awp", "sniper awp"},
    {"weapon_first_aid_kit", "first aid kit"}
    Commands
    Console Commands:
    • sm_giftpoints/sm_giftp: View points for gifts collected
    • sm_giftcollect/sm_giftc: View number of gifts collected
    Admin Commands:
    • sm_gift: Spawn a gift in your position. Usage: sm_gift | sm_gift standard | sm_gift special [weapon_name]
    • sm_reloadgifts: Reload the config file of gifts (data/l4d2_gifts.cfg)

    Cvars:
    Saved to l4d2_gifts.cfg in your servers \cfg\sourcemod\ folder.
    Code:
    // Chance (%) of infected drop gift.
    // -
    // Default: "30"
    // Minimum: "1.000000"
    // Maximum: "100.000000"
    l4d2_gifts_chance "10"
    
    // Enable gifts 0: Disable, 1: Enable
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d2_gifts_enabled "1"
    
    // How long the gift stay on ground (seconds)
    // -
    // Default: "60"
    // Minimum: "0.000000"
    l4d2_gifts_giflife "60"
    
    // Points for take a gift standard (animals and other objects). Disabled if there is not database
    // -
    // Default: "10"
    // Minimum: "1.000000"
    l4d2_gifts_pointsE "10"
    
    // Points for take a gift special. Disabled if there is not database
    // -
    // Default: "20"
    // Minimum: "1.000000"
    l4d2_gifts_pointsS "20"
    
    // Probability for gifts standard (animals and other objects) with respect to chance of infected drop gift.
    // -
    // Default: "80"
    // Minimum: "1.000000"
    // Maximum: "100.000000"
    l4d2_gifts_probabilityE "92"
    
    // Probability for gift special with respect to chance of infected drop gift.
    // -
    // Default: "20"
    // Minimum: "1.000000"
    l4d2_gifts_probabilityS "8"
    
    // Maximum of gifts that all survivors can pick up per map [0 = Disabled]
    // -
    // Default: "0"
    // Minimum: "1.000000"
    l4d2_gifts_maxcollectMap "0"
    
    // Maximum of gifts that all survivors can pick up per round [0 = Disabled]
    // -
    // Default: "0"
    // Minimum: "1.000000"
    l4d2_gifts_maxcollectRound "0"
    Thanks:

    alejandrosc - Quick update for the last syntax.

    Requirements:
    Installation:
    1. Download the .zip and extract the files to their respective folders in your servers \addons\sourcemod\ folder. (l4d2_gifts sm1.7.zip for sourcemod 1.7 and l4d2_gifts sm1.8.zip for sourcemod 1.8 {new syntax}).
    2. Place the following code with your own sql info into your databases.cfg. Title it "l4d2gifts" in the file.

    MySQL:
    Code:
    "l4d2gifts"
    {
    	"driver"            "mysql"
    	"host"              "ip/hostname"
    	"database"          "database"
    	"user"              "username"
    	"pass"              "password"
    }
    Change Log:

    Code:
    1.3.6.1 (19-November-2017)
    	- Fixed the problem that you can not collect special gifts in version 1.3.6
    	- Fixed the problem that the first aid kit was not spawned.
    	- Fixed the problem that some weapons specified by the "sm_gift" command were not spawned.
    
    1.3.6 (17-November-2017)
    	- The value of the DATABASE_CONFIG definition was changed to "l4d2gifts". 
    	  Now the plugin has its own named configuration that you must add to the databases.cfg file.
    	- Added the automatic creation of the table "players" of the database you have configured 
    	  (CREATE TABLE IF NOT EXISTS `players`).
    	- The following fields were added to the table "players":
    		+ collected_gift: Save the total of collected gifts per player.
    		+ collected_gift_standard: Save the total of standard gifts collected per player.
    		+ collected_gift_special: Save the total of special gifts collected per player.
    	- Added the dimensional array "TotalGifts" to save the number of collected gifts of each type throughout the 
    	  game by the player (since he first connected to the server).
    	- Added array "AllGifts" to save the total of gifts collected throughout the game by the player (since he first 
    	  connected to the server).
    	- Added the use of OnClientPostAdminCheck forward to get from the database how many gifts of each type and in 
    	  general has the player.
    	- The "sm_giftcollect" alias "sm_giftc" command was updated to display the gifts collected throughout the game 
    	  (since it was first connected to the server).
    	- Added the dimensional array "g_sGifSWeapon" to store the weapon of special gifts generated by the administrator.
    	- The "sm_gift" command was updated so that administrators with the ADMFLAG_CHEATS flag can spawn the gift they want.
    	  It can be a random gift, a standard gift and a special gift with the weapon they wish (It must be valid weapons).
    	- The library "l4d_weapon_stocks" was updated so that it recognizes the classname of the weapons and melee weapons 
    	  compatible with left 4 dead 2.
    	- The "DropGift" function was modified to return the entity index of the gift that was spawned.
    	- The "sm_reloadgifts" command flag was modified to ADMFLAG_CONFIG.
    	- Added cvar "l4d2_gifts_maxcollectMap" for the maximum number of gifts that all survivors can collect per map. 
    	  The value of 0 disables this functionality.
    	- Added cvar "l4d2_gifts_maxcollectRound" for the maximum number of gifts that all survivors can collect per round. 
    	  The value of 0 disables this functionality.
    	- Added definition MAX_SPECIALWEAPONS to set the maximum of special weapons.
    	- Added the "first aid kit" to the special weapons that the player wins for a special gift.
    	- The "NotifyGift" function was modified by adding the "gift" parameter that corresponds to the entity index of a gift.
    
    1.3.5 (15-November-2017)
    	- Added definition USE_DATABASE to you want to use the database. Default is true.
    
    1.3.4 (13-November-2017)
    	- The dependency on the database was removed. The plugin can work without the need for database.
    	- The translations were updated to show the ads for the gifts without points when there is not database.
    	- The points earned by gifts and the command "sm_giftpoints" is activated if the plugin is working with a database.
    
    1.3.3 (09-November-2017)
    	- Added function "PrecacheModelGifts" and "PrecacheSoundGifts"
    	- Fixed the problem of gifts that did not spawn when reloading the configuration file with the command "sm_reloadgifts"
    	- Changed PrintToChat to Client_PrintToChat and PrintToChatAll to Client_PrintToChatAll (except when printing points)
    	- Fixed the color lightgreen of translations.
    
    1.3.2 (05-November-2017)
    	- Added array's Client's Gifts Points (CurrentPointsForMap & CurrentPointsForRound)
    	- Added dimensional array's Client's Gifts Number (CurrentGiftsForMap && CurrentGiftsForRound)
    	- Added array's Client's Gifts Total (CurrentGiftsTotalForMap && CurrentGiftsTotalForRound)
    	- Added command "sm_giftpoints" alias "sm_giftp" for players to view points for gifts collected in the current map and
    	  current round.
    	- Added command "sm_giftcollect" alias "sm_giftc" for players to view the number for gifts collected in the current map and
    	  current round specific for type the gift.
    
    1.3.1 (04-October-2017)
    	- Added translations, required for the spawn gifts
    	- Fixed the name of weapons for print to chat when spawn gifts
    
    1.3 (03-October-2017)
    	- Added a config file for the gifts "l4d2_gifts" replacing the definitions. 
    	  Here you specify the path and model type, and the type of gift whether standard or special.
    	- Changed cvar l4d2_gifts_pointsA for l4d2_gifts_pointsE
    	- Fixed the gifts with models not physic that did not show up
    	- Added OnPlayerRunCmd forward when a survivor presses +USE on gifts static.
    	- Added command "sm_reloadgifts" for reloads the settings from the config file "l4d2_gifts"
    	- Added cvar "l4d2_gifts_probabilityE" to the probability for gifts standard (animals and other objects) 
    	  with respect to chance of infected drop gift. (Chance of infected drop gift represents 100% of these).
    	- Added cvar "l4d2_gifts_probabilityS" to the probability for gift special with respect to chance of infected drop gift.
    	- Added definition MAX_GIFTS to set the maximum of gifts.
    
    1.2.1 (19-July-2017)
    	- Added weapons to the gifts square for give to the player when he catches the gifts
    
    1.2 (01-June-2017)
    	- Added cvar "l4d2_gifts_pointsA" to the points for take a gift (animals and other objects).
    	- Added cvar "l4d2_gifts_pointsS" to the points for take a gift square.
    	- Added sound for gifts animals and gifts square when these are caught
    	- Added the config file that should be executed after plugin load.
    	- Added the databases config to the points of the gifts
    	- Added a hook for when the console variables values is changed.
    
    1.1 (15-March-2017)
    	- Added command "sm_gift" for admins to spawn gifts. Used for the developer.
    	- Added cvar "l4d2_gifts_enabled" to toggle to turn on or off the gifts.
    	- Added cvar "l4d2_gifts_giflife" to the time that the gift stay on ground in seconds.
    	- Added cvar "l4d2_gifts_chance" to the chance (%) of infected drop gift.
    	- Added TAG CHAT for PrintChatToAll to the gifts spawned
    
    1.0 (20-January-2017)
    	- Initial release.
    Current Translations: English (en), Spanish (es).
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_gifts.sp - 1199 views - 38.5 KB)
    File Type: smx l4d2_gifts.smx (41.0 KB, 1092 views)
    File Type: zip l4d2_gifts sm1.7.zip (128.8 KB, 622 views)
    File Type: zip l4d2_gifts sm1.8.zip (129.0 KB, 1746 views)
    __________________
    by Aceleración
    To succeed in your goals, use your true potential

    Last edited by Aceleracion; 11-19-2017 at 17:42. Reason: Fixed the problem that you can not collect special gifts in version 1.3.6. New v: 1.3.6.1
    Aceleracion is offline
    Striker black
    Member
    Join Date: Apr 2013
    Old 11-09-2017 , 14:53   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #2

    Omg, Just what I had in mind, but a question, is it good for versus or is it only cooperative?
    Striker black is offline
    Aceleracion
    Member
    Join Date: Jul 2017
    Location: Ecuador
    Old 11-09-2017 , 18:32   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #3

    Quote:
    Originally Posted by Striker black View Post
    Omg, Just what I had in mind, but a question, is it good for versus or is it only cooperative?
    For any game mode: coop or versus
    __________________
    by Aceleración
    To succeed in your goals, use your true potential
    Aceleracion is offline
    phoenix0001
    Senior Member
    Join Date: Apr 2010
    Location: China
    Old 11-12-2017 , 07:31   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #4

    ??
    Attached Thumbnails
    Click image for larger version

Name:	QQ??20171112201714.png
Views:	1237
Size:	14.8 KB
ID:	166524  
    __________________
    I like this BBS sharing of spirit

    I come from China, my English is poor
    phoenix0001 is offline
    Striker black
    Member
    Join Date: Apr 2013
    Old 11-12-2017 , 20:28   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #5

    The plugin shows the gifts but still does not show advertisement and no sounds are heard

    #define PLUGIN_VERSION "1.3.2"
    #define TAG_GIFT "{G}[{L}GIFTS{G}]\x01"
    #define SND_REWARD1 "level/loud/climber.wav"
    #define SND_REWARD2 "level/gnomeftw.wav"

    The version 1.3.3 is already released?

    The plugin can work without the need for database?

    PHP Code:
    #define DATABASE_CONFIG     "l4dstats"




    public OnConfigsExecuted()
    {
        
    GetCvars();
        
        if (!
    ConnectDB())
        {
            
    LogError("Connecting to database failed. Read error log for further details.");
        }
    }

    bool:ConnectDB()
    {
        if (
    db != INVALID_HANDLE)
            return 
    true;

        if (
    SQL_CheckConfig(DATABASE_CONFIG))
        {
            new 
    String:Error[256];
            
    db SQL_Connect(DATABASE_CONFIGtrueErrorsizeof(Error));

            if (
    db == INVALID_HANDLE)
            {
                
    LogError("Failed to connect to database: %s"Error);
                return 
    false;
            }

            if (!
    CheckDatabaseValidity())
            {
                
    LogError("Database is missing required table or tables.");
                return 
    false;
            }
        }
        else
        {
            
    LogError("Databases.cfg missing '%s' entry!"DATABASE_CONFIG);
            return 
    false;
        }

        return 
    true;
    }

    bool:CheckDatabaseValidity()
    {
        if (!
    SQL_FastQuery(db"SELECT * FROM players WHERE 1 = 2"))
        {
            return 
    false;
        }

        return 
    true;

    _____________________________________________ ______________________


    Last edited by Striker black; 11-12-2017 at 21:50.
    Striker black is offline
    Aceleracion
    Member
    Join Date: Jul 2017
    Location: Ecuador
    Old 11-13-2017 , 00:17   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #6

    Quote:
    Originally Posted by phoenix0001 View Post
    ??
    I forgot that inclusion file, here it is. Also already update the compressed zip file, I had not realized, thanks for notifying.
    Attached Files
    File Type: inc l4d_weapon_stocks.inc (14.2 KB, 739 views)
    __________________
    by Aceleración
    To succeed in your goals, use your true potential
    Aceleracion is offline
    Aceleracion
    Member
    Join Date: Jul 2017
    Location: Ecuador
    Old 11-13-2017 , 02:16   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #7

    Quote:
    Originally Posted by Striker black View Post
    The plugin shows the gifts but still does not show advertisement and no sounds are heard

    #define PLUGIN_VERSION "1.3.2"
    #define TAG_GIFT "{G}[{L}GIFTS{G}]\x01"
    #define SND_REWARD1 "level/loud/climber.wav"
    #define SND_REWARD2 "level/gnomeftw.wav"

    The version 1.3.3 is already released?

    The plugin can work without the need for database?

    PHP Code:
    #define DATABASE_CONFIG     "l4dstats"

    public OnConfigsExecuted()
    {
        
    GetCvars();
        
        if (!
    ConnectDB())
        {
            
    LogError("Connecting to database failed. Read error log for further details.");
        }
    }

    bool:ConnectDB()
    {
        if (
    db != INVALID_HANDLE)
            return 
    true;

        if (
    SQL_CheckConfig(DATABASE_CONFIG))
        {
            new 
    String:Error[256];
            
    db SQL_Connect(DATABASE_CONFIGtrueErrorsizeof(Error));

            if (
    db == INVALID_HANDLE)
            {
                
    LogError("Failed to connect to database: %s"Error);
                return 
    false;
            }

            if (!
    CheckDatabaseValidity())
            {
                
    LogError("Database is missing required table or tables.");
                return 
    false;
            }
        }
        else
        {
            
    LogError("Databases.cfg missing '%s' entry!"DATABASE_CONFIG);
            return 
    false;
        }

        return 
    true;
    }

    bool:CheckDatabaseValidity()
    {
        if (!
    SQL_FastQuery(db"SELECT * FROM players WHERE 1 = 2"))
        {
            return 
    false;
        }

        return 
    true;

    _____________________________________________ ______________________

    This plugin was first intended for coop servers where they manage a player statistics system and earn points for each collected gift. Now the dependence on the database has been removed, but it would be advisable to work with a database and it may be the same one that you use for your player stats if you have one.

    I attach the new version of the plugin (v1.3.4)
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_gifts.sp - 859 views - 29.7 KB)
    __________________
    by Aceleración
    To succeed in your goals, use your true potential

    Last edited by Aceleracion; 11-13-2017 at 02:18.
    Aceleracion is offline
    midnight9
    Senior Member
    Join Date: Nov 2012
    Old 11-13-2017 , 15:27   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #8

    Hi, interesting plugin. Im wondering if its possible to add an option where player collects gift for killing SI gets random weapon or item from configurable weapons/items list? Also any chance that an admin can control whats in gift when using sm_gift? Like it would be cool if an admin could drop gifts with desired items/weapons for example sm_gift katana.
    Regards
    midnight9 is offline
    Striker black
    Member
    Join Date: Apr 2013
    Old 11-13-2017 , 17:33   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #9

    Now if it works smoothly, is a great plugin, thanks for


    _____________________________________________ ___________________

    Striker black is offline
    aleeexxx
    Member
    Join Date: May 2014
    Location: Valhalla
    Old 11-13-2017 , 22:27   Re: [L4D2] Gifts Drop & Spawn
    Reply With Quote #10

    Hey bro thanks for shared this great plugin. I will public a quick update for the last syntax
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_gifts.sp - 842 views - 29.7 KB)
    File Type: smx l4d2_gifts.smx (34.3 KB, 771 views)
    __________________
    aleeexxx is offline
    Send a message via MSN to aleeexxx
    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 10:34.


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