AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Respawn System API! (https://forums.alliedmods.net/showthread.php?t=282172)

Benoist3012 04-30-2016 16:47

[TF2] Respawn System API!
 
3 Attachment(s)
[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

Snaggle 04-30-2016 17:18

Re: [TF2] Respawn System API!
 
I like what this offers, thank you.

Benoist3012 03-19-2017 12:50

Re: [TF2] Respawn System API!
 
[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.

404UserNotFound 03-20-2017 00:19

Re: [TF2] Respawn System API!
 
I like these types of plugins. They are incredibly useful and a great learning tool.

Rokasz 04-10-2021 14:39

Re: [TF2] Respawn System API!
 
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.

PC Gamer 04-10-2021 14:58

Re: [TF2] Respawn System API!
 
Quote:

Originally Posted by Rokasz (Post 2743694)
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.

Sappykun 07-21-2022 23:06

Re: [TF2] Respawn System API!
 
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

Sappykun 09-18-2022 22:15

Re: [TF2] Respawn System API!
 
3 Attachment(s)
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.

valio_skull 05-31-2023 20:31

Re: [TF2] Respawn System API!
 
sorry for necroposting, did anyone actually make a plugin utilizing this api ?

constantitus 06-02-2023 07:12

Re: [TF2] Respawn System API!
 
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;
    }




All times are GMT -4. The time now is 19:17.

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