Raised This Month: $ Target: $400
 0% 

Spawn on connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeeT
Junior Member
Join Date: Aug 2010
Old 07-21-2011 , 10:28   Spawn on connect
Reply With Quote #1

Hello all, i would like to make a simple plugin.
Respawn player on connect, when player connected and selected team, he should be respawned. How to make it?

I have simple script, but it doesn't work all time, sometimes it's works sometimes no. And idk why...

Code:
/* Plugin generated by AMXX-Studio */
 
#include <amxmodx>
#include <hamsandwich>
 
#define PLUGIN "Spawn on connect"
#define VERSION "1.0"
#define AUTHOR "aaarnas"
 
new client_validate[33]
 
public plugin_init()
    register_plugin(PLUGIN, VERSION, AUTHOR)
 
public client_connect(id)
    client_validate[id] = 0
 
public client_command(id) {
 
    new cmd[20]
    read_argv(0, cmd, charsmax(cmd))
   
    if(equal(cmd, "jointeam")) client_validate[id]++
    else if(equal(cmd, "joinclass")) client_validate[id]++
   
    if(client_validate[id] == 2) set_task(0.3, "spawn_player", id)
}
 
public spawn_player(id) if(!is_user_alive(id)) ExecuteHamB(Ham_CS_RoundRespawn, id)
BeeT is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 07-21-2011 , 11:08   Re: Spawn on connect
Reply With Quote #2

someone cared this question or researched this before? Let's discuess an efficient hacking method. I think there's something related to the time. cause sometime game will respawn a connected player, sometime not(when the round has started for a while). I once tried to find some info about this, but end with fail.
the procedure from a player connected to physicically spawn is a mess. I can't even find a good place to hook. Anyone interested ? Let's talk about it here
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
BeeT
Junior Member
Join Date: Aug 2010
Old 07-21-2011 , 17:18   Re: Spawn on connect
Reply With Quote #3

Maybe someone can copy code from CSDM mod?
Because there on connect you are always respawn.
BeeT is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 07-21-2011 , 19:35   Re: Spawn on connect
Reply With Quote #4

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

#define TID_HIDE_MENU 5323568

new bool:g_autojoin_team[33]
new 
bool:g_autojoin_class[33]
new 
g_vgui_menus[33][5]

public 
plugin_init(){
    
register_plugin("autojoin""1.0""Sylwester")
    
register_message(get_user_msgid("ShowMenu"), "message_show_menu")
}


public 
client_connect(id){
    
get_user_info(id"_vgui_menus"g_vgui_menus[id], 4)
    
set_user_info(id"_vgui_menus""0")
    
g_autojoin_team[id] = true
}


public 
message_show_menu(msgiddestid) {
    new 
tmp[32]
    
get_msg_arg_string(4tmp31)
    if(
contain(tmp"#Team_Select")==0){
        if(!
g_autojoin_team[id])
            return 
PLUGIN_CONTINUE
        g_autojoin_team
[id] = false
        g_autojoin_class
[id] = true
        client_cmd
(id"jointeam 5")
        return 
PLUGIN_HANDLED
    
}
    if(
contain(tmp"#CT_Select")==|| contain(tmp"#Terrorist_Select")==0){
        if(!
g_autojoin_class[id])
            return 
PLUGIN_CONTINUE
        
if(!task_exists(TID_HIDE_MENU+id))
            
set_task(0.1"hide_menu"TID_HIDE_MENU+id)
        
g_autojoin_class[id] = false
        client_cmd
(id"joinclass 5")
        
set_user_info(id"_vgui_menus"g_vgui_menus[id])
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
hide_menu(tid){
    new 
id tid-TID_HIDE_MENU
    show_menu
(id0"^n"1)
    if(!
is_user_alive(id))
        
ExecuteHam(Ham_CS_RoundRespawnid)

__________________
Impossible is Nothing
Sylwester is offline
BeeT
Junior Member
Join Date: Aug 2010
Old 07-22-2011 , 03:14   Re: Spawn on connect
Reply With Quote #5

It works, thanks man, but i have one more problem.
I edited hide_menu

Code:
public hide_menu(tid){
	new id = tid-TID_HIDE_MENU
	show_menu(id, 0, "^n", 1)
	set_task(1.0, "Respawn", id)
}

and

Code:
public Respawn(id)
{
	if(is_user_alive(id))
		return HAM_IGNORED;
	
	ExecuteHamB(Ham_CS_RoundRespawn, id);
	return HAM_IGNORED;
}


Why after connect i don't see "Respawned" message?
client_print(id, print_chat, "Respawned!");
BeeT 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 01:10.


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