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

[TF2-REQ] Simple Respawn plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZAGOR
AlliedModders Donor
Join Date: Sep 2015
Old 09-29-2016 , 09:38   [TF2-REQ] Simple Respawn plugin
Reply With Quote #1

Im looking for TF2 simple respawn plugin, following details;

- Only 1 time auto-respawn for red team, per round and only first 30 seconds.

Can somebody help me ? Thanks in advance
__________________


Last edited by ZAGOR; 09-29-2016 at 09:50.
ZAGOR is offline
ZAGOR
AlliedModders Donor
Join Date: Sep 2015
Old 10-04-2016 , 03:00   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #2

I found the following script,and i changed a few parts but I don't know exactly sourcepawn. So can someone help me do this?
  • Only 1 time
  • Only for Red Team
  • Auto-Respawn OK
  • Per Round OK
  • Only first 30 seconds OK

Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

new roundTime;
new currentTime; 

public OnPluginStart()
{
    HookEvent("teamplay_round_start", Event_RoundStart);
    HookEvent("player_death", Event_PlayerDeath);
}

public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    roundTime = GetTime();
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    currentTime = GetTime();
    
    if (currentTime-roundTime > 30)
        return;
    
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    CreateTimer(1.0, ExecRespawn, client);
}

public Action:ExecRespawn(Handle:timer, any:client)
{
    if ( client && (!IsPlayerAlive(client)))
    {
            TF2_RespawnPlayer(client);
    }    
    return Plugin_Stop;
}
__________________


Last edited by ZAGOR; 10-04-2016 at 03:36.
ZAGOR is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-04-2016 , 03:56   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #3

passing client in timer is bad.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
ZAGOR
AlliedModders Donor
Join Date: Sep 2015
Old 10-04-2016 , 04:24   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #4

Dude I didn't do it :/ Just i found from alliedmods I don't know how better yet,
__________________

ZAGOR is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-04-2016 , 04:56   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #5

Quote:
Originally Posted by friagram View Post
passing client in timer is bad.
I do it, and I don't understand why it's bad to do so (if I remember correctly, the wiki does it too). But since it's bad, how would you do it ? An array of boolean and set it to true on client's cell when you have to do something with that particular client and back to false on each timer iteration ?
__________________
Want to check my plugins ?
Arkarr is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-04-2016 , 05:22   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #6

pass userid instead since some1 might take another's client index
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

new roundTime;
new 
currentTime
new 
bool:g_bRespawned[MAXPLAYERS 1];

public 
OnPluginStart()
{
    
HookEvent("teamplay_round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
roundTime GetTime();
    for (new 
1<= MaxClientsi++)
        
g_bRespawned[i] = false;
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
currentTime GetTime();
    
    if (
currentTime-roundTime 30)
        return;
    
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    if (
GetClientTeam(client) == TFTeam_Red && !g_bRespawned[client])
        
CreateTimer(1.0ExecRespawnuserid);
}

public 
Action:ExecRespawn(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if ( 
client && (!IsPlayerAlive(client)))
    {
        
TF2_RespawnPlayer(client);
        
g_bRespawned[client] = true;
    }    
    return 
Plugin_Stop;

not tested
__________________
8guawong is offline
ZAGOR
AlliedModders Donor
Join Date: Sep 2015
Old 10-04-2016 , 06:39   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #7

Thank u dude it work can u add following ;

After round start
if (currentTime-roundTime == 30)
PrintToChatAll("Respawn time has ended!");
I tried but it didn't work
__________________


Last edited by ZAGOR; 10-04-2016 at 06:44.
ZAGOR is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-04-2016 , 07:01   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #8

Quote:
Originally Posted by 8guawong View Post
pass userid instead since some1 might take another's client index
Oh right, yeah... That's what I was missing.
__________________
Want to check my plugins ?
Arkarr is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-04-2016 , 07:34   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #9

Quote:
Originally Posted by ZAGOR View Post
Thank u dude it work can u add following ;

After round start
if (currentTime-roundTime == 30)
PrintToChatAll("Respawn time has ended!");
I tried but it didn't work
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

new roundTime;
new 
currentTime
new 
bool:g_bRespawned[MAXPLAYERS 1];

public 
OnPluginStart()
{
    
HookEvent("teamplay_round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
roundTime GetTime();
    for (new 
1<= MaxClientsi++)
        
g_bRespawned[i] = false;
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
currentTime GetTime();
    
    if (
currentTime-roundTime 30)
    {
        
PrintToChatAll("Respawn time has ended!");
        return;
    }    
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    if (
GetClientTeam(client) == TFTeam_Red && !g_bRespawned[client])
        
CreateTimer(1.0ExecRespawnuserid);
}

public 
Action:ExecRespawn(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if ( 
client && (!IsPlayerAlive(client)))
    {
        
TF2_RespawnPlayer(client);
        
g_bRespawned[client] = true;
    }    
    return 
Plugin_Stop;

__________________
8guawong is offline
ZAGOR
AlliedModders Donor
Join Date: Sep 2015
Old 10-04-2016 , 08:05   Re: [TF2-REQ] Simple Respawn plugin
Reply With Quote #10

Thnk u dude i think I told wrong after 30 seconds PrintToChatAll("Respawn time has ended!");
But I did it It works fine. I do not know how to correct encoding ;
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <morecolors>

new roundTime;
new 
currentTime
new 
bool:g_bRespawned[MAXPLAYERS 1];

public 
OnPluginStart()
{
    
HookEvent("teamplay_round_start"Event_RoundStart);
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
roundTime GetTime();
    for (new 
1<= MaxClientsi++)
        
g_bRespawned[i] = false;
    
CreateTimer(30.0auto_TIMER_FLAG_NO_MAPCHANGE);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
currentTime GetTime();
    
    if (
currentTime-roundTime 30)
        return;
    
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    if (
GetClientTeam(client) == TFTeam_Red && !g_bRespawned[client])
        
CreateTimer(1.0ExecRespawnuserid);
    
CPrintToChatAll("{tomato}[2.Life] {darkorange}%N {salmon}respawned with 2.Life"client);
}
public 
Action:auto(Handle:timerany:id)
{
            
CPrintToChatAll("{tomato}[2.Life] {salmon}Respawn time has ended!");
}
public 
Action:ExecRespawn(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if ( 
client && (!IsPlayerAlive(client)))
    {
        
TF2_RespawnPlayer(client);
        
g_bRespawned[client] = true;
    }    
    return 
Plugin_Stop;

So thank u for help I shared for the benefit of others.
__________________


Last edited by ZAGOR; 10-04-2016 at 08:25.
ZAGOR 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 08:45.


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