Raised This Month: $32 Target: $400
 8% 

help with code respawn on connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr.J
Senior Member
Join Date: Sep 2017
Location: cs_assault
Old 01-04-2018 , 14:32   help with code respawn on connect
Reply With Quote #1

can anyone make this code for cs 1.6 not for zp ?
this plugin by natsheh
PHP Code:
#include <amxmodx>
#include <zp50_core>
#include <hamsandwich>
#include <cstrike>

new gCvar_respawn_enable
new gCvar_respawn_team
new gCvar_respawn_time
new bool:gConnectSpawn[33]
new 
g_maxplayers

public plugin_init()
{
    
register_plugin("[ZP] Connect-Respawn""1.0""natsheh")
    
    
gCvar_respawn_enable register_cvar("zp_connect_respawn_enable""1")
    
gCvar_respawn_team register_cvar("zp_connect_respawn_team""0")
    
gCvar_respawn_time register_cvar("zp_connect_respawn_time""3.0")
    
    
register_message(get_user_msgid("ShowMenu"), "message_ShowMenu")
    
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu")
    
    
RegisterHam(Ham_Spawn"player""fw_user_spawn"1)
    
RegisterHam(Ham_Respawn"player""fw_user_spawn"1)
    
    
g_maxplayers get_maxplayers()
}

public 
fw_user_spawn(id)
{
    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id] && is_user_alive(id))
    {
        
gConnectSpawn[id] = false
    
}
}

public 
client_join_task(idiMsgid)
{
    new 
param[2]
    
param[0] = iMsgid
    set_task
(0.1"client_join"idparam[0], sizeof(param))
}

