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

[TF2] Respawn System API!


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Plugin ID:
5168
Plugin Version:
Plugin Category:
Technical/Development
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Allows plugin developpers to change game's respawn time.
    Old 04-30-2016 , 16:47   [TF2] Respawn System API!
    Reply With Quote #1

    [TF2] Respawn System API

    • Version: 0.2

    Introduction:
    Oh no, an other respawn time plugin, wait it's not a new respawn time plugin. It's an API, that allows you to control the respawn time! And you don't have to print an ugly message like in other respawn plugins! You can override the client's hud directly! And I made a ton of natives to make your life easier.

    Description:
    • Allows plugin developpers to control the game's respawn time.
      You can:
    • Set the respawn time of a team.
    • Set the respawn time of a client.
    • Get the respawn time of a team.
    • Get the respawn time of a client.
    • Detect when the game changes the respawn time of a team.
    • Detect when the game sets the respawn time on the client.
    • Detect when the game updates the respawn time of a client.
    The inc (with forwards and natives):
    Spoiler


    Installation:
    • Download tf2_respawn_system_core.smx and put it into your plugins folder.
    • Download tf2_respawn.inc and put into your include folder.
    • (Optional) Download tf2_respawn_system_core.sp and put into your scripting folder.

    Bugs:
    • None.

    List of plugins working with this API:
    • None (A plugin, and a example plugin are comming).

    Total downloads:
    • 85

    Git-Hub Link
    Attached Files
    File Type: sp Get Plugin or Get Source (tf2_respawn_system_core.sp - 524 views - 11.9 KB)
    File Type: smx tf2_respawn_system_core.smx (8.8 KB, 522 views)
    File Type: inc tf2_respawn.inc (3.7 KB, 534 views)
    __________________

    Last edited by Benoist3012; 03-19-2017 at 12:51.
    Benoist3012 is offline
    Snaggle
    AlliedModders Donor
    Join Date: Jul 2010
    Location: England
    Old 04-30-2016 , 17:18   Re: [TF2] Respawn System API!
    Reply With Quote #2

    I like what this offers, thank you.
    Snaggle is offline
    Benoist3012
    Veteran Member
    Join Date: Mar 2014
    Location: CWave::ForceFinish()
    Old 03-19-2017 , 12:50   Re: [TF2] Respawn System API!
    Reply With Quote #3

    [TF2] Respawn System API Update! v0.2


    Changelog:
    • Fixed an issue where the core was wrongly displaying 124 seconds as respawn time.
    • Improved core's logic.
    • Added a new native, TF2_IsClientRespawning.
    __________________

    Last edited by Benoist3012; 03-19-2017 at 12:50.
    Benoist3012 is offline
    404UserNotFound
    BANNED
    Join Date: Dec 2011
    Old 03-20-2017 , 00:19   Re: [TF2] Respawn System API!
    Reply With Quote #4

    I like these types of plugins. They are incredibly useful and a great learning tool.

    Last edited by 404UserNotFound; 03-20-2017 at 00:19.
    404UserNotFound is offline
    Rokasz
    Junior Member
    Join Date: Jun 2020
    Old 04-10-2021 , 14:39   Re: [TF2] Respawn System API!
    Reply With Quote #5

    But what are the cvars? How do I exactly control/set the respawn time of each team? (e.g: I want to make BLU team respawn after 3 seconds and make RED team respawn after 10?) Help will be appreciated.
    Rokasz is offline
    PC Gamer
    Veteran Member
    Join Date: Mar 2014
    Old 04-10-2021 , 14:58   Re: [TF2] Respawn System API!
    Reply With Quote #6

    Quote:
    Originally Posted by Rokasz View Post
    How do I exactly control/set the respawn time of each team?
    You'll have to develop a plugin that will take advantage of the natives provided in this API.
    PC Gamer is offline
    Sappykun
    Member
    Join Date: Nov 2019
    Old 07-21-2022 , 23:06   Re: [TF2] Respawn System API!
    Reply With Quote #7

    There are two issues with this plugin, the second one being more severe:

    1) The SharedPlugin name in the include file (line 104) refers to TF2 Respawn System API, and the RegPluginLibrary line in the core source file (line 70) refers to tf2_respawn_time. This prevents anyone from using the tf2_respawn.inc file in their plugins. Pretty simple fix, just rename one or the other so they both match.

    2) This plugin causes the server to crash when a player is about to respawn if they changed classes during their respawn time. For example: Spawn as Sniper, killbind, press comma and change class to Soldier before the respawn timer is up. When the timer reaches 0, the server dies.

    Code:
    Host_Error: SV_CreatePacketEntities: GetEntServerClass failed for ent 82.??
    https://crash.limetech.org/6ysq4befc3t7

    Last edited by Sappykun; 07-21-2022 at 23:09.
    Sappykun is offline
    Sappykun
    Member
    Join Date: Nov 2019
    Old 09-18-2022 , 22:15   Re: [TF2] Respawn System API!
    Reply With Quote #8

    Two months later, but an update:

    The crash was caused by calling TF2_RespawnPlayer inside a SetTransmit hook. Changing that to use RequestFrame instead fixed the issue for me.
    I've attached an updated version of the plugin to address the issues I mentioned above, plus some compiler warnings I was getting when building the plugin myself (warning 242: function "Timer_AverageUpdateRespawnTime" should return an explicit value, etc.)

    Special thanks to bakugo for finding the fix.
    Attached Files
    File Type: sp Get Plugin or Get Source (tf2_respawn_system_core.sp - 90 views - 12.2 KB)
    File Type: inc tf2_respawn.inc (3.7 KB, 70 views)
    File Type: smx tf2_respawn_system_core.smx (7.4 KB, 115 views)

    Last edited by Sappykun; 09-18-2022 at 22:16.
    Sappykun is offline
    valio_skull
    Senior Member
    Join Date: Jan 2013
    Location: at home
    Old 05-31-2023 , 20:31   Re: [TF2] Respawn System API!
    Reply With Quote #9

    sorry for necroposting, did anyone actually make a plugin utilizing this api ?
    __________________
    valio_skull is offline
    constantitus
    New Member
    Join Date: Jun 2023
    Old 06-02-2023 , 07:12   Re: [TF2] Respawn System API!
    Reply With Quote #10

    Quickly wrote this one for my server.
    I use UMC to set the cvars per map. If you want to update the cvars mid-map, you'll have to use mp_restartgame 1 or wait until the game changes the respawn times itself (on round end or capturing a checkpoint, not sure)
    PHP Code:
    #include <sourcemod>
    #include <tf2_respawn>

    #pragma semicolon 1;
    #pragma newdecls required;

    ConVar g_Enabled;
    ConVar g_TimeBoth;
    ConVar g_TimeBlue;
    ConVar g_TimeRed;

    public 
    void OnPluginStart() {
        
    g_Enabled CreateConVar("respawntime_enabled""1""Enable modified respawn times");
        
    g_TimeBoth CreateConVar("respawntime_both""-1""Sets the respawn time of both teams (-1 to disable)");
        
    g_TimeBlue CreateConVar("respawntime_blue""0""Adds or subtracts from the Blue team's respawn time");
        
    g_TimeRed CreateConVar("respawntime_red""0""Adds or subtracts from the Red team's respawn time");
    }

    public 
    Action TF2_OnTeamRespawnTimeChanged(int iTeamfloat &flRespawnTime) {
        if (
    GetConVarBool(g_Enabled)) {
            
    float rTime;
            if (
    GetConVarFloat(g_TimeBoth) >= 0)
                
    rTime GetConVarFloat(g_TimeBoth);
            else
            
    rTime flRespawnTime;
            if (
    iTeam == 2)
                
    rTime += GetConVarFloat(g_TimeRed);
            if (
    iTeam == 3)
                
    rTime += GetConVarFloat(g_TimeBlue);
            
    flRespawnTime rTime;

            return 
    Plugin_Changed;
        } else {
            return 
    Plugin_Continue;
        }

    constantitus 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 04:07.


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