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

Auto Respawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cirovic
Senior Member
Join Date: Sep 2019
Old 07-29-2020 , 11:44   Auto Respawn
Reply With Quote #1

I need plugin that will automaticly respawn death players, and players who join server.
i can't found it with respawn for people who join server.
Cirovic is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 07-29-2020 , 16:00   Re: Auto Respawn
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <hamsandwich>


public plugin_init()
{
    
RegisterHam(Ham_Killed"player""hPlayerKilledPost"1);
}

public 
client_putinserver(id)
{
    
set_task(2.0"respawnPlayer"id);
}

public 
hPlayerKilledPost(iVictim)
{
    if(
is_user_connected(iVictim))
        
set_task(2.0"respawnPlayer"iVictim);
}

public 
respawnPlayer(id)
{
    if(
is_user_connected(id) && !is_user_bot(id))
    {
        
ExecuteHamB(Ham_CS_RoundRespawnid);
    }


Last edited by ZaX; 07-30-2020 at 07:08.
ZaX is offline
Cirovic
Senior Member
Join Date: Sep 2019
Old 07-30-2020 , 00:27   Re: Auto Respawn
Reply With Quote #3

it bugs, with bots in spectator they get revieved too..
Cirovic is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 07-30-2020 , 07:08   Re: Auto Respawn
Reply With Quote #4

Edited the code
ZaX is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-30-2020 , 07:19   Re: Auto Respawn
Reply With Quote #5

A team check is needed. Real players can be spectators too.

Code:
#include <amxmodx> #include <cstrike> #include <hamsandwich> const Float:REVIVE_DELAY = 2.0; public plugin_init() {     RegisterHam(Ham_Killed, "player", "hPlayerKilledPost", 1); } public client_putinserver(id) {     set_task(REVIVE_DELAY, "respawnPlayer", id); } public hPlayerKilledPost(iVictim) {     if(is_safe_to_revive(iVictim))     {         set_task(REVIVE_DELAY, "respawnPlayer", iVictim);     } } public respawnPlayer(id) {     if(is_safe_to_revive(id))     {         ExecuteHamB(Ham_CS_RoundRespawn, id);     } } bool:is_safe_to_revive(id) {     return is_user_connected(id) && CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT; }
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 07-30-2020 , 08:10   Re: Auto Respawn
Reply With Quote #6

Wouldn't it be better so register a join team logevent?

PHP Code:
#include <amxmodx>

#include <hamsandwich>

#pragma semicolon 1

#define IsPlayer(%1) (1<=%1<=32)
#define DELAY 1.0

public plugin_init(){
    
register_plugin("MY""NAME""JEFF");
    
    
register_logevent("JoinTeam"3"1=joined team");
    
RegisterHam(Ham_Killed"player""ham_PlayerKilledPost"1);
}

public 
JoinTeam(){
    new 
user[128], name[32];
    
read_logargv(0user127);
    
parse_loguser(username31);
    new 
id=get_user_index(name);
    
    if(!
IsPlayer(id))
        return;
        
    new 
temp[2];
    
read_logargv(2temp1);
    if(
temp[0]=='T')
        
set_task(DELAY+4.0"task_Respawn"id);
    
    else if(
temp[0]=='C')
        
set_task(DELAY+4.0"task_Respawn"id);
    
    return;
}

public 
ham_PlayerKilledPost(id){
    
set_task(DELAY"task_Respawn"id);
}

public 
task_Respawn(id){
    if(
get_user_team(id)!=3)
        
ExecuteHamB(Ham_CS_RoundRespawnid);


Last edited by Foxa; 07-30-2020 at 09:13.
Foxa is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-30-2020 , 08:56   Re: Auto Respawn
Reply With Quote #7

What's the difference? The player will die anyways if the switches teams while alive.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 07-30-2020 , 09:12   Re: Auto Respawn
Reply With Quote #8

But it won't respawn players who join the team from spectators, or if they don't pick a team in less than 2 seconds after they connect.
Foxa is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-30-2020 , 09:56   Re: Auto Respawn
Reply With Quote #9

Why should it not respawn them if they joined from spectators? My code prevents unassigned team as well.
__________________

Last edited by OciXCrom; 07-30-2020 at 09:57.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 07-30-2020 , 11:29   Re: Auto Respawn
Reply With Quote #10

They won't get respawned if they join a team from spectators, lets say an admin transfers a user to spectators for being afk, once the user is back they would have to wait for the whole round to be respawned after they pick a team, also i'm pretty sure that if they don't choose a team in the given delay they wouldn't be respawned (which is why I added the DELAY+4.0 in my code, since <5 seconds should be enough to pick a player model). Your way would work if the server is running a plugin that doesn't let the user pick a team.

Also, probably hooking the "joinclass" command would be better than join team event (again if the server is not running some kind of auto team join plugin + it removes the question of "what if they don't pick a model in a given time frame")

PHP Code:
#include <amxmodx>

#include <hamsandwich>

#pragma semicolon 1

#define IsPlayer(%1) (1<=%1<=32)
#define DELAY 1.0

public plugin_init(){
    
register_plugin("MY""NAME""JEFF");
    
    
RegisterHam(Ham_Killed"player""ham_PlayerKilledPost"1);
    
    
register_clcmd("joinclass""clcmd_JoinClass");
}

public 
ham_PlayerKilledPost(id){
    if(!
task_exists(id))
        
set_task(DELAY"task_Respawn"id);
}

public 
clcmd_JoinClass(id){
    if(!
task_exists(id))
        
set_task(DELAY"task_Respawn"id);
}

public 
task_Respawn(id){
    if(
get_user_team(id)!=&& IsPlayer(id))
        
ExecuteHamB(Ham_CS_RoundRespawnid);


Last edited by Foxa; 07-30-2020 at 11:30.
Foxa 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 05:50.


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