public 
message_ShowMenu(iMsgidiDestid)
{
    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id])
    {
        
client_join_task(idiMsgid)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
message_VGUIMenu(iMsgidiDestid)
{
    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id])
    {
        
client_join_task(idiMsgid)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
Auto_Spawn(id)
{
    static 
CsTeams:team
    team 
cs_get_user_team(id)

    if(
team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR)
        return 
PLUGIN_HANDLED
    
    
if(!get_first_zombie() || get_player_team() == 2)
    {
        
zp_core_respawn_as_zombie(idfalse)
    }
    else if(!
get_player_team())
    {
        if(
zp_core_get_human_count() > zp_core_get_zombie_count())
        {
            
zp_core_respawn_as_zombie(idtrue)
        }
        else if(
zp_core_get_human_count() < zp_core_get_zombie_count())
        {
            
zp_core_respawn_as_zombie(idfalse)
        }
        else
        {
            static 
brandom_num(12)
            
zp_core_respawn_as_zombie(id, (== true:false))
        }
    }
    else if(
get_player_team() == 1)
        
zp_core_respawn_as_zombie(idtrue)
    
    if(!
is_user_alive(id) && is_user_connected(id))
    {
        
gConnectSpawn[id] = false
        set_task
(get_pcvar_float(gCvar_respawn_time), "Spawn_Player"id)
    }
    return 
PLUGIN_CONTINUE
}

public 
client_connect(id)
{
    
gConnectSpawn[id] = true
}

public 
client_putinserver(id)
{
    if(!
is_user_bot(id))
    {
        
gConnectSpawn[id] = true
    
}
}

public 
client_disconnect(id)
{
    
gConnectSpawn[id] = false
}

public 
Spawn_Player(id)
{
    if(!
is_user_alive(id) && is_user_connected(id))
    {
        
ExecuteHamB(Ham_CS_RoundRespawnid)
    }
}

public 
client_join(param[], id)
{
    if(
gConnectSpawn[id] && get_pcvar_num(gCvar_respawn_enable))
    {
        new 
iMsgBlock get_msg_block(param[0])
        
set_msg_block(param[0], BLOCK_SET)
        
        new 
gTeam[2]; gTeam[0] = get_player_team();
        
client_cmd(id"jointeam %i"gTeam[0])
        
        new 
gClass[2]; gClass[0] = get_player_class();
        
client_cmd(id"joinclass %i"gClass[0])
        
        
set_task(1.0"Auto_Spawn"id)
        
set_msg_block(param[0], iMsgBlock)
    }
}

stock get_player_team()
{
    new 
a
    
    
switch( get_pcvar_num(gCvar_respawn_team) )
    {
        case 
0:
        {
            
random_num(1,2)
        }
        case 
1:
        {
            
1
        
}
        case 
2:
        {
            
2
        
}
    }
    return 
a
}

stock get_player_class()
{
    return 
random_num(1,4)
}

public 
get_first_zombie()
{
    new 
id
    
    
for(new 1g_maxplayersi++)
    {
        if(!
is_user_connected(i))
            continue;
        
        if(
zp_core_is_first_zombie(i) && is_user_alive(i))
        {
            
id i
            
break;
        }
    }
    return 
id

Mr.J is offline
Senzor
Member
Join Date: Nov 2012
Location: Romania
Old 01-04-2018 , 15:39   Re: help with code respawn on connect
Reply With Quote #2

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

new gCvar_respawn_enable 
new gCvar_respawn_team 
new gCvar_respawn_time 
new bool:gConnectSpawn[33

public 
plugin_init() 

    
register_plugin("Connect-Respawn""1.0""natsheh"
     
    
gCvar_respawn_enable register_cvar("connect_respawn_enable""1"
    
gCvar_respawn_team register_cvar("connect_respawn_team""0"
    
gCvar_respawn_time register_cvar("connect_respawn_time""3.0"
     
    
register_message(get_user_msgid("ShowMenu"), "message_ShowMenu"
    
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu"
     
    
RegisterHam(Ham_Spawn"player""fw_user_spawn"1
    
RegisterHam(Ham_Respawn"player""fw_user_spawn"1


public 
fw_user_spawn(id

    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id] && is_user_alive(id)) 
    { 
        
gConnectSpawn[id] = false 
    



public 
client_join_task(idiMsgid

    new 
param[2
    
param[0] = iMsgid 
    set_task
(0.1"client_join"idparam[0], sizeof(param)) 


public 
message_ShowMenu(iMsgidiDestid

    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id]) 
    { 
        
client_join_task(idiMsgid
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
message_VGUIMenu(iMsgidiDestid

    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id]) 
    { 
        
client_join_task(idiMsgid
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
Auto_Spawn(id

    static 
CsTeams:team 
    team 
cs_get_user_team(id

    if(
team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR
        return 
PLUGIN_HANDLED 
     
    
if(!is_user_alive(id) && is_user_connected(id)) 
    { 
        
gConnectSpawn[id] = false 
        set_task
(get_pcvar_float(gCvar_respawn_time), "Spawn_Player"id
    } 
    return 
PLUGIN_CONTINUE 


public 
client_connect(id

    
gConnectSpawn[id] = true 


public 
client_putinserver(id

    if(!
is_user_bot(id)) 
    { 
        
gConnectSpawn[id] = true 
    



public 
client_disconnect(id

    
gConnectSpawn[id] = false 


public 
Spawn_Player(id

    if(!
is_user_alive(id) && is_user_connected(id)) 
    { 
        
ExecuteHamB(Ham_CS_RoundRespawnid
    } 


public 
client_join(param[], id

    if(
gConnectSpawn[id] && get_pcvar_num(gCvar_respawn_enable)) 
    { 
        new 
iMsgBlock get_msg_block(param[0]) 
        
set_msg_block(param[0], BLOCK_SET
         
        new 
gTeam[2]; gTeam[0] = get_player_team(); 
        
client_cmd(id"jointeam %i"gTeam[0]) 
         
        new 
gClass[2]; gClass[0] = get_player_class(); 
        
client_cmd(id"joinclass %i"gClass[0]) 
         
        
set_task(1.0"Auto_Spawn"id
        
set_msg_block(param[0], iMsgBlock
    } 


stock get_player_team() 

    new 

     
    
switch( get_pcvar_num(gCvar_respawn_team) ) 
    { 
        case 
0
        { 
            
random_num(1,2
        } 
        case 
1
        { 
            

        

        case 
2
        { 
            

        

    } 
    return 



stock get_player_class() 

    return 
random_num(1,4


Last edited by Senzor; 01-04-2018 at 15:41.
Senzor is offline
Mr.J
Senior Member
Join Date: Sep 2017
Location: cs_assault
Old 01-05-2018 , 07:42   Re: help with code respawn on connect
Reply With Quote #3

Quote:
Originally Posted by Senzor View Post
PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#include <cstrike> 

new gCvar_respawn_enable 
new gCvar_respawn_team 
new gCvar_respawn_time 
new bool:gConnectSpawn[33

public 
plugin_init() 

    
register_plugin("Connect-Respawn""1.0""natsheh"
     
    
gCvar_respawn_enable register_cvar("connect_respawn_enable""1"
    
gCvar_respawn_team register_cvar("connect_respawn_team""0"
    
gCvar_respawn_time register_cvar("connect_respawn_time""3.0"
     
    
register_message(get_user_msgid("ShowMenu"), "message_ShowMenu"
    
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu"
     
    
RegisterHam(Ham_Spawn"player""fw_user_spawn"1
    
RegisterHam(Ham_Respawn"player""fw_user_spawn"1


public 
fw_user_spawn(id

    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id] && is_user_alive(id)) 
    { 
        
gConnectSpawn[id] = false 
    



public 
client_join_task(idiMsgid

    new 
param[2
    
param[0] = iMsgid 
    set_task
(0.1"client_join"idparam[0], sizeof(param)) 


public 
message_ShowMenu(iMsgidiDestid

    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id]) 
    { 
        
client_join_task(idiMsgid
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
message_VGUIMenu(iMsgidiDestid

    if(
get_pcvar_num(gCvar_respawn_enable) && gConnectSpawn[id]) 
    { 
        
client_join_task(idiMsgid
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
Auto_Spawn(id

    static 
CsTeams:team 
    team 
cs_get_user_team(id

    if(
team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR
        return 
PLUGIN_HANDLED 
     
    
if(!is_user_alive(id) && is_user_connected(id)) 
    { 
        
gConnectSpawn[id] = false 
        set_task
(get_pcvar_float(gCvar_respawn_time), "Spawn_Player"id
    } 
    return 
PLUGIN_CONTINUE 


public 
client_connect(id

    
gConnectSpawn[id] = true 


public 
client_putinserver(id

    if(!
is_user_bot(id)) 
    { 
        
gConnectSpawn[id] = true 
    



public 
client_disconnect(id

    
gConnectSpawn[id] = false 


public 
Spawn_Player(id

    if(!
is_user_alive(id) && is_user_connected(id)) 
    { 
        
ExecuteHamB(Ham_CS_RoundRespawnid
    } 


public 
client_join(param[], id

    if(
gConnectSpawn[id] && get_pcvar_num(gCvar_respawn_enable)) 
    { 
        new 
iMsgBlock get_msg_block(param[0]) 
        
set_msg_block(param[0], BLOCK_SET
         
        new 
gTeam[2]; gTeam[0] = get_player_team(); 
        
client_cmd(id"jointeam %i"gTeam[0]) 
         
        new 
gClass[2]; gClass[0] = get_player_class(); 
        
client_cmd(id"joinclass %i"gClass[0]) 
         
        
set_task(1.0"Auto_Spawn"id
        
set_msg_block(param[0], iMsgBlock
    } 


stock get_player_team() 

    new 

     
    
switch( get_pcvar_num(gCvar_respawn_team) ) 
    { 
        case 
0
        { 
            
random_num(1,2
        } 
        case 
1
        { 
            

        

        case 
2
        { 
            

        

    } 
    return 



stock get_player_class() 

    return 
random_num(1,4

Thx
Mr.J 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 14:35.


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