Raised This Month: $ Target: $400
 0% 

Autorespawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
villios
Member
Join Date: Nov 2009
Old 04-29-2018 , 15:18   Autorespawn
Reply With Quote #1

Hi there! I wonder if anyone can help me so that the players will autorespawn when they have choosen a team (SPECTATORS should not autorespawn - only T or CT). The plugin that I use does not autorespawn players who join late.

Here is the code/plugin I'm using right now:

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#define PLUGIN "Respawn Mod"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define RESPAWN_TIME_DELAY 3.0
#define TASK_ID 1337

new g_restart_attempt[33];
new 
bool:just_joined[33] = { true , ... };

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event("DeathMsg""death_msg""a");
    
    
register_event("ResetHUD""event_hud_reset""be");
    
register_clcmd("fullupdate""clcmd_fullupdate");
    
register_event("TextMsg""event_restart_attempt""a""2=#Game_will_restart_in");
    
    
register_clcmd("say /respawn""command_respawn");
}

public 
client_disconnect(id)
    
just_joined[id] = true;

public 
clcmd_fullupdate()
    return 
2;

public 
event_restart_attempt()
{
    
    new 
players[32], num;
    
get_players(playersnum"a");
    
    for(new 
num ; ++i)
        
g_restart_attempt[players[i]] = true;
}

public 
event_hud_reset(id)
{
    if (
g_restart_attempt[id])
    {
        
g_restart_attempt[id] = false;
        return;
    }
    
event_player_spawn(id);
}

public 
event_player_spawn(id)
{
    if(!
just_joined[id])
        return;
    
    
just_joined[id] = false;
    
    
set_task(0.5"set_items"id);
}

public 
set_items(index)
{
    if(!
is_user_connected(index))
        return;
    
    
fm_strip_user_weapons(index);
    
fm_give_item(index"weapon_knife");
}

public 
death_msg()
{
    new 
victim read_data(2);
    
    if(
just_joined[victim])
        return;
    
    
set_task(RESPAWN_TIME_DELAY"respawn_player"victim TASK_ID);
}

public 
respawn_player(taskID)
{
    new 
id taskID TASK_ID;
    new 
CsTeams:team cs_get_user_team(id);
    
    if(
team != CS_TEAM_T && team != CS_TEAM_CT)
        return;
    
    
cs_user_spawn(id);
}

public 
command_respawn(id)
{
    if(
is_user_alive(id))
        return;
    
    
set_task(RESPAWN_TIME_DELAY"respawn_player"id TASK_ID);
}

/*Fakemeta GOOD (Fun module sucks badly)! Stocks*/

stock fm_strip_user_weapons(index)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"));
    
    if(!
pev_valid(ent))
        return 
0;
    
    
dllfunc(DLLFunc_Spawnent);
    
dllfunc(DLLFunc_Useentindex);
    
engfunc(EngFunc_RemoveEntityent);
    
    return 
1;
}

stock fm_give_item(index, const item[])
{
    if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
        return 
0;
    
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem));
    
    if(!
pev_valid(ent))
        return 
0;
    
    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
    
dllfunc(DLLFunc_Spawnent);
    
    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    
    if(
pev(entpev_solid) != save)
        return 
ent;
    
    
engfunc(EngFunc_RemoveEntityent);
    
    return -
1;


Last edited by villios; 04-29-2018 at 15:19.
villios is offline
Vieni
Member
Join Date: Apr 2018
Old 04-29-2018 , 17:13   Re: Autorespawn
Reply With Quote #2

Try

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#define PLUGIN "Respawn Mod"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define RESPAWN_TIME_DELAY 3.0
#define TASK_ID 1337

new g_restart_attempt[33];
new 
bool:just_joined[33] = { true , ... };

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event("DeathMsg""death_msg""a");
    
    
register_event("ResetHUD""event_hud_reset""be");
    
register_clcmd("fullupdate""clcmd_fullupdate");
    
register_event("TextMsg""event_restart_attempt""a""2=#Game_will_restart_in");
    
    
register_clcmd("jointeam 1""command_respawn");
    
register_clcmd("jointeam 2""command_respawn");
}

public 
client_disconnect(id)
    
just_joined[id] = true;

public 
clcmd_fullupdate()
    return 
2;

public 
event_restart_attempt()
{
    
    new 
players[32], num;
    
get_players(playersnum"a");
    
    for(new 
num ; ++i)
        
g_restart_attempt[players[i]] = true;
}

public 
event_hud_reset(id)
{
    if (
g_restart_attempt[id])
    {
        
g_restart_attempt[id] = false;
        return;
    }
    
event_player_spawn(id);
}

public 
event_player_spawn(id)
{
    if(!
just_joined[id])
        return;
    
    
just_joined[id] = false;
    
    
set_task(0.5"set_items"id);
}

public 
set_items(index)
{
    if(!
is_user_connected(index))
        return;
    
    
fm_strip_user_weapons(index);
    
fm_give_item(index"weapon_knife");
}

public 
death_msg()
{
    new 
victim read_data(2);
    
    if(
just_joined[victim])
        return;
    
    
set_task(RESPAWN_TIME_DELAY"respawn_player"victim TASK_ID);
}

public 
respawn_player(taskID)
{
    new 
id taskID TASK_ID;
    new 
CsTeams:team cs_get_user_team(id);
    
    if(
team != CS_TEAM_T && team != CS_TEAM_CT)
        return;
    
    
cs_user_spawn(id);
}

public 
command_respawn(id)
{
    if(
is_user_alive(id))
        return;
    
    
set_task(RESPAWN_TIME_DELAY"respawn_player"id TASK_ID);
}

/*Fakemeta GOOD (Fun module sucks badly)! Stocks*/

stock fm_strip_user_weapons(index)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"));
    
    if(!
pev_valid(ent))
        return 
0;
    
    
dllfunc(DLLFunc_Spawnent);
    
dllfunc(DLLFunc_Useentindex);
    
engfunc(EngFunc_RemoveEntityent);
    
    return 
1;
}

stock fm_give_item(index, const item[])
{
    if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
        return 
0;
    
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem));
    
    if(!
pev_valid(ent))
        return 
0;
    
    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
    
dllfunc(DLLFunc_Spawnent);
    
    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    
    if(
pev(entpev_solid) != save)
        return 
ent;
    
    
engfunc(EngFunc_RemoveEntityent);
    
    return -
1;

Vieni 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:38.


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